From patchwork Thu Jul 7 08:14:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9218273 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 A627C60B16 for ; Thu, 7 Jul 2016 08:14:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A74E28326 for ; Thu, 7 Jul 2016 08:14:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EFF4287A9; Thu, 7 Jul 2016 08:14:41 +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, UNPARSEABLE_RELAY 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 BAB2D287A4 for ; Thu, 7 Jul 2016 08:14:39 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0A8A22656F5; Thu, 7 Jul 2016 10:14:36 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8277E265262; Thu, 7 Jul 2016 10:14:27 +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 9318A265329; Thu, 7 Jul 2016 10:14:26 +0200 (CEST) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by alsa0.perex.cz (Postfix) with ESMTP id 0A9E02650FA for ; Thu, 7 Jul 2016 10:14:18 +0200 (CEST) Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u678EGgS002591 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Jul 2016 08:14:16 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u678EETd004883 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Jul 2016 08:14:15 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u678ECpg005468; Thu, 7 Jul 2016 08:14:12 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 07 Jul 2016 08:14:11 +0000 Date: Thu, 7 Jul 2016 11:14:04 +0300 From: Dan Carpenter To: Liam Girdwood , Garlic Tseng Message-ID: <20160707081404.GB16645@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, Takashi Iwai , Mark Brown , linux-mediatek@lists.infradead.org, Matthias Brugger Subject: [alsa-devel] [patch] ASoC: mediatek: mt2701: fix some error handling in probe 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 The check for if the "afe" allocation failed was too late and there wasn't a check for "afe->platform_priv". Fixes: 43a6a7e71063 ('ASoC: mediatek: add mt2701 platform driver implementation.') Signed-off-by: Dan Carpenter Acked-by: Garlic Tseng diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index c865ba1..fc5a87d 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -1350,11 +1350,13 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) ret = 0; afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); + if (!afe) + return -ENOMEM; afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv), GFP_KERNEL); - afe_priv = afe->platform_priv; - if (!afe) + if (!afe->platform_priv) return -ENOMEM; + afe_priv = afe->platform_priv; afe->dev = &pdev->dev; dev = afe->dev;