diff mbox series

HID: sony: Fix a potential memory leak in sony_probe()

Message ID db06095c912d6bc56bed6b7e4663c7994072a2ce.1693757011.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New
Delegated to: Jiri Kosina
Headers show
Series HID: sony: Fix a potential memory leak in sony_probe() | expand

Commit Message

Christophe JAILLET Sept. 3, 2023, 4:04 p.m. UTC
If an error occurs after a successful usb_alloc_urb() call, usb_free_urb()
should be called.

Fixes: fb1a79a6b6e1 ("HID: sony: fix freeze when inserting ghlive ps3/wii dongles")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
The NULL check is not needed, but I think that it is more informative
written this way.
---
 drivers/hid/hid-sony.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jiri Kosina Sept. 4, 2023, 9:14 a.m. UTC | #1
On Sun, 3 Sep 2023, Christophe JAILLET wrote:

> If an error occurs after a successful usb_alloc_urb() call, usb_free_urb()
> should be called.
> 
> Fixes: fb1a79a6b6e1 ("HID: sony: fix freeze when inserting ghlive ps3/wii dongles")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> The NULL check is not needed, but I think that it is more informative
> written this way.
> ---
>  drivers/hid/hid-sony.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index dd942061fd77..a02046a78b2d 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -2155,6 +2155,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  	return ret;
>  
>  err:
> +	if (sc->ghl_urb)
> +		usb_free_urb(sc->ghl_urb);
> +

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index dd942061fd77..a02046a78b2d 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -2155,6 +2155,9 @@  static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	return ret;
 
 err:
+	if (sc->ghl_urb)
+		usb_free_urb(sc->ghl_urb);
+
 	hid_hw_stop(hdev);
 	return ret;
 }