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 C9E64C6FD1F for ; Tue, 14 Mar 2023 16:06:26 +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 9BE5C9F6; Tue, 14 Mar 2023 17:05:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9BE5C9F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1678809984; bh=ctvavJRoWtzOtGYRVTVB1y0T2i9104+KXdatCcO90tU=; h=Date:From:To:Subject:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=D8D2FCLguVlH5zUnHCsEMVuV2Hqj0OBxUq7OAOXDU6D6sJfGgZgmVQb3oof88qRDh Lik0zoxU+7Mgg2iSpolZfLNO8tHzslUbI6FnIudv2Nd+LsQ8aCNFTpmyaCWfsR6sue GXLV2gcpXBh7JvwODinIpSHRNYcblNO7jLLgM2fQ= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 8C3B5F80423; Tue, 14 Mar 2023 17:05:13 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 22308F80423; Tue, 14 Mar 2023 17:05:09 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 56D5AF80272 for ; Tue, 14 Mar 2023 17:05:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 56D5AF80272 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Lcn6SvER; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=jzNSkTCe Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C62681F8B5; Tue, 14 Mar 2023 16:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678809906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IBJGHM7hDpD+AtF6DMGO2CoPdkke6PSckMUSkntEeY4=; b=Lcn6SvER/FCxB6HON5ZXojBSgjsjr5fM/68o7LLievZSMVWZFBG/194WtFsp5yWGH813OS Y4CNoniz2lcCgnPusH4TERGmIyawKEVruIP4O/8m0M9794f/dAfQcoOMq9O4ZQS3mYskqS WTF8rIt53fmBLWf5UiQJJbPKyuval4I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678809906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IBJGHM7hDpD+AtF6DMGO2CoPdkke6PSckMUSkntEeY4=; b=jzNSkTCe73htXa211zYfw1LiM4zjNWqwqSGPj4CMq+Qf2L00fs+oHqyvUe2Y28Y4BGzfTf szZU61ri3Q4krRDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9E2ED13A1B; Tue, 14 Mar 2023 16:05:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IEuLJTKbEGTeVwAAMHmgww (envelope-from ); Tue, 14 Mar 2023 16:05:06 +0000 Date: Tue, 14 Mar 2023 17:05:06 +0100 Message-ID: <87fsa7b9ot.wl-tiwai@suse.de> From: Takashi Iwai To: Kuninori Morimoto Subject: Re: [PATCH] ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set() In-Reply-To: <87sfe9eap7.wl-kuninori.morimoto.gx@renesas.com> References: <87sfe9eap7.wl-kuninori.morimoto.gx@renesas.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Message-ID-Hash: ASWBW4BURL7ZQQXWEMERF43BCLBZAVHI X-Message-ID-Hash: ASWBW4BURL7ZQQXWEMERF43BCLBZAVHI X-MailFrom: tiwai@suse.de 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 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: On Mon, 13 Mar 2023 01:50:28 +0100, Kuninori Morimoto wrote: > > 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 Thanks, applied now. Takashi