* [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs
@ 2021-10-20 12:03 Wang Hai
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 1/2] libertas_tf: Fix possible memory leak in probe and disconnect Wang Hai
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wang Hai @ 2021-10-20 12:03 UTC (permalink / raw)
To: kvalo, briannorris, davem, kuba, shenyang39, marcelo, linville, luisca
Cc: libertas-dev, linux-wireless, netdev, linux-kernel
This patchset fixes some memory leak bugs by adding the missing kfree().
v1->v2:
1. Fix the wrong subject.
2. Splitting the big patch into two separate patches.
Wang Hai (2):
libertas_tf: Fix possible memory leak in probe and disconnect
libertas: Fix possible memory leak in probe and disconnect
drivers/net/wireless/marvell/libertas/if_usb.c | 2 ++
drivers/net/wireless/marvell/libertas_tf/if_usb.c | 2 ++
2 files changed, 4 insertions(+)
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 wireless-drivers 1/2] libertas_tf: Fix possible memory leak in probe and disconnect
2021-10-20 12:03 [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs Wang Hai
@ 2021-10-20 12:03 ` Wang Hai
2021-10-27 7:32 ` Kalle Valo
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 2/2] libertas: " Wang Hai
2021-10-20 17:33 ` [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs Brian Norris
2 siblings, 1 reply; 5+ messages in thread
From: Wang Hai @ 2021-10-20 12:03 UTC (permalink / raw)
To: kvalo, briannorris, davem, kuba, shenyang39, marcelo, linville, luisca
Cc: libertas-dev, linux-wireless, netdev, linux-kernel
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff88810a2ddc00 (size 512):
comm "kworker/6:1", pid 176, jiffies 4295009893 (age 757.220s)
hex dump (first 32 bytes):
00 50 05 18 81 88 ff ff 00 00 00 00 00 00 00 00 .P..............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8167939c>] slab_post_alloc_hook+0x9c/0x490
[<ffffffff8167f627>] kmem_cache_alloc_trace+0x1f7/0x470
[<ffffffffa02a1530>] if_usb_probe+0x60/0x37c [libertas_tf_usb]
[<ffffffffa022668a>] usb_probe_interface+0x1aa/0x3c0 [usbcore]
[<ffffffff82b59630>] really_probe+0x190/0x480
[<ffffffff82b59a19>] __driver_probe_device+0xf9/0x180
[<ffffffff82b59af3>] driver_probe_device+0x53/0x130
[<ffffffff82b5a075>] __device_attach_driver+0x105/0x130
[<ffffffff82b55949>] bus_for_each_drv+0x129/0x190
[<ffffffff82b593c9>] __device_attach+0x1c9/0x270
[<ffffffff82b5a250>] device_initial_probe+0x20/0x30
[<ffffffff82b579c2>] bus_probe_device+0x142/0x160
[<ffffffff82b52e49>] device_add+0x829/0x1300
[<ffffffffa02229b1>] usb_set_configuration+0xb01/0xcc0 [usbcore]
[<ffffffffa0235c4e>] usb_generic_driver_probe+0x6e/0x90 [usbcore]
[<ffffffffa022641f>] usb_probe_device+0x6f/0x130 [usbcore]
cardp is missing being freed in the error handling path of the probe
and the path of the disconnect, which will cause memory leak.
This patch adds the missing kfree().
Fixes: c305a19a0d0a ("libertas_tf: usb specific functions")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
drivers/net/wireless/marvell/libertas_tf/if_usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
index fe0a69e804d8..75b5319d033f 100644
--- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
@@ -230,6 +230,7 @@ static int if_usb_probe(struct usb_interface *intf,
dealloc:
if_usb_free(cardp);
+ kfree(cardp);
error:
lbtf_deb_leave(LBTF_DEB_MAIN);
return -ENOMEM;
@@ -254,6 +255,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
/* Unlink and free urb */
if_usb_free(cardp);
+ kfree(cardp);
usb_set_intfdata(intf, NULL);
usb_put_dev(interface_to_usbdev(intf));
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 wireless-drivers 2/2] libertas: Fix possible memory leak in probe and disconnect
2021-10-20 12:03 [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs Wang Hai
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 1/2] libertas_tf: Fix possible memory leak in probe and disconnect Wang Hai
@ 2021-10-20 12:03 ` Wang Hai
2021-10-20 17:33 ` [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs Brian Norris
2 siblings, 0 replies; 5+ messages in thread
From: Wang Hai @ 2021-10-20 12:03 UTC (permalink / raw)
To: kvalo, briannorris, davem, kuba, shenyang39, marcelo, linville, luisca
Cc: libertas-dev, linux-wireless, netdev, linux-kernel
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff88812c7d7400 (size 512):
comm "kworker/6:1", pid 176, jiffies 4295003332 (age 822.830s)
hex dump (first 32 bytes):
00 68 1e 04 81 88 ff ff 01 00 00 00 00 00 00 00 .h..............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8167939c>] slab_post_alloc_hook+0x9c/0x490
[<ffffffff8167f627>] kmem_cache_alloc_trace+0x1f7/0x470
[<ffffffffa02c9873>] if_usb_probe+0x63/0x446 [usb8xxx]
[<ffffffffa022668a>] usb_probe_interface+0x1aa/0x3c0 [usbcore]
[<ffffffff82b59630>] really_probe+0x190/0x480
[<ffffffff82b59a19>] __driver_probe_device+0xf9/0x180
[<ffffffff82b59af3>] driver_probe_device+0x53/0x130
[<ffffffff82b5a075>] __device_attach_driver+0x105/0x130
[<ffffffff82b55949>] bus_for_each_drv+0x129/0x190
[<ffffffff82b593c9>] __device_attach+0x1c9/0x270
[<ffffffff82b5a250>] device_initial_probe+0x20/0x30
[<ffffffff82b579c2>] bus_probe_device+0x142/0x160
[<ffffffff82b52e49>] device_add+0x829/0x1300
[<ffffffffa02229b1>] usb_set_configuration+0xb01/0xcc0 [usbcore]
[<ffffffffa0235c4e>] usb_generic_driver_probe+0x6e/0x90 [usbcore]
[<ffffffffa022641f>] usb_probe_device+0x6f/0x130 [usbcore]
cardp is missing being freed in the error handling path of the probe
and the path of the disconnect, which will cause memory leak.
This patch adds the missing kfree().
Fixes: 876c9d3aeb98 ("[PATCH] Marvell Libertas 8388 802.11b/g USB driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
drivers/net/wireless/marvell/libertas/if_usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/wireless/marvell/libertas/if_usb.c b/drivers/net/wireless/marvell/libertas/if_usb.c
index 20436a289d5c..5d6dc1dd050d 100644
--- a/drivers/net/wireless/marvell/libertas/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas/if_usb.c
@@ -292,6 +292,7 @@ static int if_usb_probe(struct usb_interface *intf,
if_usb_reset_device(cardp);
dealloc:
if_usb_free(cardp);
+ kfree(cardp);
error:
return r;
@@ -316,6 +317,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
/* Unlink and free urb */
if_usb_free(cardp);
+ kfree(cardp);
usb_set_intfdata(intf, NULL);
usb_put_dev(interface_to_usbdev(intf));
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs
2021-10-20 12:03 [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs Wang Hai
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 1/2] libertas_tf: Fix possible memory leak in probe and disconnect Wang Hai
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 2/2] libertas: " Wang Hai
@ 2021-10-20 17:33 ` Brian Norris
2 siblings, 0 replies; 5+ messages in thread
From: Brian Norris @ 2021-10-20 17:33 UTC (permalink / raw)
To: Wang Hai
Cc: Kalle Valo, David S. Miller, Jakub Kicinski, shenyang39, marcelo,
linville, luisca, libertas-dev, linux-wireless,
<netdev@vger.kernel.org>,
Linux Kernel
On Wed, Oct 20, 2021 at 5:04 AM Wang Hai <wanghai38@huawei.com> wrote:
> This patchset fixes some memory leak bugs by adding the missing kfree().
You could probably just as well switch the kzalloc()'s to be
devm_kzalloc()'s, but either way works I guess.
Reviewed-by: Brian Norris <briannorris@chromium.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 wireless-drivers 1/2] libertas_tf: Fix possible memory leak in probe and disconnect
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 1/2] libertas_tf: Fix possible memory leak in probe and disconnect Wang Hai
@ 2021-10-27 7:32 ` Kalle Valo
0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-10-27 7:32 UTC (permalink / raw)
To: Wang Hai
Cc: briannorris, davem, kuba, shenyang39, marcelo, linville, luisca,
libertas-dev, linux-wireless, netdev, linux-kernel
Wang Hai <wanghai38@huawei.com> wrote:
> I got memory leak as follows when doing fault injection test:
>
> unreferenced object 0xffff88810a2ddc00 (size 512):
> comm "kworker/6:1", pid 176, jiffies 4295009893 (age 757.220s)
> hex dump (first 32 bytes):
> 00 50 05 18 81 88 ff ff 00 00 00 00 00 00 00 00 .P..............
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> backtrace:
> [<ffffffff8167939c>] slab_post_alloc_hook+0x9c/0x490
> [<ffffffff8167f627>] kmem_cache_alloc_trace+0x1f7/0x470
> [<ffffffffa02a1530>] if_usb_probe+0x60/0x37c [libertas_tf_usb]
> [<ffffffffa022668a>] usb_probe_interface+0x1aa/0x3c0 [usbcore]
> [<ffffffff82b59630>] really_probe+0x190/0x480
> [<ffffffff82b59a19>] __driver_probe_device+0xf9/0x180
> [<ffffffff82b59af3>] driver_probe_device+0x53/0x130
> [<ffffffff82b5a075>] __device_attach_driver+0x105/0x130
> [<ffffffff82b55949>] bus_for_each_drv+0x129/0x190
> [<ffffffff82b593c9>] __device_attach+0x1c9/0x270
> [<ffffffff82b5a250>] device_initial_probe+0x20/0x30
> [<ffffffff82b579c2>] bus_probe_device+0x142/0x160
> [<ffffffff82b52e49>] device_add+0x829/0x1300
> [<ffffffffa02229b1>] usb_set_configuration+0xb01/0xcc0 [usbcore]
> [<ffffffffa0235c4e>] usb_generic_driver_probe+0x6e/0x90 [usbcore]
> [<ffffffffa022641f>] usb_probe_device+0x6f/0x130 [usbcore]
>
> cardp is missing being freed in the error handling path of the probe
> and the path of the disconnect, which will cause memory leak.
>
> This patch adds the missing kfree().
>
> Fixes: c305a19a0d0a ("libertas_tf: usb specific functions")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
2 patches applied to wireless-drivers-next.git, thanks.
d549107305b4 libertas_tf: Fix possible memory leak in probe and disconnect
9692151e2fe7 libertas: Fix possible memory leak in probe and disconnect
--
https://patchwork.kernel.org/project/linux-wireless/patch/20211020120345.2016045-2-wanghai38@huawei.com/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-27 7:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 12:03 [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs Wang Hai
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 1/2] libertas_tf: Fix possible memory leak in probe and disconnect Wang Hai
2021-10-27 7:32 ` Kalle Valo
2021-10-20 12:03 ` [PATCH v2 wireless-drivers 2/2] libertas: " Wang Hai
2021-10-20 17:33 ` [PATCH v2 wireless-drivers 0/2] libertas: Fix some memory leak bugs Brian Norris
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.