Skip to content

Commit a3a9b33

Browse files
fishilicogregkh
authored andcommitted
ASoC: Intel: Atom: add a missing star in a memcpy call
commit 61ab0d4 upstream. In sst_prepare_and_post_msg(), when a response is received in "block", the following code gets executed: *data = kzalloc(block->size, GFP_KERNEL); memcpy(data, (void *) block->data, block->size); The memcpy() call overwrites the content of the *data pointer instead of filling the newly-allocated memory (which pointer is hold by *data). Fix this by merging kzalloc+memcpy into a single kmemdup() call. Thanks Joe Perches for suggesting using kmemdup() Fixes: 60dc8db ("ASoC: Intel: sst: Add some helper functions") Signed-off-by: Nicolas Iooss <[email protected]> Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 85e27fe commit a3a9b33

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

sound/soc/intel/atom/sst/sst_pvt.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,15 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst,
279279

280280
if (response) {
281281
ret = sst_wait_timeout(sst, block);
282-
if (ret < 0) {
282+
if (ret < 0)
283283
goto out;
284-
} else if(block->data) {
285-
if (!data)
286-
goto out;
287-
*data = kzalloc(block->size, GFP_KERNEL);
288-
if (!(*data)) {
284+
285+
if (data && block->data) {
286+
*data = kmemdup(block->data, block->size, GFP_KERNEL);
287+
if (!*data) {
289288
ret = -ENOMEM;
290289
goto out;
291-
} else
292-
memcpy(data, (void *) block->data, block->size);
290+
}
293291
}
294292
}
295293
out:

0 commit comments

Comments
 (0)