[alsa-devel] [PATCH v2 1/3] ALSA: hdac: Fix size allocation for ext device allocation
While creating hdac_ext_device, we used hdev for sizeof insteadof edev, which resulted in eventual crash of the system Fix the size here
Fixes: a512f5611646 ('ALSA: hdac: add hdac extended device') Reported-by: Subhransu S. Prusty subhransu.s.prusty@intel.com Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/hda/ext/hdac_ext_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c index 8544e4fb1cd3..4449d1a99089 100644 --- a/sound/hda/ext/hdac_ext_bus.c +++ b/sound/hda/ext/hdac_ext_bus.c @@ -139,7 +139,7 @@ int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr) char name[15]; int ret;
- edev = kzalloc(sizeof(*hdev), GFP_KERNEL); + edev = kzalloc(sizeof(*edev), GFP_KERNEL); if (!edev) return -ENOMEM; hdev = &edev->hdac;
spbmaxfifo API is actually a query function not a set function so name it snd_hdac_ext_stream_get_spbmaxfifo()
Reported-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul vinod.koul@intel.com --- include/sound/hdaudio_ext.h | 2 +- sound/hda/ext/hdac_ext_stream.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h index 9385c99a6504..94210dcdb6ea 100644 --- a/include/sound/hdaudio_ext.h +++ b/include/sound/hdaudio_ext.h @@ -107,7 +107,7 @@ void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus);
int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus, struct hdac_ext_stream *stream, u32 value); -int snd_hdac_ext_stream_set_spbmaxfifo(struct hdac_ext_bus *ebus, +int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus, struct hdac_ext_stream *stream);
void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream); diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c index c978a9bb1db8..33ba77dd32f2 100644 --- a/sound/hda/ext/hdac_ext_stream.c +++ b/sound/hda/ext/hdac_ext_stream.c @@ -461,13 +461,13 @@ int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus, EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_spib);
/** - * snd_hdac_ext_stream_set_spbmaxfifo - sets the spib value of a stream + * snd_hdac_ext_stream_get_spbmaxfifo - gets the spib value of a stream * @ebus: HD-audio ext core bus * @stream: hdac_ext_stream * * Return maxfifo for the stream */ -int snd_hdac_ext_stream_set_spbmaxfifo(struct hdac_ext_bus *ebus, +int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus, struct hdac_ext_stream *stream) { struct hdac_bus *bus = &ebus->bus; @@ -479,7 +479,7 @@ int snd_hdac_ext_stream_set_spbmaxfifo(struct hdac_ext_bus *ebus,
return readl(stream->fifo_addr); } -EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_spbmaxfifo); +EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_get_spbmaxfifo);
/**
From: Jeeja KP jeeja.kp@intel.com
Add a helper to find the stream using stream tag and direction. This is useful for drivers to query stream based on stream tag and direction, fox example while downloading FW thru DSP loader code
Signed-off-by: Jeeja KP jeeja.kp@intel.com Signed-off-by: Vinod Koul vinod.koul@intel.com --- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_stream.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+)
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 23a44c39c51c..49bc836fcd84 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -438,6 +438,8 @@ void snd_hdac_stream_init(struct hdac_bus *bus, struct hdac_stream *azx_dev, struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream); void snd_hdac_stream_release(struct hdac_stream *azx_dev); +struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus, + int dir, int stream_tag);
int snd_hdac_stream_setup(struct hdac_stream *azx_dev); void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev); diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c index 4c15d0accc9e..8981159813ef 100644 --- a/sound/hda/hdac_stream.c +++ b/sound/hda/hdac_stream.c @@ -286,6 +286,28 @@ void snd_hdac_stream_release(struct hdac_stream *azx_dev) } EXPORT_SYMBOL_GPL(snd_hdac_stream_release);
+/** + * snd_hdac_get_stream - return hdac_stream based on stream_tag and + * direction + * + * @bus: HD-audio core bus + * @dir: direction for the stream to be found + * @stream_tag: stream tag for stream to be found + */ +struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus, + int dir, int stream_tag) +{ + struct hdac_stream *s; + + list_for_each_entry(s, &bus->stream_list, list) { + if (s->direction == dir && s->stream_tag == stream_tag) + return s; + } + + return NULL; +} +EXPORT_SYMBOL_GPL(snd_hdac_get_stream); + /* * set up a BDL entry */
On Sun, 23 Aug 2015 08:22:49 +0200, Vinod Koul wrote:
While creating hdac_ext_device, we used hdev for sizeof insteadof edev, which resulted in eventual crash of the system Fix the size here
Fixes: a512f5611646 ('ALSA: hdac: add hdac extended device') Reported-by: Subhransu S. Prusty subhransu.s.prusty@intel.com Signed-off-by: Vinod Koul vinod.koul@intel.com
Applied all three patches.
thanks,
Takashi
sound/hda/ext/hdac_ext_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c index 8544e4fb1cd3..4449d1a99089 100644 --- a/sound/hda/ext/hdac_ext_bus.c +++ b/sound/hda/ext/hdac_ext_bus.c @@ -139,7 +139,7 @@ int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr) char name[15]; int ret;
- edev = kzalloc(sizeof(*hdev), GFP_KERNEL);
- edev = kzalloc(sizeof(*edev), GFP_KERNEL); if (!edev) return -ENOMEM; hdev = &edev->hdac;
-- 1.9.1
participants (2)
-
Takashi Iwai
-
Vinod Koul