From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755917AbcH1SRP (ORCPT ); Sun, 28 Aug 2016 14:17:15 -0400 Received: from smtprelay0176.hostedemail.com ([216.40.44.176]:34242 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750857AbcH1SRO (ORCPT ); Sun, 28 Aug 2016 14:17:14 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3870:3871:4321:5007:7903:8603:8660:10004:10400:10848:11026:11232:11657:11658:11783:11914:12043:12048:12438:12555:12740:13148:13230:13439:13894:14093:14097:14181:14659:14721:21080:21212:21433:30012:30054:30055:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: shirt95_21cf326900f3a X-Filterd-Recvd-Size: 3045 Message-ID: <1472408231.26978.98.camel@perches.com> Subject: Re: [PATCH 1/1] ASoC: Intel: Atom: add a missing star in a memcpy call From: Joe Perches To: Nicolas Iooss , Liam Girdwood , Mark Brown , alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Date: Sun, 28 Aug 2016 11:17:11 -0700 In-Reply-To: <20160828173945.27721-1-nicolas.iooss_linux@m4x.org> References: <20160828173945.27721-1-nicolas.iooss_linux@m4x.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2016-08-28 at 19:39 +0200, Nicolas Iooss wrote: > 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 using *data in the memcpy() call. > > Fixes: 60dc8dbacb00 ("ASoC: Intel: sst: Add some helper functions") > Cc: stable@vger.kernel.org # 3.19.x > Signed-off-by: Nicolas Iooss > --- >  sound/soc/intel/atom/sst/sst_pvt.c | 2 +- >  1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c > index adb32fefd693..7c398b7c9d4b 100644 > --- a/sound/soc/intel/atom/sst/sst_pvt.c > +++ b/sound/soc/intel/atom/sst/sst_pvt.c > @@ -289,7 +289,7 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst, >   ret = -ENOMEM; >   goto out; >   } else > - memcpy(data, (void *) block->data, block->size); > + memcpy(*data, (void *) block->data, block->size); >   } >   } >  out: Perhaps this would be nicer using kmemdup too ---  sound/soc/intel/atom/sst/sst_pvt.c | 14 ++++++--------  1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c index adb32fe..b1e6b8f 100644 --- a/sound/soc/intel/atom/sst/sst_pvt.c +++ b/sound/soc/intel/atom/sst/sst_pvt.c @@ -279,17 +279,15 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst,   if (response) { ret = sst_wait_timeout(sst, block); - if (ret < 0) { + if (ret < 0) goto out; - } else if(block->data) { - if (!data) - goto out; - *data = kzalloc(block->size, GFP_KERNEL); - if (!(*data)) { + + if (data && block->data) { + *data = kmemdup(block->data, block->size, GFP_KERNEL); + if (!*data) { ret = -ENOMEM; goto out; - } else - memcpy(data, (void *) block->data, block->size); + } } } out: