From patchwork Mon May 19 08:32:09 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Xiubo Li
X-Patchwork-Id: 4200511
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 0B083BEEAB
for ;
Mon, 19 May 2014 09:19:55 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 1C3D520173
for ;
Mon, 19 May 2014 09:19:54 +0000 (UTC)
Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243])
by mail.kernel.org (Postfix) with ESMTP id 3BCF72028D
for ;
Mon, 19 May 2014 09:19:50 +0000 (UTC)
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id B36B82610C1; Mon, 19 May 2014 11:19:48 +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 CF18D261685;
Mon, 19 May 2014 11:19:42 +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 B485B2619E1; Mon, 19 May 2014 11:19:41 +0200 (CEST)
Received: from na01-bn1-obe.outbound.protection.outlook.com
(mail-bn1blp0189.outbound.protection.outlook.com [207.46.163.189])
by alsa0.perex.cz (Postfix) with ESMTP id 2D5D8260864
for ;
Mon, 19 May 2014 11:19:34 +0200 (CEST)
Received: from DM2PR03CA009.namprd03.prod.outlook.com (10.141.52.157) by
DM2PR03MB510.namprd03.prod.outlook.com (10.141.87.15) with Microsoft
SMTP Server (TLS) id 15.0.944.11; Mon, 19 May 2014 09:19:28 +0000
Received: from BN1BFFO11FD016.protection.gbl (2a01:111:f400:7c10::1:115) by
DM2PR03CA009.outlook.office365.com (2a01:111:e400:2414::29) with
Microsoft SMTP Server (TLS) id 15.0.944.11 via Frontend Transport;
Mon, 19 May 2014 09:19:28 +0000
Received: from az84smr01.freescale.net (192.88.158.2) by
BN1BFFO11FD016.mail.protection.outlook.com (10.58.144.79) with
Microsoft SMTP Server (TLS) id 15.0.949.9 via Frontend Transport;
Mon, 19 May 2014 09:19:28 +0000
Received: from rock.ap.freescale.net (rock.ap.freescale.net [10.193.20.106])
by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id
s4J9JFiu011405; Mon, 19 May 2014 02:19:20 -0700
From: Xiubo Li
To: ,
Date: Mon, 19 May 2014 16:32:09 +0800
Message-ID: <1400488329-31702-1-git-send-email-Li.Xiubo@freescale.com>
X-Mailer: git-send-email 1.8.0
X-EOPAttributedMessage: 0
X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI;
SFV:NSPM;
SFS:(6009001)(189002)(199002)(19580405001)(81156002)(87936001)(19580395003)(88136002)(81542001)(83322001)(92726001)(93916002)(74662001)(77096999)(62966002)(86362001)(81342001)(99396002)(31966008)(84676001)(74502001)(87286001)(77982001)(89996001)(44976005)(50986999)(6806004)(76482001)(68736004)(85852003)(83072002)(50466002)(79102001)(46102001)(69596002)(102836001)(21056001)(47776003)(77156001)(36756003)(20776003)(92566001)(64706001)(48376002)(4396001)(80022001)(50226001);
DIR:OUT; SFP:; SCL:1; SRVR:DM2PR03MB510; H:az84smr01.freescale.net;
FPR:;
MLV:sfv; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en;
MIME-Version: 1.0
X-Forefront-PRVS: 021670B4D2
Received-SPF: Fail (: domain of freescale.com does not designate
192.88.158.2 as permitted sender) receiver=; 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: tiwai@suse.de, alsa-devel@alsa-project.org,
Xiubo Li
Subject: [alsa-devel] [PATCH] ASoC: cache: 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 'reg_size' will always be none zero here,
and then if 'reg_size' equals to zero, the kzalloc() will return ZERO_SIZE_PTR,
which equals to ((void *)16).
So this patch fix this with just doing the 'reg_size' zero check before calling
kzalloc().
Signed-off-by: Xiubo Li
---
sound/soc/soc-cache.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 3fa77d5..8fff5b6 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -72,6 +72,9 @@ int snd_soc_cache_init(struct snd_soc_codec *codec)
reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
+ if (!reg_size)
+ return -EINVAL;
+
mutex_init(&codec->cache_rw_mutex);
dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n",