2022-11-19 05:22:01

by Ziyang Xuan (William)

[permalink] [raw]
Subject: [PATCH net] wifi: plfxlc: fix potential memory leak in __lf_x_usb_enable_rx()

urbs does not be freed in exception paths in __lf_x_usb_enable_rx().
That will trigger memory leak. To fix it, add kfree() for urbs within
"error" label. Compile tested only.

Fixes: 68d57a07bfe5 ("wireless: add plfxlc driver for pureLiFi X, XL, XC devices")
Signed-off-by: Ziyang Xuan <[email protected]>
---
drivers/net/wireless/purelifi/plfxlc/usb.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/purelifi/plfxlc/usb.c b/drivers/net/wireless/purelifi/plfxlc/usb.c
index 39e54b3787d6..76d0a778636a 100644
--- a/drivers/net/wireless/purelifi/plfxlc/usb.c
+++ b/drivers/net/wireless/purelifi/plfxlc/usb.c
@@ -247,6 +247,7 @@ static int __lf_x_usb_enable_rx(struct plfxlc_usb *usb)
for (i = 0; i < RX_URBS_COUNT; i++)
free_rx_urb(urbs[i]);
}
+ kfree(urbs);
return r;
}

--
2.25.1



2022-11-19 06:49:23

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH net] wifi: plfxlc: fix potential memory leak in __lf_x_usb_enable_rx()

Ziyang Xuan <[email protected]> writes:

> urbs does not be freed in exception paths in __lf_x_usb_enable_rx().
> That will trigger memory leak. To fix it, add kfree() for urbs within
> "error" label. Compile tested only.
>
> Fixes: 68d57a07bfe5 ("wireless: add plfxlc driver for pureLiFi X, XL, XC devices")
> Signed-off-by: Ziyang Xuan <[email protected]>
> ---
> drivers/net/wireless/purelifi/plfxlc/usb.c | 1 +
> 1 file changed, 1 insertion(+)

plfxlc patches go to wireless tree, not net. But I think I'll take this
to wireless-next actually.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-11-28 14:09:18

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH net] wifi: plfxlc: fix potential memory leak in __lf_x_usb_enable_rx()

Ziyang Xuan <[email protected]> wrote:

> urbs does not be freed in exception paths in __lf_x_usb_enable_rx().
> That will trigger memory leak. To fix it, add kfree() for urbs within
> "error" label. Compile tested only.
>
> Fixes: 68d57a07bfe5 ("wireless: add plfxlc driver for pureLiFi X, XL, XC devices")
> Signed-off-by: Ziyang Xuan <[email protected]>

Patch applied to wireless-next.git, thanks.

895b3b06efc2 wifi: plfxlc: fix potential memory leak in __lf_x_usb_enable_rx()

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches