From patchwork Sun Sep 28 09:29:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 4991281 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13597BEEA6 for ; Sun, 28 Sep 2014 09:30:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AAD8220219 for ; Sun, 28 Sep 2014 09:30:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 17F5620176 for ; Sun, 28 Sep 2014 09:30:31 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C8A21260578; Sun, 28 Sep 2014 11:30:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 1B6E1260568; Sun, 28 Sep 2014 11:30:10 +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 19D44260569; Sun, 28 Sep 2014 11:30:09 +0200 (CEST) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0122.outbound.protection.outlook.com [65.55.169.122]) by alsa0.perex.cz (Postfix) with ESMTP id 91174260567 for ; Sun, 28 Sep 2014 11:30:01 +0200 (CEST) Received: from BN3PR0301CA0047.namprd03.prod.outlook.com (25.160.152.143) by BY2PR0301MB0615.namprd03.prod.outlook.com (25.160.125.25) with Microsoft SMTP Server (TLS) id 15.0.1039.15; Sun, 28 Sep 2014 09:29:58 +0000 Received: from BY2FFO11FD002.protection.gbl (2a01:111:f400:7c0c::114) by BN3PR0301CA0047.outlook.office365.com (2a01:111:e400:401e::15) with Microsoft SMTP Server (TLS) id 15.0.1039.15 via Frontend Transport; Sun, 28 Sep 2014 09:29:57 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD002.mail.protection.outlook.com (10.1.14.124) with Microsoft SMTP Server (TLS) id 15.0.1029.15 via Frontend Transport; Sun, 28 Sep 2014 09:29:57 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s8S9Tsbc020373; Sun, 28 Sep 2014 02:29:55 -0700 From: Xiubo Li To: Date: Sun, 28 Sep 2014 17:29:37 +0800 Message-ID: <1411896577-30965-1-git-send-email-Li.Xiubo@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(92566001)(102836001)(99396003)(84676001)(10300001)(87286001)(93916002)(86362001)(92726001)(21056001)(26826002)(104166001)(120916001)(77156001)(62966002)(80022003)(77982003)(81542003)(74502003)(46102003)(74662003)(81342003)(79102003)(36756003)(20776003)(89996001)(85852003)(64706001)(87936001)(88136002)(69596002)(83072002)(31966008)(68736004)(47776003)(97736003)(90102001)(95666004)(83322001)(19580395003)(19580405001)(44976005)(6806004)(48376002)(50466002)(85306004)(229853001)(50226001)(4396001)(2351001)(76482002)(104016003)(50986999)(107046002)(105606002)(106466001)(81156004)(110136001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB0615; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0615; X-Forefront-PRVS: 03484C0ABF Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=Li.Xiubo@freescale.com; X-OriginatorOrg: freescale.com Cc: alsa-devel@alsa-project.org, Xiubo Li Subject: [alsa-devel] [PATCH] ASoC: core: fix possible ZERO_SIZE_PTR pointer dereferencing error. 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 Since we cannot make sure the 'params->num_regs' will always be none zero here, and then if it equals to zero, the kmemdup() will return ZERO_SIZE_PTR, which equals to ((void *)16). So this patch fix this with just doing the zero check before calling kmemdup(). Signed-off-by: Xiubo Li --- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7b5a7ce..263514a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3051,7 +3051,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, unsigned int val, mask; void *data; - if (!component->regmap) + if (!component->regmap || !params->num_regs) return -EINVAL; len = params->num_regs * component->val_bytes;