From patchwork Wed Mar 10 16:13:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 84631 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2AGDsVO009062 for ; Wed, 10 Mar 2010 16:13:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932425Ab0CJQNp (ORCPT ); Wed, 10 Mar 2010 11:13:45 -0500 Received: from mail-bw0-f209.google.com ([209.85.218.209]:46732 "EHLO mail-bw0-f209.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756838Ab0CJQNo (ORCPT ); Wed, 10 Mar 2010 11:13:44 -0500 Received: by bwz1 with SMTP id 1so5089156bwz.21 for ; Wed, 10 Mar 2010 08:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=uo4DgG5Px/hM1c/u+pn7DxEcqXTSg/x6DDDHKgMw8Yc=; b=sp3sMFBAW8u27rszdFs+BRd2Gd9EnAueTCOzDMtOgFmV83KxGdnUFm6lII3UIuR8XT 6GudSmU9kp0/yGXAm8mK/RlxqeDb4vTh+9J9XpidPjYYBKYX+2SYXIzNN5hziRt9QW6b R6zLDBfRWo7Rta19BgEaZM5CLupUAQzEqeeKQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=Ia8hMg5XHN078dbGGnqqsPypy3suTdmnQrdeUy+mxGymsmUXPmvef7tiqRcCrFOteO 9R7H0cKe40RagTdejk0M7KP+ViFGS2o+w0/xMG1HlwZyd1ck3lK+xYVYyT/3QrhNTPxm JGxMQTo+C3thZY+LWAcxYn+E+veV8tEl60csg= Received: by 10.204.0.77 with SMTP id 13mr2095675bka.5.1268237621579; Wed, 10 Mar 2010 08:13:41 -0800 (PST) Received: from [127.0.0.1] (gw1.cosmosbay.com [212.99.114.194]) by mx.google.com with ESMTPS id 14sm3437551bwz.6.2010.03.10.08.13.39 (version=SSLv3 cipher=RC4-MD5); Wed, 10 Mar 2010 08:13:39 -0800 (PST) Subject: [PATCH] mac80211: Fix memory leak in ieee80211_if_write() From: Eric Dumazet To: David Miller , Johannes Berg Cc: netdev , linux-wireless@vger.kernel.org Date: Wed, 10 Mar 2010 17:13:36 +0100 Message-ID: <1268237616.2880.34.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Mar 2010 16:13:56 +0000 (UTC) diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 9affe2c..a55e864 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c @@ -48,20 +48,24 @@ static ssize_t ieee80211_if_write( ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int)) { u8 *buf; - ssize_t ret = -ENODEV; + ssize_t ret; - buf = kzalloc(count, GFP_KERNEL); + buf = kmalloc(count, GFP_KERNEL); if (!buf) return -ENOMEM; + ret = -EFAULT; if (copy_from_user(buf, userbuf, count)) - return -EFAULT; + goto freebuf; + ret = -ENODEV; rtnl_lock(); if (sdata->dev->reg_state == NETREG_REGISTERED) ret = (*write)(sdata, buf, count); rtnl_unlock(); +freebuf: + kfree(buf); return ret; }