From patchwork Sat Sep 19 21:18:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Cernekee X-Patchwork-Id: 33953 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 9A9DCB7B69 for ; Sun, 20 Sep 2009 07:35:15 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbZISVel (ORCPT ); Sat, 19 Sep 2009 17:34:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752205AbZISVel (ORCPT ); Sat, 19 Sep 2009 17:34:41 -0400 Received: from [65.98.92.6] ([65.98.92.6]:1769 "EHLO b32.net" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751584AbZISVek (ORCPT ); Sat, 19 Sep 2009 17:34:40 -0400 X-Greylist: delayed 401 seconds by postgrey-1.27 at vger.kernel.org; Sat, 19 Sep 2009 17:34:40 EDT Received: (qmail 2130 invoked from network); 19 Sep 2009 21:28:01 -0000 Received: from unknown (HELO two) (127.0.0.1) by 127.0.0.1 with SMTP; 19 Sep 2009 21:28:01 -0000 Received: by two (sSMTP sendmail emulation); Sat, 19 Sep 2009 14:28:01 -0700 From: Kevin Cernekee To: Cc: , , Oliver Neukum , Greg Kroah-Hartman Date: Sat, 19 Sep 2009 14:18:21 -0700 Subject: [PATCH RESEND] kaweth: Fix memory leak in kaweth_control() Message-Id: <3317a2830541b564fef54730a60f85dc@localhost> User-Agent: vim 7.1 MIME-Version: 1.0 Content-Disposition: inline Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Oliver Neukum --- drivers/net/usb/kaweth.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index e2a39b9..e391ef9 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -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; } /****************************************************************