From patchwork Fri Mar 10 06:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13168766 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 10DFAC6FA99 for ; Fri, 10 Mar 2023 06:15: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 04B451723; Fri, 10 Mar 2023 07:14:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 04B451723 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1678428909; bh=HZpjx30Se9SsQHbHbRwxCn11/vC+ZfXM4QSlLyjUbl0=; h=From:Subject:To:In-Reply-To:References:Date:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FO3okzm9FLXpan+RYxFagGhN1B19FmBOzuTy3SfoePCOXh3Us+8+tyuItoPu3bkXL A5JZFjK032gXZNxvtX+RPXVjscwBtmKKBFdlBpg7ubhHTtGQVkSPYRIBBBDNYF+r+G KfXfQDsu43HNGfZ9dI5IJLGVgB5O7aylc4A34JVc= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3ACF4F8007E; Fri, 10 Mar 2023 07:13:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A5941F8007E; Fri, 10 Mar 2023 07:13:21 +0100 (CET) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2072d.outbound.protection.outlook.com [IPv6:2a01:111:f403:7010::72d]) (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 7B923F8007E for ; Fri, 10 Mar 2023 07:13:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7B923F8007E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=PGoInEJv ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oMW94CFQMyMuxO3HGLiMI6FWm69BWhdiFAwokWegAEfYtWWkFSIMuTP4ZF5ApiLNdmApf3i/8Z8/3YPbATa+Dtah/wmKvkh2m0bE63SWMUnHhIjVXwk+RDAsxCj5hhxuGkGM3YduR4DJaiv002jRezR59fNfr+1WCv+yo8nMG3LCqcz/3OBSkZlRmCfoYenLDWxaJlNoS2g6fqHsVJ5pbNTJNxp7ishHrRVqgLJ7S5syHvg097YvwYOn3eG/V7muJBWd2NstLf6cI2Kf04A1GT9KeHsRm/2Fw3wHDBoRtm6r9af6HjJYVKeR2ZLBGFluTGYq66j2iU9syDQo+EtthQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rmDNud1kgb4WAQKdI7SN8s1Vm9fyt7CZLa3yRcI0lSE=; b=GXuwXVd8AUdYqUUwk322YQnAd0f8HQppzeRi28xdEYBn9QNW2wsXn6+Jq001aDomQYAK15vy3zS/ANDz7pC2JpygCkTJNcsKqFHnwIrtJeXBsdP1GKAg6Q+4W1O51iGiQu6JWkSppQZSjYkHArFktCilh8RMklQYtP9AlqGy36IBMRWgm03H+caKau0MK+ddxPJOe0eLd713XK/MeAn/uEqInACTUz6hO9+i6Q1so0iLfJHALT6hTgBDQLM2pYlV8Yg+BoU03jOXcIxlSru4aR74NMKLL7H+iVLT0ya/oSjEpGezrEQT4mh2KHa7iUxHD8/Hv2s+oJKdkQkLvUZuQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rmDNud1kgb4WAQKdI7SN8s1Vm9fyt7CZLa3yRcI0lSE=; b=PGoInEJv4Ra2XHBKG7ojcCnQpDazdX328B4gsoe2vHZePMjtXiTwiVbQp76/Jx23F9u4T/D+SjNz8FZBnqkJcxBySd6wCMKGD1sQLAaG7e1bTELqxYZQT0QIezoNGXRWiJD+3ywTKqvLwOhajr8V5pwRwBAKBxx0oiZUOHncioo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TYWPR01MB10612.jpnprd01.prod.outlook.com (2603:1096:400:2a1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 06:13:10 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::e03e:1938:695b:f472]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::e03e:1938:695b:f472%7]) with mapi id 15.20.6178.019; Fri, 10 Mar 2023 06:13:10 +0000 Message-ID: <87edpx2ky2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [RESEND][PATCH 1/2] ASoC: hpi6205.c: check pao in control_message() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Mark Brown In-Reply-To: <87fsad2kzn.wl-kuninori.morimoto.gx@renesas.com> References: <87fsad2kzn.wl-kuninori.morimoto.gx@renesas.com> Date: Fri, 10 Mar 2023 06:13:10 +0000 X-ClientProxiedBy: TY2PR06CA0017.apcprd06.prod.outlook.com (2603:1096:404:42::29) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TYWPR01MB10612:EE_ X-MS-Office365-Filtering-Correlation-Id: 54353523-c0ed-4b83-887f-08db212e860c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: peArKdzGn/kjt8O6qtqm8xNef10Z8FYr8Akv+ZJzWXf/jQjEkgE74cxX4qlKOvnxo0cgUuRHi5suW6AokYAvoJ3xjHT9KXY7dX64BwWRCgfiuDc2dzWCyLkn71SWT4R1oupwfQASWzC2Exeq0nAp742KrsyxAUrcs70Ozwh5w/9xJee3yNnlwKIpHQPe0G4ZMSe1pfW/q//IRvWyiWsg/XGFluI9YzoeWgNXGO3pN7l+QxXiUpw3KyyedGrKU8y3dlZTGJXwR0xrbeRbfbpZO2wHze5O3OaMgfJQP0FQMlrvTQ3uG3Agtk43X8A2OiZG12qC5fjdk9kG4/rO/SgvKwBrpXl0xOLdE8AnXBkLSauaOjKfk/Vi29JQS5ayatX6EKFcznbrDjZ94wDps1Ui89KtRmTeyvf7f6TabQUe57EAhEHRhNZXQmwWYZLUE1LrVpVzyMz/b2ty58z07v+Muk0ioQF77Xe8nHkVvJqcb+VSBjCDPnglBeowaMljinUEvSdITKeGknxph86WnID9JaYOmxxyk+Ou58pWgJDMnTmJzr7u48lKewKlyYnZ4VOKqlKx4g5nHvBlmIbS/cbJ3brSQqbFFTK5azEGOAVGaYOW/C/zPGqmimxL6VhmIybgoX5IyPsX8omuFnT4iTwvCRcy4J7Q3XrKPsHrDH9timIIx0GJEOvYnBcmHpu+hIBFanyoa+cIhPSNXMmnyLo+3A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(376002)(39860400002)(366004)(136003)(451199018)(36756003)(316002)(54906003)(478600001)(6486002)(52116002)(8936002)(5660300002)(4326008)(8676002)(66556008)(66946007)(66476007)(6916009)(2906002)(38350700002)(6506007)(86362001)(38100700002)(41300700001)(186003)(2616005)(26005)(6512007)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UjBQ9JO2XngcQJK2KdjWGJwwEsFTTtAPj7ck9TACTrCU0eQXVnP8T0UjRPlV+IfEI0dWqKa5jKRnWH6sieOimWmpxicStrgOzJNrIrXlCGTeIHr45H01ZCdAtkT56wKiADR9dWphtBTEvTVkUrQ7gJYDIaF+H+bQzGGb4e/vrlhK9ZoTveFU+2SIfGQ9C/ljYiJg2BA3yqLi98Tu14QUn1HbL9iSk29pcxds9wZZCF93WOPltONhrAiizgcwPr5bBDXoNk2djidLe0a/n7dV6rlyXP0J1UDw1Tm3JKS6LyK9qgPKzCvHjFjGbwcOsShq0m4BedahoO5f3v+XWbtzvXtoFPORXaTEYQTKul3x4dJ5qrcIHiyzJukoKcHAawJbEsrBGXQtiskJwGgYJC9MlbS84vx0GfwdMeUb593CTkuHgHKfm1WKkC3QyllMw9bI9aKNWktHHUP43w9dnRmifVQBD3mlo/AgCQqYsbocYTz48Xi3KU5IhDeFmDG3rd+ukmIlvxqO/cXTFv29Un2VJpHDSa3RC1lxGFxE+sIReAKvmmpySK20YvbN/V5w8dJCTCtYp5kUf59Bck6j8/dXYKG6X4mBs54ee0yc+gwtrt1zuPPbb61FG1684MgEGAZeeBgvakSzlo0nZD0m1vpUjruMOH1ZXF9zYPMo7DMSSTU02t3gh+h6Kg3/B86K6UXgEiTR975d5dYZvFXsDOzBkXfG5VoI+n9n0qnWkEtjt5xQv2xYaqQSYxrIYH0WoqV3wkJUQd/UfkL/cjHQqKUFU0FwHKLjdFYFECZE9aaymVKA4dxeWJiUd5soudDwv1UbbBdGqEfd+UnnGdbkWXf4ymerJs+funLpT4yniorkvNtGc5OiZScMB9srA9grwr91npEBECPNhRv94LYVWvOepj9aOUvzF6JMyTbbCMHWIJ/7fftubZpY9xsb9V2BqDArj9kh2NQm/eJy/UF5R3e9N6bT/mjnw52GTYWUp9HFffd5C156qMkA1iA4WjJCyYLCdewBb48VW7vuW6jcnUhDykADtgkoyRYs+VIS9UjCHJ8AOQknXxXDCzFkWEFOsASPHZcXG7XQ4GixRMGREK83i3DZuKg48sF7HpA3hDfDtvABNphl8JQIfhGVAdOTK8dGZBEuA1CbIKVlEI8rRkSBL53sdhm9fMCXjS4qXIyFjfaFp1G9c6/kh17mOi+TB2yuoCjU8R+1ypAtFzbABzowc+f5jqLfWQrgAcKuAVo8bKQzp+1LmVmF2pWlu6C9w7+lvgmrgyqHw6142AIq1WBsSsS2Z/+6cINjfLMuKopRYd8zNV8qcH05ajt4R86w/DEPXGuJQYWhlyJyZ40kH+/zOxw1sCCNWMSUpMKKbndwpzs3QQhrPMdKkEXjAOsuhVxIqBB7bXbytxcg6VtRGxRTcXBTt+z8scCLLh/1XP7DT9/TMUlYlSMa+uk6FUZqbFYZNFnuBfFB93FMyjAKBiZrBlPoJ3yaA19NjBrP55F8ujXyeg6z796uc/qjg5xoYC5lMDWjHGxmS/szyVd8DVCoobKeWh7A4G1JUFzBBZsgDUhiQkJ/9MXmQgCkL2TjKsNNH0/kbTC+n0bSJZH5Bte2DCN1vYTMi/CqP5efrRLj/eE= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54353523-c0ed-4b83-887f-08db212e860c X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 06:13:10.5799 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aEGjuQVIofoFbfMGi6nRzDhr0CupWXBk4io42Pjbe+HyZvSGPEjE+0Mx5894uRtLDWjMie6D2Z56lGBTfjjNNDFOti3o70TLaNoM4PDUZ0OsuBKRtCCZgP37Dr7qTaDK X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB10612 Message-ID-Hash: D25LFX6253EHVCUUDQJS3UEWLRFIQO3F X-Message-ID-Hash: D25LFX6253EHVCUUDQJS3UEWLRFIQO3F X-MailFrom: kuninori.morimoto.gx@renesas.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 CC: Linux-ALSA , Takashi Iwai , shaomin Deng 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: 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 --- 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 27e11b5f70b9..c7d7eff86727 100644 --- a/sound/pci/asihpi/hpi6205.c +++ b/sound/pci/asihpi/hpi6205.c @@ -430,7 +430,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; } From patchwork Fri Mar 10 06:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13168767 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 99686C64EC4 for ; Fri, 10 Mar 2023 06:15: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 5D338175C; Fri, 10 Mar 2023 07:14:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5D338175C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1678428939; bh=HMqy37WxfTqkKliIi9hhNeX5H3Vpi2aBAICvaxAgPmo=; h=To:In-Reply-To:References:From:Subject:Date:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=dV62iWOuUOZ7Shd6gt9PJ8YzwoW8oHoCJVjbw1o1sOMD88y+pwQGsbxvvNYyDphpt lzXz5vSv+zu5AgHyRDOPKwPCR/rf3sVQ33+2+O6uL4Sdula8dEZzWsPsom1ha+KsrO YqlGGeUrPPCGe/3d8C3kl5gYG0KbL1+RtzXQ98Qo= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 48A9AF804B1; Fri, 10 Mar 2023 07:14:47 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA4D6F804B1; Fri, 10 Mar 2023 07:14:42 +0100 (CET) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on20713.outbound.protection.outlook.com [IPv6:2a01:111:f403:7010::713]) (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 9D3D6F80482 for ; Fri, 10 Mar 2023 07:14:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9D3D6F80482 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=lee1t6lk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B9kIeXNam9X4hM+zbiZm5FGsRespC03jDgKFrbtXaI++K7NX0eaDZZLrI7FW8Wz10L0nasrTf92aScAGPL/YZDT93gso7GRxg1cU1uqH07d+b6VgNJX0SGbGVFhywfhloHA4E7VfoHK8YNNs8BeGNzaagLxj0OFwPiEgzIXSzamncMZtLPcIyTYX5wSEgaX/HCS2HkHu0WDWOSyTODqaz2ivIbby4FumTfXoxQqJDNSAmRqYmi+qOMF0lSAtMnFli0dbjorlpLCh+p0WiZijGQeahcAmsoYYmBzYvv8qycrZqbE9udDHharXhMYPnFl32ocpa6onqdeke+IZZuqWLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Nvoitf4TNjzW8os/z0eZWqyAcsvlpD+FZuTfpjJ3maY=; b=icu6SKgcCuUO3XcDZMasNsdm+1LYWUFtxV9yU3zXWEXAaEgUJlLV4bElONY2lrc5t+tigEpalDrgXBvSSq2huErcVLk+3YtLo+m9RKmZ8jLMeYuDM79iMeQWv1zSwC8LRpcxr5LM469DV4Ld2Gnp61K9lCnsWwZXtjx5cyFHpGXTL6sD2Bbonx8ddIPRZA+Wt3NpPAniMwtoYJy/SLjavUgZS8xrm4jz0HSjyWjmaFtuFUgFIeCRGuWnxCkKgcrgCBE8xSpGqk+DmSmtQ3TfPx84kkNz8XHItz8hGNC80SgzTJvOF1FIhii49LsTU3N/VolTVYstbjXNTSquUQFTPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nvoitf4TNjzW8os/z0eZWqyAcsvlpD+FZuTfpjJ3maY=; b=lee1t6lkc0y0qT5jupwFgarBI53mwS5/cF8p9PgP8QJ5iHJAI+IEtDNSQ7EaXLFPkBK5KagiuCOboR/4qU4mXYMEhlYwbvFMcKPcY0urJiSGdoDAMdrbpZJKVk08IfFJjVPuEna0NKNTgO37cWaOK8PoW66JDhm5zDS6tQ1Ey8A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TYWPR01MB10612.jpnprd01.prod.outlook.com (2603:1096:400:2a1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 06:14:32 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::e03e:1938:695b:f472]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::e03e:1938:695b:f472%7]) with mapi id 15.20.6178.019; Fri, 10 Mar 2023 06:14:32 +0000 Message-ID: <87cz5h2kvs.wl-kuninori.morimoto.gx@renesas.com> To: Mark Brown In-Reply-To: <87fsad2kzn.wl-kuninori.morimoto.gx@renesas.com> References: <87fsad2kzn.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [RESEND][PATCH 2/2] ASoC: patch_ca0132.c: fixup buffer overrun at tuning_ctl_set() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 Date: Fri, 10 Mar 2023 06:14:32 +0000 X-ClientProxiedBy: TYCPR01CA0140.jpnprd01.prod.outlook.com (2603:1096:400:2b7::10) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TYWPR01MB10612:EE_ X-MS-Office365-Filtering-Correlation-Id: ed51da54-6bfc-48b8-f1eb-08db212eb6d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z086ch8qQ/LpV33HipIQlMcX2gysjl2Sws493bvw4IhMgs49H6pDlidDqYoDKEt/JC3TWs42jQJQbPShd0upKBn6BtT1+axxlIj2w4DkwBxdmQOHSqGMzo7DvQ86x7EE9iJ+AcdIX+8pyTdS7gcMU8eXcJpmQRMOtqSpJ7x6awKqrUrGFB8NCY/bn1xSXgRIcNOzHBbfLSsJvS8h477wcEQ9LLgmmRhv1VhoO5Ejxw3/OEKQnLCihGrxmGJP/j0KXv80EQWV7mn+ypqBhr7jLXuV91AycZD+qm902VMWoU7Lg3bdxaa+xaOx38EU6dMLJEQlPAE/Uixk8cJo/1HrhOQMJ6tB69nihwQmYAfBRBB3AQ1i2T/o/2JJtKOM6OvtT9CTucj5vy1/h+cJtyFAdxebxR2nY6eFPxlmzZrtdAi0MJnc1sT47iuXF8POmJVOkq47RA3GifuTJ+ncoz5wdpeGTk0SHlML+36WOGbOYFWX5HLrBQotVAVkpxibEGChvDNJYlVQ7nTE46TEcqLTB8YaCSoogeMH3F7BWwEC1SS5qy2lCoqce30ItaGsoqasK5ssKUqoqaUwrZwR5d1C6ZXb8evVh7ZkyMZpeqH/gqIxyDZdhr4oFdt5UuFUPb4pVNHiZZ0kmBNN7sMbJS9wEceAs97K7LXMbAOQmG2G/3PXrdV3TLe3NvSwF0H85qhgDrAYIp/UmUneb9ngJgg0/A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(376002)(39860400002)(366004)(136003)(451199018)(36756003)(316002)(54906003)(478600001)(6486002)(52116002)(8936002)(5660300002)(4326008)(8676002)(66556008)(66946007)(66476007)(6916009)(2906002)(38350700002)(6506007)(86362001)(38100700002)(41300700001)(186003)(2616005)(26005)(6512007)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WFGgXs3yVRs3vEdwkruUI2edWosKj8DTBQcYB/2q3jH0dyb1iUhODYeIVadKJr4Pt9a3LirmlLPQ9vvD5l4cDgHrHjQAQc5o3PzxTGEnOqI+4BBf/PeXskl7s56cQ7x22H/wadBtxMilnP4lKb/iOmZNqgM4Y/6Yewgm/U9W8WV5BLksMr6kTj4/+TdnznzcBLL3kpfV+Z9Ct7LwDliSCatR5j8C0zPq9Lf/EZWCjkipp3Nte2Mb2/n6sSu6QPK4llo1yCdIjGInUly3mddGHFL89K0KMtiCGqPa6UTVbkX98DBkiuIaukzGJh9Rk2lySk3Mhls3WeZ8XiZwqjRJjUIENrtEI9DBCJK8Zifaj0Vyvsw/pqelGF8ls2aQ0d2O7rIuea9eP3i/iX/nP5a2nio38Dg/oOk+r4/SH5H8SPBK3Iba0duhVh3h5yrzAtMMjSr7ZmUWijtJYzv265tl5fBKZ6HiNVRSNYEtFeLQTkHd5Bq0MNNwyVbFfI2UWP1EzZAHD84/z9x09CHysYUH12cCzAiVCwIJHIYZ4EyVZRAUPHm3ok0VayYvQ+C53YB9K/vqUf7+ey1PiMotWNFKT63ytJLrQPzIqe7/sRnknbY+QQ1fl5MjdJBy16p/eE2mhFYLGE8DkO4ZuLZ0g5C7nKm19bWQNJfEfDn4/pocSCIjLjCHrtgtZq0JLfnPkcy4qqFohcC4IsOM2AJXykd6WUlBP2wjeHHFeZtB1tb8kqdpzG278zn0pE4IGJ/TbJCEw5gtR68kDgfuXwtnvazTdwMzusflfRzNAu2EPIpJwhf0IUIjw/8OhR1m/idJU/lGinCPJZdzv8fYuybKu0OikZxSINYCmtmjqEke0klwQtslZ/P8I6qeu4iGXmNt9npl/GBXsTsAydq2Qtez6IIscjT/JaR25jdg3caaki6MdkumPz0tfhs18NChl/EBVfDAZDq+d/DwYgrMZCdDL1c4oJEZwFZw5ph4vrLR7opstnDRsWMkqrynsr/B/TvLQ2f6fZpTOiC+w5qoEnw3TxrWNe0luKNKlHU4DHeCjI+zv8T8bFDVoOEbseRkcxUU5fN4RqnbwJsc+l2sf1m/VtJ7CjG53dxolNxgzQ8WHeLTDIGWL3FL2ldkNBn1m1Ct+82qJXLA3Ufhr8MXj6EX67aZOkdFKNRgUnUA6ae4l+5cEvCqyBMqqVVuDxBCrHo0sE21z/E/HDjbFRfQBPZ2pwtp5Gg/qeoZlQ7zL9PoTfdex6ZCq/93DV6FNF7ZvCpgLM/C60lwh73mrhELvTHr34XntuoKa43ALYCou9++bImDqiCpVylp4VYyWJebQlf3lQEVmVpna38GT69y6oDLKCqqP0rWFHDi4rmZe5LT7l/NPjKRRoIhtkssZJ8aHY50nKg1FlGirNnRXrVk1p3MAOH9TkNYWliJB3gjBsxkjyVoOgVy0hbCK9Z8aqcJlf+aLlyNLsIqRpTyqCKfk+rXowsegQg7lqkabKcrXDyRzYTyo78bCVVMJTUxKjHamOftc3RNegqWhM7J+WqlramT1vwxXcPcGUatmg5bzUsBeMl1ueYWWxAW2eygYLc5ROS2O+ijAAboEWOZSVg+xEURCgamWbeCIGZNzUCcQ+V3MGK/xhw= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed51da54-6bfc-48b8-f1eb-08db212eb6d6 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 06:14:32.6402 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dpDjQwdYAd1ipMGUgLO7FTXRAiNsN+gjs9oSNRjqBdYIIHSha5sMFqHFHkGLeJXfLH44ZkZ2ejUQ15YqVAI84HdYoLxYITe9URFR/KMFOQyOddGlUOvBAX4M9MC9Byja X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB10612 Message-ID-Hash: Y46256AS6YDNIH2X7XRZIVJS6VH3EAQR X-Message-ID-Hash: Y46256AS6YDNIH2X7XRZIVJS6VH3EAQR X-MailFrom: kuninori.morimoto.gx@renesas.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 CC: Linux-ALSA , Takashi Iwai , Xian Wang , ye xingchen 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: tuning_ctl_set() might have buffer overrun at (X) if it didn't break from loop by matching (A). static int tuning_ctl_set(...) { for (i = 0; i < TUNING_CTLS_COUNT; i++) (A) if (nid == ca0132_tuning_ctls[i].nid) break; snd_hda_power_up(...); (X) dspio_set_param(..., ca0132_tuning_ctls[i].mid, ...); snd_hda_power_down(...); ^ return 1; } We will get below error by cppcheck sound/pci/hda/patch_ca0132.c:4229:2: note: After for loop, i has value 12 for (i = 0; i < TUNING_CTLS_COUNT; i++) ^ sound/pci/hda/patch_ca0132.c:4234:43: note: Array index out of bounds dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20, ^ This patch cares non match case. Signed-off-by: Kuninori Morimoto --- sound/pci/hda/patch_ca0132.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 0a292bf271f2..5ce4b5f62983 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -4228,8 +4228,10 @@ static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid, for (i = 0; i < TUNING_CTLS_COUNT; i++) if (nid == ca0132_tuning_ctls[i].nid) - break; + goto found; + return -EINVAL; +found: snd_hda_power_up(codec); dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20, ca0132_tuning_ctls[i].req,