linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] ALSA: rawmidi: fix incorrect array bounds check on clock_names
@ 2021-05-19 10:54 Colin King
  2021-05-19 14:20 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-05-19 10:54 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, David Henningsson, alsa-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The array bounds check on clock_names is currently checking the size
of the entire array rather than the number of elements in the array
leading to a potential array bounds read error. Fix this by using
the ARRAY_SIZE macro instead of sizeof.

Addresses-Coverity: ("Out-of-bounds read")
Fixes: 08fdced60ca0 ("ALSA: rawmidi: Add framing mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 sound/core/rawmidi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 4a6534db77d6..6c0a4a67ad2e 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -1679,7 +1679,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
 					    buffer_size, avail, xruns);
 				if (substream->framing == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP) {
 					clock_type = substream->clock_type >> SNDRV_RAWMIDI_MODE_CLOCK_SHIFT;
-					if (!snd_BUG_ON(clock_type >= sizeof(clock_names)))
+					if (!snd_BUG_ON(clock_type >= ARRAY_SIZE(clock_names)))
 						snd_iprintf(buffer,
 							    "  Framing      : tstamp\n"
 							    "  Clock type   : %s\n",
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] ALSA: rawmidi: fix incorrect array bounds check on clock_names
  2021-05-19 10:54 [PATCH][next] ALSA: rawmidi: fix incorrect array bounds check on clock_names Colin King
@ 2021-05-19 14:20 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2021-05-19 14:20 UTC (permalink / raw)
  To: Colin King
  Cc: Jaroslav Kysela, Takashi Iwai, David Henningsson, alsa-devel,
	kernel-janitors, linux-kernel

On Wed, 19 May 2021 12:54:24 +0200,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> The array bounds check on clock_names is currently checking the size
> of the entire array rather than the number of elements in the array
> leading to a potential array bounds read error. Fix this by using
> the ARRAY_SIZE macro instead of sizeof.
> 
> Addresses-Coverity: ("Out-of-bounds read")
> Fixes: 08fdced60ca0 ("ALSA: rawmidi: Add framing mode")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks, applied.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-19 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 10:54 [PATCH][next] ALSA: rawmidi: fix incorrect array bounds check on clock_names Colin King
2021-05-19 14:20 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).