From patchwork Mon Jun 5 14:47:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 689784 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 9F38DC77B73 for ; Mon, 5 Jun 2023 14:49:53 +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 05EC182B; Mon, 5 Jun 2023 16:49:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 05EC182B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685976591; bh=pLgnot7GrxGQfhgSHONBTPkF9lZwnqUnXogvVruYOXw=; h=From:To:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=By9MPxyH0EBS/9apPVQLWkR1V9AvyXirS2BSl1w2F7EE3LmLkkIwJQ2JbVFaHB8KK a2Qy52HuwlIamiTZ+v4RVH7f2ZAkH6qJENAQDru21sGqhDLK/voWbOEkafapx0njA6 sIBN365S+jluk5IQPDKjS3lC/Yh6iPKPbA0rgm88= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 717A1F8055B; Mon, 5 Jun 2023 16:48:12 +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 BC8E3F80544; Mon, 5 Jun 2023 16:48:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 22870F80199; Mon, 5 Jun 2023 16:48:07 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (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 1FFDFF80155 for ; Mon, 5 Jun 2023 16:48:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1FFDFF80155 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=2ShDTX0h; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=xR0PCrYH 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-out1.suse.de (Postfix) with ESMTPS id D21FD21B5B; Mon, 5 Jun 2023 14:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1685976481; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=feAukb2LCzN3dc5mffNcaeofTYKQrjuHkiI++GeYCI4=; b=2ShDTX0hnK/q5x7nggUQFZbX8zokguWPkXerl8ZeslsdkrNrTv8kUWEyJc1aKd+HRSh5u4 SGP5Boo5+gPajBEX0ORNUEUdahv4qgtykUpPfT/uUINbpaoIwNyaWiFI2pRbhYMx0ImUgD hWaihgeQSdbyq5bJ2rdhOtrrG3WZNR0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1685976481; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=feAukb2LCzN3dc5mffNcaeofTYKQrjuHkiI++GeYCI4=; b=xR0PCrYH2ATwZJh+CTXT7HLTNxupH8gEAsyFxhD06PPKWVbwsNBJgLRITs2UXecmhBwk7d TLbUHz36ZlFZdzCQ== 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 B87C0139C8; Mon, 5 Jun 2023 14:48:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pnD0K6H1fWQMXwAAMHmgww (envelope-from ); Mon, 05 Jun 2023 14:48:01 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 1/2] ALSA: usb-audio: Use __le16 for 16bit USB descriptor fields Date: Mon, 5 Jun 2023 16:47:57 +0200 Message-Id: <20230605144758.6677-1-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Message-ID-Hash: WSRUHOIEPEUCHPJRXVLTR2FQ7H7BPI6P X-Message-ID-Hash: WSRUHOIEPEUCHPJRXVLTR2FQ7H7BPI6P 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 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: Use proper notion for 16bit values for fixing the sparse warnings. Fixes: f8ddb0fb3289 ("ALSA: usb-audio: Define USB MIDI 2.0 specs") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202305260528.wcqjXso8-lkp@intel.com/ Closes: https://lore.kernel.org/oe-kbuild-all/202305270534.odwHL9F0-lkp@intel.com/ Signed-off-by: Takashi Iwai --- include/linux/usb/midi-v2.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/usb/midi-v2.h b/include/linux/usb/midi-v2.h index ebbffcae0417..16f09d959a2d 100644 --- a/include/linux/usb/midi-v2.h +++ b/include/linux/usb/midi-v2.h @@ -73,7 +73,7 @@ struct usb_ms20_gr_trm_block_header_descriptor { __u8 bLength; /* 5 */ __u8 bDescriptorType; /* USB_DT_CS_GR_TRM_BLOCK */ __u8 bDescriptorSubtype; /* USB_MS_GR_TRM_BLOCK_HEADER */ - __u16 wTotalLength; /* Total number of bytes */ + __le16 wTotalLength; /* Total number of bytes */ } __packed; /* 5.4.2.1 Group Terminal Block Descriptor */ @@ -87,8 +87,8 @@ struct usb_ms20_gr_trm_block_descriptor { __u8 nNumGroupTrm; /* Number of member Group Terminals spanned */ __u8 iBlockItem; /* String ID of Block item */ __u8 bMIDIProtocol; /* Default MIDI protocol */ - __u16 wMaxInputBandwidth; /* Max input bandwidth capability in 4kB/s */ - __u16 wMaxOutputBandwidth; /* Max output bandwidth capability in 4kB/s */ + __le16 wMaxInputBandwidth; /* Max input bandwidth capability in 4kB/s */ + __le16 wMaxOutputBandwidth; /* Max output bandwidth capability in 4kB/s */ } __packed; #endif /* __LINUX_USB_MIDI_V2_H */ From patchwork Mon Jun 5 14:47:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 689289 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 DE0C4C77B73 for ; Mon, 5 Jun 2023 14:49:25 +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 9C9853E7; Mon, 5 Jun 2023 16:48:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9C9853E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685976562; bh=ucOenpIhyQHtU9opD7HRjyaONgF+MW9jjdFBjCHmeN8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=ZE+NwXg+iMM+2/YtnroSE32PGx4r8TL6bes+A2CJirMuBzJ9ibBqAOy+gI3RHWTyv xHeI/zod4XwTlMMK8Rgu2MNKBCRe59qRTFYcPmxkjXtYi+YqaxNNly5PzNPikl89ai 6d8x7czQC5qr9vMf0R9UsOVb3jgRkUTtPhsIPI/U= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73EF8F80290; Mon, 5 Jun 2023 16:48:10 +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 E86E9F804DA; Mon, 5 Jun 2023 16:48:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CD222F80254; Mon, 5 Jun 2023 16:48:05 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (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 62D13F800ED for ; Mon, 5 Jun 2023 16:48:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 62D13F800ED 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=G+PDZBYW; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=U+kg53V/ 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-out1.suse.de (Postfix) with ESMTPS id E7CDB21B67; Mon, 5 Jun 2023 14:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1685976481; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cSgax4rMLB5Ej1iWw2VeveKyp/v9Eyqcam0xxdkZvQM=; b=G+PDZBYWeRdlvSpQjHBJT4CR08Q/+ZocPYt6ua7F9HCRF2I2SIoTRd/xr+CYjbRyMxCQFj dcH1hTp36W1R7qBKQUNzKokaYitLvzN/PPwSJXM5XW/IKdrm8G+GF1iVzt0/kaIPTYorsD 8zXqPq7/Ayw6hS78WJmzYCyhvLZNiD8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1685976481; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cSgax4rMLB5Ej1iWw2VeveKyp/v9Eyqcam0xxdkZvQM=; b=U+kg53V/Y8mj2MPY+dMEbzVwkNO0GwcOXYrqGpvdFdGpceou1HwzRENdp+nXib2c1QJGit LRnEMC59KjHbFIDA== 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 D4B2113A3C; Mon, 5 Jun 2023 14:48:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AOsJM6H1fWQMXwAAMHmgww (envelope-from ); Mon, 05 Jun 2023 14:48:01 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 2/2] ALSA: seq: Avoid confusion of aligned read size Date: Mon, 5 Jun 2023 16:47:58 +0200 Message-Id: <20230605144758.6677-2-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230605144758.6677-1-tiwai@suse.de> References: <20230605144758.6677-1-tiwai@suse.de> MIME-Version: 1.0 Message-ID-Hash: GEDWO6A55H23IHMSZZ7GFOKHYWUPXVRZ X-Message-ID-Hash: GEDWO6A55H23IHMSZZ7GFOKHYWUPXVRZ 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 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: Currently the read event packet size in snd_seq_read() is defined by client->midi_version value that is guaranteed to be zero if UMP isn't enabled. But the static analyzer doesn't know of the fact, and it still suspects as if it were leading to a potential overflow. Add the more explicit check of CONFIG_SND_SEQ_UMP to determine the aligned_size value for avoiding the confusion. Fixes: 46397622a3fa ("ALSA: seq: Add UMP support") Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202305261415.NY0vapZK-lkp@intel.com/ Signed-off-by: Takashi Iwai --- sound/core/seq/seq_clientmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 948ae45e0cc3..e3f9ea67d019 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -451,7 +451,7 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, err = 0; snd_seq_fifo_lock(fifo); - if (client->midi_version > 0) + if (IS_ENABLED(CONFIG_SND_SEQ_UMP) && client->midi_version > 0) aligned_size = sizeof(struct snd_seq_ump_event); else aligned_size = sizeof(struct snd_seq_event);