From patchwork Mon Jul 31 21:37:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 13335500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 062F4C001DE for ; Mon, 31 Jul 2023 21:40:12 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 07F8E86E; Mon, 31 Jul 2023 23:39:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 07F8E86E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839610; bh=Bzebpf+PgboJ9OXM7CKrNmzDFd2cjkZIXNYVnb6RFbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pwzEanQ4HTw7PM9l55sd6jIL4mzVPynhTrapu9a5EFK0dfwkFo+Z8/++IfhZ5o/dZ G/wVtY2fnk/p+Q28g60ThVGGGv1i47Thypgo1b0gtKsg33/6qwi5yNsLvZZlcKJr/E AK4Q5Xxppd2hAMv1sC8LEwrj0w2mzpHNajaYvJ8o= Received: by alsa1.perex.cz (Postfix, from userid 50401) id EA460F805A0; Mon, 31 Jul 2023 23:38:28 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 68C5CF8059F; Mon, 31 Jul 2023 23:38:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0F526F80564; Mon, 31 Jul 2023 23:38:17 +0200 (CEST) Received: from mgamail.intel.com (unknown [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B42FEF80551 for ; Mon, 31 Jul 2023 23:38:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B42FEF80551 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=FlGTKX19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690839494; x=1722375494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Bzebpf+PgboJ9OXM7CKrNmzDFd2cjkZIXNYVnb6RFbs=; b=FlGTKX19sGHj6pEq1v+pal7q4xO2k8cdt5662cFSw3/zRwGv4Cv1iTeb oYbO7m4ajibVrOv9Wzu7jXNd3IvEM4ZwQTK09s2R77VFQl0TBr9BHCK7O iLTQSK64b9a6CYqejKBFKux7opobjSrYacBigXKm6SzDt9dZ3r8HDwRR3 og6LWTYG+L3ziNPB2JQV+9opBgpAUUzKRWnyqMn1MxmSSPk81kquatIZD W2H0baxADAhFTM38qNCfT1ZAjtW910jzTb1a8t0Jp8dEpB2kivwl+duLt /L6SAC8ALPxwQu8sjj+Pm3JmgyMRyaWrCdefxquGVhBNLqVcgbyq3fuZt A==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604126" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604126" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 14:38:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880073" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880073" Received: from youngnic-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.209.180.66]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 14:38:11 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, Pierre-Louis Bossart , Rander Wang , Daniel Baluta , Yaochun Hung Subject: [PATCH 6/8] ASoC: Intel: bdw_rt286: add checks to avoid static analysis warnings Date: Mon, 31 Jul 2023 16:37:46 -0500 Message-Id: <20230731213748.440285-7-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230731213748.440285-1-pierre-louis.bossart@linux.intel.com> References: <20230731213748.440285-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: TUJ6KIJDQ4QNSIRGLU7NXXCP7E6EG3GA X-Message-ID-Hash: TUJ6KIJDQ4QNSIRGLU7NXXCP7E6EG3GA X-MailFrom: pierre-louis.bossart@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: snd_soc_card_get_codec_dai() can return NULL, but that value is not checked for, leading to false-positive static analysis warnings sound/soc/intel/boards/bdw_rt286.c:190:16: error: dereference of NULL ‘codec_dai’ [CWE-476] [-Werror=analyzer-null-dereference] 190 | return snd_soc_component_set_jack(codec_dai->component, NULL, NULL); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ‘card_suspend_pre’: event 1 | | 190 | return snd_soc_component_set_jack(codec_dai->component, NULL, NULL); | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) dereference of NULL ‘codec_dai’ This NULL dereference cannot happen, the codec-dai "rt286-aif1" must exists otherwise the card would not be created. Static analysis cannot know that however so we might as well squelch this report. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- sound/soc/intel/boards/bdw_rt286.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/intel/boards/bdw_rt286.c b/sound/soc/intel/boards/bdw_rt286.c index b7687a93a923..036579331d8f 100644 --- a/sound/soc/intel/boards/bdw_rt286.c +++ b/sound/soc/intel/boards/bdw_rt286.c @@ -187,6 +187,9 @@ static int card_suspend_pre(struct snd_soc_card *card) { struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1"); + if (!codec_dai) + return 0; + return snd_soc_component_set_jack(codec_dai->component, NULL, NULL); } @@ -194,6 +197,9 @@ static int card_resume_post(struct snd_soc_card *card) { struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1"); + if (!codec_dai) + return 0; + return snd_soc_component_set_jack(codec_dai->component, &card_headset, NULL); }