alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda: prevent undefined shift in snd_hdac_ext_bus_get_link()
@ 2020-11-03 10:18 Dan Carpenter
  2020-11-03 13:12 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-11-03 10:18 UTC (permalink / raw)
  To: Jaroslav Kysela, Jeeja KP
  Cc: alsa-devel, Kai Vehmanen, kernel-janitors, Keyon Jie,
	Takashi Iwai, Pierre-Louis Bossart, Vinod Koul, Mark Brown

This is harmless, but the "addr" comes from the user and it could lead
to a negative shift or to shift wrapping if it's too high.

Fixes: 0b00a5615dc4 ("ALSA: hdac_ext: add hdac extended controller")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/hda/ext/hdac_ext_controller.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/hda/ext/hdac_ext_controller.c b/sound/hda/ext/hdac_ext_controller.c
index 4d060d5b1db6..b0c0ef824d7d 100644
--- a/sound/hda/ext/hdac_ext_controller.c
+++ b/sound/hda/ext/hdac_ext_controller.c
@@ -148,6 +148,8 @@ struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
 		return NULL;
 	if (bus->idx != bus_idx)
 		return NULL;
+	if (addr < 0 || addr > 31)
+		return NULL;
 
 	list_for_each_entry(hlink, &bus->hlink_list, list) {
 		for (i = 0; i < HDA_MAX_CODECS; i++) {
-- 
2.28.0


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

* Re: [PATCH] ALSA: hda: prevent undefined shift in snd_hdac_ext_bus_get_link()
  2020-11-03 10:18 [PATCH] ALSA: hda: prevent undefined shift in snd_hdac_ext_bus_get_link() Dan Carpenter
@ 2020-11-03 13:12 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2020-11-03 13:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: alsa-devel, Kai Vehmanen, kernel-janitors, Keyon Jie,
	Pierre-Louis Bossart, Takashi Iwai, Vinod Koul, Mark Brown,
	Jeeja KP

On Tue, 03 Nov 2020 11:18:07 +0100,
Dan Carpenter wrote:
> 
> This is harmless, but the "addr" comes from the user and it could lead
> to a negative shift or to shift wrapping if it's too high.
> 
> Fixes: 0b00a5615dc4 ("ALSA: hdac_ext: add hdac extended controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied.


Takashi

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

end of thread, other threads:[~2020-11-03 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 10:18 [PATCH] ALSA: hda: prevent undefined shift in snd_hdac_ext_bus_get_link() Dan Carpenter
2020-11-03 13:12 ` 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).