kaweth: Fix memory leak in kaweth_control()
Subsystems (2)
PATCH 1/1 kaweth: Fix memory leak in kaweth_control()
kaweth_control() never frees the buffer that it allocates for the USB control message. Test case:
while :; do ifconfig eth2 down ; ifconfig eth2 up ; done
This is a tiny buffer so it is a slow leak. If you want to speed up the process, you can change the allocation size to e.g. 16384 bytes, and it will consume several megabytes within a few minutes.
--- drivers/net/usb/kaweth.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-)
drivers/net/usb/kaweth.c +11 -7
@@ -263,6 +263,7 @@ static int kaweth_control(struct kaweth_device *kaweth, int timeout) {struct usb_ctrlrequest *dr; +int retval;dbg ("kaweth_control()" );
@@ -278,18 +279,21 @@ static int kaweth_control(struct kaweth_device *kaweth,return -ENOMEM ; } - dr->bRequestType= requesttype; + dr->bRequestType = requesttype; dr->bRequest = request; dr->wValue =cpu_to_le16 (value); dr->wIndex =cpu_to_le16 (index); dr->wLength =cpu_to_le16 (size); -return kaweth_internal_control_msg (kaweth->dev, - pipe, - dr, - data, - size, - timeout); + retval =kaweth_internal_control_msg (kaweth->dev, + pipe, + dr, + data, + size, + timeout); + +kfree (dr); +return retval; }/****************************************************************
Signature · 1 line
1.6.3.1
Am Samstag, 19. September 2009 03:43:30 schrieb Kevin Cernekee:
Quoted 8 lines
kaweth_control()never frees the buffer that it allocates for the USB control message. Test case:while :; do ifconfig eth2 down ; ifconfig eth2 up ; done
This is a tiny buffer so it is a slow leak. If you want to speed up the process, you can change the allocation size to e.g. 16384 bytes, and it will consume several megabytes within a few minutes.
You are right, the patch is correct. But it has to go to netdev, as it is for a network driver. Please resend it and add
Greg, it should go into stable, too.
Regards
Oliver
From: Kevin Cernekee <[email protected]>
Date: Fri, 18 Sep 2009 18:43:30 -0700
Quoted 10 lines
kaweth_control()never frees the buffer that it allocates for the USB control message. Test case:while :; do ifconfig eth2 down ; ifconfig eth2 up ; done
This is a tiny buffer so it is a slow leak. If you want to speed up the process, you can change the allocation size to e.g. 16384 bytes, and it will consume several megabytes within a few minutes.
Signed-off-by Kevin Cernekee <[email protected]>
Applied, thanks.
I've been trying to wait to give time for people like david-b to review and bless the various USB networking patches that have been posted over the past few weeks but I'm running out of patience :-)
So simple ones like this I'm just gonna apply.