From patchwork Mon Jul 31 21:37:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 13335497 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 BD2C3C001E0 for ; Mon, 31 Jul 2023 21:39:28 +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 9923AFA; Mon, 31 Jul 2023 23:38:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9923AFA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839566; bh=sNsN8EC1sC6pKQi+Ke0PT79DyXqCkZVD5XZycTAyHgQ=; 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=QAM7nVnwo4foYeS8gzDHokO8Z1jnili7jo70XdzAulQRcWP0GRyLZ8Vjojh/+Nvh1 l/8vGCl3AJc13hhoRRB056HG7EcB3GbPYYihfNTQRrp9SpBARygFqii7+Ymz3OGJ7w QJ4Mtj1IJR1FKrpGraBMxuArgyzlZos938z6eMbk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 85377F8055C; Mon, 31 Jul 2023 23:38:18 +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 701F4F80563; Mon, 31 Jul 2023 23:38:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1085BF80549; Mon, 31 Jul 2023 23:38:13 +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 07288F8053B for ; Mon, 31 Jul 2023 23:38:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 07288F8053B 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=cuhRacWW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690839490; x=1722375490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sNsN8EC1sC6pKQi+Ke0PT79DyXqCkZVD5XZycTAyHgQ=; b=cuhRacWWoXFTlHTsIvxpbtwI9cAp7dRqGtqutxdwmrp+hfACK6IjOenU yWMF5lONZkUQnfx6+ruBW8nr6NHxmMZrsHAljprz7a6aLj0CpyG2HPAEv V2mVldUs6+GpzeJm8bdKSQ7+TuWd4Ckg/ioANOTkNauYOTRYfvxWvoY2W 4hMzWQ0C1tEsxkg6SkIUzMBbE9u1i1XDPotwWGa1r4w0MNGw5uRFPjQHB w8LQF8GCDxA2MPZvTmLoTycsS/wDBa8AOrgct9gElUAL3DknOJrtxlf4U 1e1WGOaEZwrvWl3IccYDE957n2WqmoI6RWQN2opjKYrazqKzsSjBTiGW+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604091" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604091" 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:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880026" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880026" 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:03 -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 1/8] ASoC: SOF: sof-client-probes-ipc4: add checks to prevent static analysis warnings Date: Mon, 31 Jul 2023 16:37:41 -0500 Message-Id: <20230731213748.440285-2-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: 5LMDGNHSMBWTKTAWKJK6KXXYY5GITK62 X-Message-ID-Hash: 5LMDGNHSMBWTKTAWKJK6KXXYY5GITK62 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: make KCFLAGS='-fanalyzer' sound/soc/sof/ reports several NULL pointer dereference paths. sof_ipc4_probe_get_module_info() can return a NULL value, but it's only tested in the init state. Static analyzers cannot know the probe state machine and hence flags a potential issue for all calls of that function. Squelch these errors by adding the same check consistently. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- sound/soc/sof/sof-client-probes-ipc4.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sound/soc/sof/sof-client-probes-ipc4.c b/sound/soc/sof/sof-client-probes-ipc4.c index ea21ef176c42..c56a85854d92 100644 --- a/sound/soc/sof/sof-client-probes-ipc4.c +++ b/sound/soc/sof/sof-client-probes-ipc4.c @@ -146,6 +146,9 @@ static int ipc4_probes_deinit(struct sof_client_dev *cdev) struct sof_man4_module *mentry = sof_ipc4_probe_get_module_info(cdev); struct sof_ipc4_msg msg; + if (!mentry) + return -ENODEV; + msg.primary = mentry->id; msg.primary |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_MOD_DELETE_INSTANCE); msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); @@ -197,6 +200,9 @@ static int ipc4_probes_points_add(struct sof_client_dev *cdev, struct sof_ipc4_msg msg; int i, ret; + if (!mentry) + return -ENODEV; + /* The sof_probe_point_desc and sof_ipc4_probe_point structs * are of same size and even the integers are the same in the * same order, and similar meaning, but since there is no @@ -247,6 +253,9 @@ static int ipc4_probes_points_remove(struct sof_client_dev *cdev, u32 *probe_point_ids; int i, ret; + if (!mentry) + return -ENODEV; + probe_point_ids = kcalloc(num_buffer_id, sizeof(*probe_point_ids), GFP_KERNEL); if (!probe_point_ids) From patchwork Mon Jul 31 21:37:42 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: 13335498 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 79EE6C04A94 for ; Mon, 31 Jul 2023 21:39:41 +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 D3F36852; Mon, 31 Jul 2023 23:38:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D3F36852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839579; bh=TT//xhE8LJQih3OlJzpd6S9o6Jf8OcD3SeZFDVF5am8=; 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=iSAdGymXOosQ5bkYx3M0ATsc1ZOyqOMgvo3LtIBgnQFB6fTwHcPVTLsVhfE/ku1C6 P+UwZKaM3jzAQ9hbErJCZDYtYmVeix2ABuvyrzL8orjb8Y+uIztd/BwEfCKOaTFEfX 3o1BytV1U3j7iDlKwFig7v/B5I+GvEvrtt2ALHQc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C0B08F80580; Mon, 31 Jul 2023 23:38:22 +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 12B92F80544; Mon, 31 Jul 2023 23:38:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CBFDBF80564; Mon, 31 Jul 2023 23:38:14 +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 ACEB5F8025A for ; Mon, 31 Jul 2023 23:38:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ACEB5F8025A 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=WgMlN1+a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690839489; x=1722375489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TT//xhE8LJQih3OlJzpd6S9o6Jf8OcD3SeZFDVF5am8=; b=WgMlN1+aBDXxeqB5r6fFdohezBGxnJ5+vi2PPt6CbibyFbqiBwQ8e76Z VSbpuqL/Of3gp13Ozb9Qc4UgXdk9zaf4KO0YGazTzzbVcDUrIwxC6PxCx bN0Zk6meqdTyuR2I/DuxOqz3bBJb1eHE1j+EgaLde7Yt6X7DR9euKaIxP 4WQnLvw8R8xNUsOuFCBlOVYijSrn9ejMA90ru65uAHmePIn29gf78a37A HAMSkBh0xkxPUjIJUgtdcZ+X67OL38hE1qdqQ2HcwqR7bO6tVMRHMgXLW VRnqsa/KgmjWbeNw8+QVsohYRdxY8/GOqVS0Ejby88B4sW1SIwOYf5BNP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604099" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604099" 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:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880034" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880034" 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:05 -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 2/8] ASoC: SOF: ipc3: add checks to prevent static analysis warnings Date: Mon, 31 Jul 2023 16:37:42 -0500 Message-Id: <20230731213748.440285-3-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: VWFZGFRIMYCJAPAF53UZQ77NTG2KUQEP X-Message-ID-Hash: VWFZGFRIMYCJAPAF53UZQ77NTG2KUQEP 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: make KCFLAGS='-fanalyzer' sound/soc/sof/ reports an issue with memcpy: sound/soc/sof/ipc3.c: In function ‘ipc3_wait_tx_done’: sound/soc/sof/ipc3.c:309:33: error: use of NULL ‘reply_data’ where non-null expected [CWE-476] [-Werror=analyzer-null-argument] 309 | memcpy(reply_data, msg->reply_data, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 310 | msg->reply_size); The finding is legit with this call: return sof_ipc3_tx_msg(sdev, &pm_ctx, sizeof(pm_ctx), NULL, 0, false); Static analysis has no way of knowing that the reply will be zero-sized. Add a check to only do the memcpy if the reply size is not zero and the destination pointer is not NULL. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- sound/soc/sof/ipc3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/ipc3.c b/sound/soc/sof/ipc3.c index 2c5aac31e8b0..09834205b119 100644 --- a/sound/soc/sof/ipc3.c +++ b/sound/soc/sof/ipc3.c @@ -312,7 +312,7 @@ static int ipc3_wait_tx_done(struct snd_sof_ipc *ipc, void *reply_data) } else { if (sof_debug_check_flag(SOF_DBG_PRINT_IPC_SUCCESS_LOGS)) ipc3_log_header(sdev->dev, "ipc tx succeeded", hdr->cmd); - if (msg->reply_size) + if (reply_data && msg->reply_size) /* copy the data returned from DSP */ memcpy(reply_data, msg->reply_data, msg->reply_size); From patchwork Mon Jul 31 21:37:43 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: 13335503 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 DBA2CC001E0 for ; Mon, 31 Jul 2023 21:41:02 +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 D3646950; Mon, 31 Jul 2023 23:40:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D3646950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839660; bh=fPhiiq55j/+ahMHT94Bc2s7ZfXhpAe04roSi7bxEURE=; 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=TUgfNsphPv9xB0ithgxRB6na960pNlm49kCpx70WBh2qxAaMwNN1x0gUUF5WFjzwU 89gZyFEuor07fhgqnnh0+Ug1P9Y2f1xe/bqikuh5cGeC3bqPXtZS+X6wry1+D6ngvc Bja6qLBj7oH6Ma/2ZpeuOlH3tyo6yNd0qQrJzAOg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 32712F805B6; Mon, 31 Jul 2023 23:38:39 +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 681D0F80579; Mon, 31 Jul 2023 23:38:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 35E17F8057E; Mon, 31 Jul 2023 23:38:23 +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 EEC28F80535 for ; Mon, 31 Jul 2023 23:38:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EEC28F80535 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=gtSo0xtR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690839491; x=1722375491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fPhiiq55j/+ahMHT94Bc2s7ZfXhpAe04roSi7bxEURE=; b=gtSo0xtRXUy5chqwIdHdcg29L8iEsVNF6NVpIll8yscoGy2wnG+cWiMB qrFT02YXy3lVAOwf36pkqittQw5Rl6bnuMtKokpfFqg1LSC4Gj5GZhjKx mCSO/UABv5Zdv3HmVOJlOUmoo3QIj5pen04+MfhEWbhUqdYNTXaMn8JH+ RDbrfPUSB5cu/l2SeoRplrtrKg8GeQdc1d0nwC70ZAF3e11kGno39mAZa AdTqadGu7nKDCcczr8P1nOv82zAj9uVnzWosSxJwF/uK1H92jADPVHQk2 7OWfBzO6pnu8lz23lQ8qa+m+vJIOlY9FPLxxmSklobl3Hb9Z4Py0zgm9o A==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604103" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604103" 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:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880040" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880040" 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:06 -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 3/8] ASoC: SOF: topology: simplify code to prevent static analysis warnings Date: Mon, 31 Jul 2023 16:37:43 -0500 Message-Id: <20230731213748.440285-4-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: X37FX7AMPJVI25PBZ5OJ6E76G2IXV5SE X-Message-ID-Hash: X37FX7AMPJVI25PBZ5OJ6E76G2IXV5SE 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: make KCFLAGS='-fanalyzer' sound/soc/sof/intel/ reports a possible NULL pointer dereference. sound/soc/sof/topology.c:1136:21: error: dereference of NULL ‘w’ [CWE-476] [-Werror=analyzer-null-dereference] 1136 | strcmp(w->sname, rtd->dai_link->stream_name)) The code is rather confusing and can be simplified to make static analysis happy. No functionality change. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- sound/soc/sof/topology.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 698129dccc7d..3866dd3cba69 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1117,10 +1117,11 @@ static void sof_disconnect_dai_widget(struct snd_soc_component *scomp, { struct snd_soc_card *card = scomp->card; struct snd_soc_pcm_runtime *rtd; + const char *sname = w->sname; struct snd_soc_dai *cpu_dai; int i, stream; - if (!w->sname) + if (!sname) return; if (w->id == snd_soc_dapm_dai_out) @@ -1133,7 +1134,7 @@ static void sof_disconnect_dai_widget(struct snd_soc_component *scomp, list_for_each_entry(rtd, &card->rtd_list, list) { /* does stream match DAI link ? */ if (!rtd->dai_link->stream_name || - strcmp(w->sname, rtd->dai_link->stream_name)) + strcmp(sname, rtd->dai_link->stream_name)) continue; for_each_rtd_cpu_dais(rtd, i, cpu_dai) From patchwork Mon Jul 31 21:37:44 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: 13335502 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 5E0F2C04A94 for ; Mon, 31 Jul 2023 21:40:52 +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 8AF70846; Mon, 31 Jul 2023 23:40:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8AF70846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839650; bh=bx1kbEvqfdBzjp5ne8h2vYYEwMySusNwUEtHoqCIXbg=; 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=bb/g5C6vDm+9E69S+30jvrx4mIIMj/E3/g2H774ctE+WxFZ6ALuJuHGIFuSBLlZHV QrXcXkhF2wbtHFyXAuXz7CC1n+c2Q1VLpo26cmsMzUN6cuTqpLEvBAcvNlwCg7sUMs eEYyvHpva8l0IwfqfjKtgkzHQB6AAE6WKcyjLziw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F35BFF805C4; Mon, 31 Jul 2023 23:38:35 +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 0B54BF805BD; Mon, 31 Jul 2023 23:38:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CDFF9F8057B; Mon, 31 Jul 2023 23:38:21 +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 B5908F80544 for ; Mon, 31 Jul 2023 23:38:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B5908F80544 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=Bw1qGuCn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690839492; x=1722375492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bx1kbEvqfdBzjp5ne8h2vYYEwMySusNwUEtHoqCIXbg=; b=Bw1qGuCnJVZO9oYYwziOOiejrI4HaNtoJmAWIzJq57eirS+s/Yy1PToi /xPzM6tEok+e4Tnu3YBzj6ot2bUYy/OZH5qiqEOQfQw2pc0mu2XV9ziAm KGyT3Tiet1jGqtsik7xWGi8vzLHMvYfX6s/586wbUfwcDc1etUZRI5nz+ hK/Ci/xBeToLfORIOVhnsEnILarUqa/0LbXZ6jCUvdCMUbhiDJHUUR+Y9 Khy3syUAOCIygqS+mSHWuzinXA+d2S5s2TTR3LoFm/P06lmkckRE4Wjv6 c7IIKJ3OetaSDmWEr6e8B+swcMCorTa2ybFjEBzRdBKD8go+bbDS6JOrf Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604112" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604112" 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:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880050" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880050" 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:07 -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 4/8] ASoC: SOF: imx: remove error checks on NULL ipc Date: Mon, 31 Jul 2023 16:37:44 -0500 Message-Id: <20230731213748.440285-5-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: AL4KUUL5YRQOAV5YUZISYY57W5GX2V6D X-Message-ID-Hash: AL4KUUL5YRQOAV5YUZISYY57W5GX2V6D 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: imx_dsp_get_data() can return NULL, but the value is not checked before being usd, leading to static analysis warnings. sound/soc/sof/imx/imx8.c:85:32: error: dereference of NULL ‘0’ [CWE-476] [-Werror=analyzer-null-dereference] 85 | spin_lock_irqsave(&priv->sdev->ipc_lock, flags); | ~~~~^~~~~~ It appears this is not really a possible problem, so remove those checks. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- include/linux/firmware/imx/dsp.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/linux/firmware/imx/dsp.h b/include/linux/firmware/imx/dsp.h index 4f7895a3b73c..1f176a2683fe 100644 --- a/include/linux/firmware/imx/dsp.h +++ b/include/linux/firmware/imx/dsp.h @@ -37,17 +37,11 @@ struct imx_dsp_ipc { static inline void imx_dsp_set_data(struct imx_dsp_ipc *ipc, void *data) { - if (!ipc) - return; - ipc->private_data = data; } static inline void *imx_dsp_get_data(struct imx_dsp_ipc *ipc) { - if (!ipc) - return NULL; - return ipc->private_data; } From patchwork Mon Jul 31 21:37:45 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: 13335499 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 41D60C001DE for ; Mon, 31 Jul 2023 21:39:56 +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 61F16836; Mon, 31 Jul 2023 23:39:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 61F16836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839594; bh=eIHSLTn49PLH6BaHj9sdqt6aQ09Bsd1DBy7WeFJFRvA=; 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=kQWraN/wDjWs25SLsK5QJGPcSSqOnYi2zngDtL/5ydhJk97JDs3yfuSkoMZLlhCg9 GgMw/lWebP55E2e3833DGUqNozXkPxZmgVRZ/CIehVhgpKrNyU0yU4wSnCu6zNCWdY 8jl2gcpi5D17zfxFda46QKie25bS3WhaA7i5Sh7k= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4B47AF80544; Mon, 31 Jul 2023 23:38:24 +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 C5246F80544; Mon, 31 Jul 2023 23:38:23 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A92FAF8055C; Mon, 31 Jul 2023 23:38:15 +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 B9CE3F80563 for ; Mon, 31 Jul 2023 23:38:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B9CE3F80563 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=nxGNcvC4 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=eIHSLTn49PLH6BaHj9sdqt6aQ09Bsd1DBy7WeFJFRvA=; b=nxGNcvC4cH2nb2OPMJbEie+wwoYgLtpCvfBuo94z/5BeQIswWNThlpj6 41j+Lxl6aKpC4eHxffMBGm2MX47uqUzSnUN42VHQFK4ZuIATgNqJ3hvvL ar7Joq5VXkEKhyFgzIUZbBabopEaphpYZuaW7t5YMVIVA3EhSue25ZTRd G55jHOiHDxcRwKVS/+Md1NDk5dlUzSLzSXIzOn8qlcYLGYzW/edRC5Bi+ vnLITXxuokxoNWarQkpZ/d7QOVW2RscQVCshpNquW5wHw4bNMAMsZQSQO ENqqK3ZQBjU6DaNzf9k3KBhWyT350I/PNmQdR0vk0G4n9wV8PwVDdpn5/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604116" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604116" 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:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880069" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880069" 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:10 -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 5/8] ASoC: SOF: mediatek: remove error checks on NULL ipc Date: Mon, 31 Jul 2023 16:37:45 -0500 Message-Id: <20230731213748.440285-6-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: ERUS7LZ25KT6XL6TIRJUF2EVGJRWFNGW X-Message-ID-Hash: ERUS7LZ25KT6XL6TIRJUF2EVGJRWFNGW 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: mtk_adsp_ipc_get_data() can return NULL, but the value is not checked before being used, leading to static analysis warnings. sound/soc/sof/mediatek/mt8195/mt8195.c:90:32: error: dereference of NULL ‘0’ [CWE-476] [-Werror=analyzer-null-dereference] 90 | spin_lock_irqsave(&priv->sdev->ipc_lock, flags); | ~~~~^~~~~~ It appears this is not really a possible problem, so remove those checks. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- include/linux/firmware/mediatek/mtk-adsp-ipc.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/linux/firmware/mediatek/mtk-adsp-ipc.h b/include/linux/firmware/mediatek/mtk-adsp-ipc.h index 28fd313340b8..5b1d16fa3f56 100644 --- a/include/linux/firmware/mediatek/mtk-adsp-ipc.h +++ b/include/linux/firmware/mediatek/mtk-adsp-ipc.h @@ -46,17 +46,11 @@ struct mtk_adsp_ipc { static inline void mtk_adsp_ipc_set_data(struct mtk_adsp_ipc *ipc, void *data) { - if (!ipc) - return; - ipc->private_data = data; } static inline void *mtk_adsp_ipc_get_data(struct mtk_adsp_ipc *ipc) { - if (!ipc) - return NULL; - return ipc->private_data; } 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); } From patchwork Mon Jul 31 21:37:47 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: 13335501 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 EF0E9C001DE for ; Mon, 31 Jul 2023 21:40:31 +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 3474D7F8; Mon, 31 Jul 2023 23:39:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3474D7F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839630; bh=n+gYWPAWWn2JLZPyHWV+sZix+i/KMcgEQnVBlEXCl/0=; 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=HjTQv7BdTzS9+b2S4GMQQLXEVxVOuqOMzyY+ezrj93DJA+1o7l4dJBmi39+CNAqA1 H9iW2stutgjTEOK5eEVfskI6clkJ9VcoCl82ksLAoC+6E6HLp/bIU17XHfePai5dUL qfDbs+AfJQi+lj+PDKkdrujuVslURcwt9Uquw65Y= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A5386F805B1; Mon, 31 Jul 2023 23:38:33 +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 EF5F0F805A9; Mon, 31 Jul 2023 23:38:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7695DF80578; Mon, 31 Jul 2023 23:38:20 +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 BA838F8055A for ; Mon, 31 Jul 2023 23:38:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BA838F8055A 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=QgWirXHq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690839496; x=1722375496; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n+gYWPAWWn2JLZPyHWV+sZix+i/KMcgEQnVBlEXCl/0=; b=QgWirXHqN9GWSxHju5FgGkFSf/9VLtOGTEG6j+almCKXheoNuCqQhyvw xzHYGxXjbt5PXNTD9jbQO2VqHOoJhFXjs/bDBMnazxe9jNyvfunH/ortu 5RdU6VrSaNCXuMLgu0iISoewKaCMzVQhoLRDX4nRDHr1NFDXPXpMRl7wW 66LReZJJaQZ6ks0Qdj3rCU8wQIBpXoRIWseOJ95HYtEcY/oRRV8C9t96i M0C47aTziU9dd4ytzWmRwaUy8V7LNNalm0hYefLikydJ7GzYMewE/037S zpirT7h17BqJT5LzWJeuLlrAoMpcYU03LaoQ87YP7v8SSB6agnjPRmwu5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604136" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604136" 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:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880083" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880083" 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:12 -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 7/8] ASoC: Intel: atom: remove static analysis false positive Date: Mon, 31 Jul 2023 16:37:47 -0500 Message-Id: <20230731213748.440285-8-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: 7TT6XNC3NMKJUGH667WQZN24O57SBCK2 X-Message-ID-Hash: 7TT6XNC3NMKJUGH667WQZN24O57SBCK2 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: make KCFLAGS='-fanalyzer' sound/soc/intel/atom/ reports a possible NULL pointer dereference. sound/soc/intel/atom/sst/sst_stream.c:221:40: error: dereference of NULL ‘block’ [CWE-476] [-Werror=analyzer-null-dereference] 221 | unsigned char *r = block->data; This is a false-positive, the GCC analyzer generated that report by considering if (bytes->block) as true in some cases and false in others. We can simplify the code and use a local variable so that static analysis does not try to look for cases where bytes->block can be modified concurrently. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- sound/soc/intel/atom/sst/sst_stream.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index 862a19ae5429..288221db7323 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -173,10 +173,11 @@ int sst_send_byte_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, u32 length; int pvt_id, ret = 0; struct sst_block *block = NULL; + u8 bytes_block = bytes->block; dev_dbg(sst_drv_ctx->dev, "type:%u ipc_msg:%u block:%u task_id:%u pipe: %#x length:%#x\n", - bytes->type, bytes->ipc_msg, bytes->block, bytes->task_id, + bytes->type, bytes->ipc_msg, bytes_block, bytes->task_id, bytes->pipe_id, bytes->len); if (sst_create_ipc_msg(&msg, true)) @@ -185,12 +186,12 @@ int sst_send_byte_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, pvt_id = sst_assign_pvt_id(sst_drv_ctx); sst_fill_header_mrfld(&msg->mrfld_header, bytes->ipc_msg, bytes->task_id, 1, pvt_id); - msg->mrfld_header.p.header_high.part.res_rqd = bytes->block; + msg->mrfld_header.p.header_high.part.res_rqd = bytes_block; length = bytes->len; msg->mrfld_header.p.header_low_payload = length; dev_dbg(sst_drv_ctx->dev, "length is %d\n", length); memcpy(msg->mailbox_data, &bytes->bytes, bytes->len); - if (bytes->block) { + if (bytes_block) { block = sst_create_block(sst_drv_ctx, bytes->ipc_msg, pvt_id); if (block == NULL) { kfree(msg); @@ -203,7 +204,7 @@ int sst_send_byte_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, dev_dbg(sst_drv_ctx->dev, "msg->mrfld_header.p.header_low_payload:%d", msg->mrfld_header.p.header_low_payload); - if (bytes->block) { + if (bytes_block) { ret = sst_wait_timeout(sst_drv_ctx, block); if (ret) { dev_err(sst_drv_ctx->dev, "fw returned err %d\n", ret); @@ -216,7 +217,7 @@ int sst_send_byte_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, * copy the reply and send back * we need to update only sz and payload */ - if (bytes->block) { + if (bytes_block) { unsigned char *r = block->data; dev_dbg(sst_drv_ctx->dev, "read back %d bytes", @@ -224,7 +225,7 @@ int sst_send_byte_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, memcpy(bytes->bytes, r, bytes->len); } } - if (bytes->block) + if (bytes_block) sst_free_block(sst_drv_ctx, block); out: test_and_clear_bit(pvt_id, &sst_drv_ctx->pvt_id); From patchwork Mon Jul 31 21:37:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 13335504 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 D7347C001E0 for ; Mon, 31 Jul 2023 21:41:19 +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 1573E868; Mon, 31 Jul 2023 23:40:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1573E868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690839678; bh=OAI2qcEg7OqvHUBhJ2efMbqxaB8PVBmIckjGoOZBK50=; 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=GUY1sNHH4g5QSbCxGoC5JJ8z+34pZY3lbZZ4hsnVcoln0dmKkzHiJlj+Gwa46ieNY C7RopqTexlY5QV+YHQ8v8iRtiqco4Sb5+LnaYrKexGpzIySvmuKBHMcqd+M6oa4u/F cJfq8QjEQ6xYHWwPb3rDdsDQH2S8sExNhlh/UUUI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 055C4F805D5; Mon, 31 Jul 2023 23:38:42 +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 6350DF805CA; Mon, 31 Jul 2023 23:38:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1A8D0F80588; Mon, 31 Jul 2023 23:38:23 +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 80CA9F8056F for ; Mon, 31 Jul 2023 23:38:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 80CA9F8056F 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=XgC8OyPX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690839501; x=1722375501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OAI2qcEg7OqvHUBhJ2efMbqxaB8PVBmIckjGoOZBK50=; b=XgC8OyPXjtxxd3y5vbxijW+GVBoFiPHt3i5maXvP+KA0uBPZnaNHVllb bt9svEGP+lGSFLKcW5UGV2jQADsx0leCuOzGvG5EjwprMhMfB6ctna4vL wYO0gtIugye/fuUyJAAEzsMgg24VTso1vO/4CFVArpelHbMAkLsU4GDzu mTLe35KTxXEkm2nC/acFL3njM8yF886ioBhLT5CHswqtlH1Nvl5fEPcw/ h+ajK21z2HtV/6b0nK2hl0QZR3JpqlA5m9YiUU+IiOLsoTr2bNzvjYLdf FMPNOo3ijW6S2Q2GE8uEU6Ec/9nfW7Oif5ll3IZLlyH7DuIcLy/0Vy78v A==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="366604154" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="366604154" 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:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="793880102" X-IronPort-AV: E=Sophos;i="6.01,245,1684825200"; d="scan'208";a="793880102" 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:13 -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 8/8] ASoC: amd: acp5x-mach:add checks to avoid static analysis warnings Date: Mon, 31 Jul 2023 16:37:48 -0500 Message-Id: <20230731213748.440285-9-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: ET26PBT6VAV5J66OAERMM42GLM7PMCLX X-Message-ID-Hash: ET26PBT6VAV5J66OAERMM42GLM7PMCLX 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 static analysis warnings. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung --- sound/soc/amd/vangogh/acp5x-mach.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c index 125a8e93478d..eda464545866 100644 --- a/sound/soc/amd/vangogh/acp5x-mach.c +++ b/sound/soc/amd/vangogh/acp5x-mach.c @@ -170,6 +170,9 @@ static int acp5x_nau8821_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai = snd_soc_card_get_codec_dai(card, ACP5X_NAU8821_DAI_NAME); int ret, bclk; + if (!dai) + return -EINVAL; + ret = snd_soc_dai_set_sysclk(dai, NAU8821_CLK_FLL_BLK, 0, SND_SOC_CLOCK_IN); if (ret < 0) dev_err(card->dev, "can't set FS clock %d\n", ret);