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 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 66B42C6FD1F for ; Wed, 22 Mar 2023 20:07:39 +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 46EC9F21; Wed, 22 Mar 2023 21:06:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 46EC9F21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1679515657; bh=elbZTfnoO9XGtb/v16KA9+EzqGYnj10HocvDxBVSs5Y=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HL82V/ve2mLA7unMR3X0MhO68IEGVyzEpmgvI9toQdRuI36sQ7x/m2XfwJ28sYIf/ djgje941lC/bAZHRdylv1lspHOQgfAr2fwy3NJVMxeOykq6+J122E7EmCtU8/7cUuf x8xj4dfsXpfmpglc0ttphqFhlhhzT0iOeioLMg9A= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 14EBBF80563; Wed, 22 Mar 2023 21:03:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3EFDEF80567; Wed, 22 Mar 2023 21:03:18 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4DF5CF80534 for ; Wed, 22 Mar 2023 21:03:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4DF5CF80534 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=sVae1T5u Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E4CE9B81DE8; Wed, 22 Mar 2023 20:03:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B672CC4339B; Wed, 22 Mar 2023 20:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679515395; bh=elbZTfnoO9XGtb/v16KA9+EzqGYnj10HocvDxBVSs5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVae1T5uFPhN7Nj7WoVvM5b3q8+rO7GbzG46dr7tG/8oUqtl288t9ZNM/Cm6UeT2N BeMbXoFVmq2MMeLYNgD0KW6/BAZbtED03664Am++XkODM1pYdC/XtUwzfMPm00BGGK 7rtPXjg7wJLx/GoWVhlGNH9kv4pQbN5pLMC7/hZeC+sWrRLeInFB7xg7dkA3rWbQPd AXSxPBu3NwtmPsjyH+K3xhILMAKUW52vSLSUqkX13VIc3j6dJQgXvrpRXR0Vpjv+p1 hrbuZOHbPi8jeHjY4sh6S0d/+VaTtAyT8gpLcnCyY7GMq5PejrpcCMQlTOFKSRCs3q FqpLWnKz76bqw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 2/9] ALSA: asihpi: check pao in control_message() Date: Wed, 22 Mar 2023 16:03:02 -0400 Message-Id: <20230322200309.1997651-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230322200309.1997651-1-sashal@kernel.org> References: <20230322200309.1997651-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Message-ID-Hash: YTKQOLTBS2PASCCDW2VC6DACXMMKFIXV X-Message-ID-Hash: YTKQOLTBS2PASCCDW2VC6DACXMMKFIXV X-MailFrom: sashal@kernel.org 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 CC: Kuninori Morimoto , Takashi Iwai , Sasha Levin , tiwai@suse.com, dengshaomin@cdjrlc.com, alsa-devel@alsa-project.org 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: From: Kuninori Morimoto [ Upstream commit 9026c0bf233db53b86f74f4c620715e94eb32a09 ] control_message() might be called with pao = NULL. Here indicates control_message() as sample. (B) static void control_message(struct hpi_adapter_obj *pao, ...) { ^^^ struct hpi_hw_obj *phw = pao->priv; ... ^^^ } (A) void _HPI_6205(struct hpi_adapter_obj *pao, ...) { ^^^ ... case HPI_OBJ_CONTROL: (B) control_message(pao, phm, phr); break; ^^^ ... } void HPI_6205(...) { ... (A) _HPI_6205(NULL, phm, phr); ... ^^^^ } Therefore, We will get too many warning via cppcheck, like below sound/pci/asihpi/hpi6205.c:238:27: warning: Possible null pointer dereference: pao [nullPointer] struct hpi_hw_obj *phw = pao->priv; ^ sound/pci/asihpi/hpi6205.c:433:13: note: Calling function '_HPI_6205', 1st argument 'NULL' value is 0 _HPI_6205(NULL, phm, phr); ^ sound/pci/asihpi/hpi6205.c:401:20: note: Calling function 'control_message', 1st argument 'pao' value is 0 control_message(pao, phm, phr); ^ Set phr->error like many functions doing, and don't call _HPI_6205() with NULL. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87ttypeaqz.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/asihpi/hpi6205.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c index 2864698436a5f..6a49f897c4d91 100644 --- a/sound/pci/asihpi/hpi6205.c +++ b/sound/pci/asihpi/hpi6205.c @@ -441,7 +441,7 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) pao = hpi_find_adapter(phm->adapter_index); } else { /* subsys messages don't address an adapter */ - _HPI_6205(NULL, phm, phr); + phr->error = HPI_ERROR_INVALID_OBJ_INDEX; return; } -- 2.39.2 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A372C6FD1F for ; Wed, 22 Mar 2023 20:12:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbjCVUMU (ORCPT ); Wed, 22 Mar 2023 16:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232077AbjCVULy (ORCPT ); Wed, 22 Mar 2023 16:11:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AAFE7E89D; Wed, 22 Mar 2023 13:04:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30CCE622BF; Wed, 22 Mar 2023 20:03:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B672CC4339B; Wed, 22 Mar 2023 20:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679515395; bh=elbZTfnoO9XGtb/v16KA9+EzqGYnj10HocvDxBVSs5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVae1T5uFPhN7Nj7WoVvM5b3q8+rO7GbzG46dr7tG/8oUqtl288t9ZNM/Cm6UeT2N BeMbXoFVmq2MMeLYNgD0KW6/BAZbtED03664Am++XkODM1pYdC/XtUwzfMPm00BGGK 7rtPXjg7wJLx/GoWVhlGNH9kv4pQbN5pLMC7/hZeC+sWrRLeInFB7xg7dkA3rWbQPd AXSxPBu3NwtmPsjyH+K3xhILMAKUW52vSLSUqkX13VIc3j6dJQgXvrpRXR0Vpjv+p1 hrbuZOHbPi8jeHjY4sh6S0d/+VaTtAyT8gpLcnCyY7GMq5PejrpcCMQlTOFKSRCs3q FqpLWnKz76bqw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kuninori Morimoto , Takashi Iwai , Sasha Levin , perex@perex.cz, tiwai@suse.com, dengshaomin@cdjrlc.com, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 4.19 2/9] ALSA: asihpi: check pao in control_message() Date: Wed, 22 Mar 2023 16:03:02 -0400 Message-Id: <20230322200309.1997651-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230322200309.1997651-1-sashal@kernel.org> References: <20230322200309.1997651-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Kuninori Morimoto [ Upstream commit 9026c0bf233db53b86f74f4c620715e94eb32a09 ] control_message() might be called with pao = NULL. Here indicates control_message() as sample. (B) static void control_message(struct hpi_adapter_obj *pao, ...) { ^^^ struct hpi_hw_obj *phw = pao->priv; ... ^^^ } (A) void _HPI_6205(struct hpi_adapter_obj *pao, ...) { ^^^ ... case HPI_OBJ_CONTROL: (B) control_message(pao, phm, phr); break; ^^^ ... } void HPI_6205(...) { ... (A) _HPI_6205(NULL, phm, phr); ... ^^^^ } Therefore, We will get too many warning via cppcheck, like below sound/pci/asihpi/hpi6205.c:238:27: warning: Possible null pointer dereference: pao [nullPointer] struct hpi_hw_obj *phw = pao->priv; ^ sound/pci/asihpi/hpi6205.c:433:13: note: Calling function '_HPI_6205', 1st argument 'NULL' value is 0 _HPI_6205(NULL, phm, phr); ^ sound/pci/asihpi/hpi6205.c:401:20: note: Calling function 'control_message', 1st argument 'pao' value is 0 control_message(pao, phm, phr); ^ Set phr->error like many functions doing, and don't call _HPI_6205() with NULL. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87ttypeaqz.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/asihpi/hpi6205.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c index 2864698436a5f..6a49f897c4d91 100644 --- a/sound/pci/asihpi/hpi6205.c +++ b/sound/pci/asihpi/hpi6205.c @@ -441,7 +441,7 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) pao = hpi_find_adapter(phm->adapter_index); } else { /* subsys messages don't address an adapter */ - _HPI_6205(NULL, phm, phr); + phr->error = HPI_ERROR_INVALID_OBJ_INDEX; return; } -- 2.39.2