Commit 3459a712 authored by Peilin Ye's avatar Peilin Ye Committed by Jialin Zhang
Browse files

usbnet: Fix memory leak in usbnet_disconnect()

stable inclusion
from stable-v5.10.147
commit fa065e60811a689601924e8ade4a81a90468e204
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0W8

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=fa065e60811a689601924e8ade4a81a90468e204



--------------------------------

[ Upstream commit a4320615 ]

Currently usbnet_disconnect() unanchors and frees all deferred URBs
using usb_scuttle_anchored_urbs(), which does not free urb->context,
causing a memory leak as reported by syzbot.

Use a usb_get_from_anchor() while loop instead, similar to what we did
in commit 19cfe912 ("Bluetooth: btusb: Fix memory leak in
play_deferred").  Also free urb->sg.

Reported-and-tested-by: default avatar <syzbot+dcd3e13cf4472f2e0ba1@syzkaller.appspotmail.com>
Fixes: 69ee472f ("usbnet & cdc-ether: Autosuspend for online devices")
Fixes: 638c5115 ("USBNET: support DMA SG")
Signed-off-by: default avatarPeilin Ye <peilin.ye@bytedance.com>
Link: https://lore.kernel.org/r/20220923042551.2745-1-yepeilin.cs@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 0913e953
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment