ALSA: hdac: Fix size allocation for ext device allocation
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
--- sound/hda/ext/hdac_ext_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/ext/hdac_ext_bus.c +1 -1
@@ -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;
Signature · 1 line
1.9.1
PATCH v2 2/3 ALSA: hdac: fix the spbmaxfifo API
spbmaxfifo API is actually a query function not a set function so name it snd_hdac_ext_stream_get_spbmaxfifo()
--- include/sound/hdaudio_ext.h | 2 +- sound/hda/ext/hdac_ext_stream.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
include/sound/hdaudio_ext.h +1 -1
@@ -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);
sound/hda/ext/hdac_ext_stream.c +3 -3
@@ -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);/**
Signature · 1 line
1.9.1
PATCH v2 3/3 ALSA: hdac: Add snd_hdac_get_hdac_stream()
In reply to Vinod KoulFrom: Jeeja KP <[email protected]>
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
--- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_stream.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+)
include/sound/hdaudio.h +2 -0
@@ -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);
sound/hda/hdac_stream.c +22 -0
@@ -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 */
Signature · 1 line
1.9.1
Quoted 8 lines · Vinod Koul
While creating
hdac_ext_device, we used hdev for sizeof insteadof edev, which resulted in eventual crash of the system Fix the size hereFixes a512f5611646 ('ALSA: hdac: add hdac extended device')Reported-by Subhransu S. Prusty <[email protected]>Signed-off-by Vinod Koul <[email protected]>
Applied all three patches.
thanks,
Takashi
Quoted 20 lines
--- sound/hda/ext/hdac_ext_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sound/hda/ext/hdac_ext_bus.c +1
-1@@ -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;Signature · 1 line
1.9.1