From patchwork Sat Feb 14 19:52:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Engelmayer X-Patchwork-Id: 5828831 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 573849F380 for ; Sat, 14 Feb 2015 19:52:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2D6220138 for ; Sat, 14 Feb 2015 19:52:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 009EF20142 for ; Sat, 14 Feb 2015 19:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754243AbbBNTw1 (ORCPT ); Sat, 14 Feb 2015 14:52:27 -0500 Received: from mout.gmx.net ([212.227.17.21]:50967 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754177AbbBNTw0 (ORCPT ); Sat, 14 Feb 2015 14:52:26 -0500 Received: from localhost.localdomain ([81.217.123.197]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0LhwAY-1XrDU41fL0-00n6Ph; Sat, 14 Feb 2015 20:52:22 +0100 From: Christian Engelmayer To: johannes@sipsolutions.net Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Christian Engelmayer Subject: [PATCH] nl80211: Fix possible leak in nl80211_new_interface on MONITOR_FLAG_ACTIVE Date: Sat, 14 Feb 2015 20:52:01 +0100 Message-Id: <1423943521-2896-1-git-send-email-cengelma@gmx.at> X-Mailer: git-send-email 1.9.1 X-Provags-ID: V03:K0:P7Y/lm0t3zWmWtvsESqUXy15BwJJKNGHGypnAWbN98RVryJBOj0 9DWMOL3JffsvnFvEkWn65PGg17RdsxgWBuRlBDrh5sRs/jhjb9IPbJq/zWLiu/DgGnvm7qw rTZeEAeowgIpkQs+kC4JMcKw80btvTkDlYrYOICSnN9yjtsCQAxVJPn4LlnvA5Bjh7Wpks7 D6/bKVhgdIIVmhXBbsAPA== X-UI-Out-Filterresults: notjunk:1; Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of NL80211_IFTYPE_MONITOR and flag MONITOR_FLAG_ACTIVE, the already allocated sk_buff 'msg' is not freed, when the function exits in case the feature is not supported. Detected by Coverity CID 1269116. Signed-off-by: Christian Engelmayer --- Compile tested only. Applies against linux-next. --- net/wireless/nl80211.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index d78fd8b54515..38a7477dda81 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2663,8 +2663,10 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) &flags); if (!err && (flags & MONITOR_FLAG_ACTIVE) && - !(rdev->wiphy.features & NL80211_FEATURE_ACTIVE_MONITOR)) + !(rdev->wiphy.features & NL80211_FEATURE_ACTIVE_MONITOR)) { + nlmsg_free(msg); return -EOPNOTSUPP; + } wdev = rdev_add_virtual_intf(rdev, nla_data(info->attrs[NL80211_ATTR_IFNAME]),