* [PATCH] ALSA: usb-audio: endpoint : remove redundant check before usb_free_coherent()
@ 2021-02-04 2:05 Xu Wang
2021-02-04 6:40 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Xu Wang @ 2021-02-04 2:05 UTC (permalink / raw)
To: perex, tiwai, alexander, e.burema, alsa-devel; +Cc: linux-kernel
usb_free_coherent() is safe with NULL addr and this check is
not required.
Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
---
sound/usb/endpoint.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 8e568823c992..d5ed4ddfd451 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -82,10 +82,9 @@ static inline unsigned get_usb_high_speed_rate(unsigned int rate)
*/
static void release_urb_ctx(struct snd_urb_ctx *u)
{
- if (u->buffer_size)
- usb_free_coherent(u->ep->chip->dev, u->buffer_size,
- u->urb->transfer_buffer,
- u->urb->transfer_dma);
+ usb_free_coherent(u->ep->chip->dev, u->buffer_size,
+ u->urb->transfer_buffer,
+ u->urb->transfer_dma);
usb_free_urb(u->urb);
u->urb = NULL;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: usb-audio: endpoint : remove redundant check before usb_free_coherent()
2021-02-04 2:05 [PATCH] ALSA: usb-audio: endpoint : remove redundant check before usb_free_coherent() Xu Wang
@ 2021-02-04 6:40 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2021-02-04 6:40 UTC (permalink / raw)
To: Xu Wang; +Cc: perex, tiwai, alexander, e.burema, alsa-devel, linux-kernel
On Thu, 04 Feb 2021 03:05:18 +0100,
Xu Wang wrote:
>
> usb_free_coherent() is safe with NULL addr and this check is
> not required.
The check there isn't about NULL buffer or not; instead it checks
whether the buffer was allocated for each or it shares the single
buffer (for sync endpoints). In the latter case, your patch will lead
to double-free.
thanks,
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: usb-audio: endpoint : remove redundant check before usb_free_coherent()
@ 2021-02-04 6:40 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2021-02-04 6:40 UTC (permalink / raw)
To: Xu Wang; +Cc: e.burema, alsa-devel, linux-kernel, tiwai, alexander
On Thu, 04 Feb 2021 03:05:18 +0100,
Xu Wang wrote:
>
> usb_free_coherent() is safe with NULL addr and this check is
> not required.
The check there isn't about NULL buffer or not; instead it checks
whether the buffer was allocated for each or it shares the single
buffer (for sync endpoints). In the latter case, your patch will lead
to double-free.
thanks,
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-04 6:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 2:05 [PATCH] ALSA: usb-audio: endpoint : remove redundant check before usb_free_coherent() Xu Wang
2021-02-04 6:40 ` Takashi Iwai
2021-02-04 6:40 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.