From patchwork Wed Nov 25 12:49:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7711211 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 096BD9F1D3 for ; Fri, 27 Nov 2015 07:05:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0804120641 for ; Fri, 27 Nov 2015 07:05:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3064020555 for ; Fri, 27 Nov 2015 07:05:29 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6D4FF26052F; Fri, 27 Nov 2015 08:05:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6B90B26058D; Fri, 27 Nov 2015 08:05:21 +0100 (CET) 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 7286C2606CD; Wed, 25 Nov 2015 13:50:39 +0100 (CET) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by alsa0.perex.cz (Postfix) with ESMTP id 6166426058D for ; Wed, 25 Nov 2015 13:50:32 +0100 (CET) Received: by wmec201 with SMTP id c201so68742120wme.1 for ; Wed, 25 Nov 2015 04:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=8gLlHdElXr1dr2i5sGhr36Pc7aJCxMvJj85fi5OF41Q=; b=Wda3Cbcg7+KhrrOQjHJM7yubloB1/jNFo/nmRjhV61vYZS80wtAuiIEIXojmNs686A xvASf3j/tUMO47bxiHTQjiPZjuHLxlyD1maw5mDJ8M3J3PwNADiPaBF+z0e9LgHjuR8w ooK/APls/03Y/8uE1itOvz+wMpiC9BzfDJD6V7fTYbJF6FJHN1ZS4C5rBf5pFyJ5AP7Y A3/Bcri/LnVwBL9M69gZeYfnMlKELpvVB9KSwg8noRcMzXtzw1mM5kHzvgtBQkRSSrw6 NKM0xHhpNtKUW+b25xKBHsSgDj/exmH+wBLmO2+n1/MbYR97/mWXLIbwqXumGAx7rzsV 2FUA== X-Received: by 10.28.72.136 with SMTP id v130mr4212554wma.60.1448455832138; Wed, 25 Nov 2015 04:50:32 -0800 (PST) Received: from Red.local (ANice-651-1-274-133.w86-193.abo.wanadoo.fr. [86.193.134.133]) by smtp.googlemail.com with ESMTPSA id lx4sm23013858wjb.5.2015.11.25.04.50.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Nov 2015 04:50:31 -0800 (PST) From: LABBE Corentin To: alsa-devel@alsa-project.org, broonie@kernel.org, kuninori.morimoto.gx@renesas.com, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com Date: Wed, 25 Nov 2015 13:49:35 +0100 Message-Id: <1448455796-27315-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.10 X-Mailman-Approved-At: Fri, 27 Nov 2015 08:05:20 +0100 Cc: LABBE Corentin , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: rsnd: fix a possible NULL dereference 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP of_match_device could return NULL, and so cause a NULL pointer dereference later. Even if the probability of this case is very low, fixing it made static analyzers happy. Solving this with of_device_get_match_data made also code simplier. Signed-off-by: LABBE Corentin --- sound/soc/sh/rcar/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index deed48e..54cc44c 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1204,7 +1204,6 @@ static int rsnd_probe(struct platform_device *pdev) struct rsnd_priv *priv; struct device *dev = &pdev->dev; struct rsnd_dai *rdai; - const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev); const struct rsnd_of_data *of_data; int (*probe_func[])(struct platform_device *pdev, const struct rsnd_of_data *of_data, @@ -1221,11 +1220,13 @@ static int rsnd_probe(struct platform_device *pdev) }; int ret, i; + of_data = of_device_get_match_data(dev); + if (!of_data) + return 1; info = devm_kzalloc(&pdev->dev, sizeof(struct rcar_snd_info), GFP_KERNEL); if (!info) return -ENOMEM; - of_data = of_id->data; /* * init priv data