From patchwork Sun Aug 28 18:17:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 9304363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B9FC601C0 for ; Mon, 29 Aug 2016 19:00:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BB022894A for ; Mon, 29 Aug 2016 19:00:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08D3F288DF; Mon, 29 Aug 2016 19:00:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48255288DF for ; Mon, 29 Aug 2016 19:00:56 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 53244267426; Mon, 29 Aug 2016 21:00:55 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C3BB22667A5; Mon, 29 Aug 2016 20:19:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9187E2667A5; Mon, 29 Aug 2016 20:19:47 +0200 (CEST) Received: from smtprelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by alsa0.perex.cz (Postfix) with ESMTP id 395192674F3 for ; Mon, 29 Aug 2016 19:02:11 +0200 (CEST) Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave08.hostedemail.com (Postfix) with ESMTP id 19B3F2111EA for ; Sun, 28 Aug 2016 18:22:14 +0000 (UTC) Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 5ACD86ABF4; Sun, 28 Aug 2016 18:17:13 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: shirt95_21cf326900f3a X-Filterd-Recvd-Size: 3045 Received: from XPS-9350.home (unknown [96.251.125.34]) (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA; Sun, 28 Aug 2016 18:17:12 +0000 (UTC) Message-ID: <1472408231.26978.98.camel@perches.com> From: Joe Perches To: Nicolas Iooss , Liam Girdwood , Mark Brown , alsa-devel@alsa-project.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> X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Cc: linux-kernel@vger.kernel.org Subject: Re: [alsa-devel] [PATCH 1/1] ASoC: Intel: Atom: add a missing star in a memcpy call X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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: