From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54DDAC43219 for ; Thu, 2 May 2019 11:33:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19A572075E for ; Thu, 2 May 2019 11:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726533AbfEBLdy (ORCPT ); Thu, 2 May 2019 07:33:54 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:44063 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbfEBLdx (ORCPT ); Thu, 2 May 2019 07:33:53 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hM9y8-0005q6-Uv; Thu, 02 May 2019 11:33:41 +0000 From: Colin King To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Pierre-Louis Bossart , alsa-devel@alsa-project.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] ASoC: SOF: remove redundant null checks of dai Date: Thu, 2 May 2019 12:33:40 +0100 Message-Id: <20190502113340.8688-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently there are two null checks of pointer dai in function sof_connect_dai_widget and yet there is no null check of dai at the end of the function when checking !dai->name. The latter would be a null pointer deference if dai is null (as picked up by static analysis), however the function is only ever called when dai is successfully allocated, so the null checks are redundant. Clean up the code by removing the null checks. Addresses-Coverity: ("Dereference after null check") Signed-off-by: Colin Ian King --- sound/soc/sof/topology.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 2b9de1b97447..1f71857298a9 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1127,15 +1127,13 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp, switch (w->id) { case snd_soc_dapm_dai_out: rtd->cpu_dai->capture_widget = w; - if (dai) - dai->name = rtd->dai_link->name; + dai->name = rtd->dai_link->name; dev_dbg(sdev->dev, "tplg: connected widget %s -> DAI link %s\n", w->name, rtd->dai_link->name); break; case snd_soc_dapm_dai_in: rtd->cpu_dai->playback_widget = w; - if (dai) - dai->name = rtd->dai_link->name; + dai->name = rtd->dai_link->name; dev_dbg(sdev->dev, "tplg: connected widget %s -> DAI link %s\n", w->name, rtd->dai_link->name); break; -- 2.20.1