From patchwork Thu Feb 5 13:45:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 5784711 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 260B9BF440 for ; Thu, 5 Feb 2015 13:47:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49F642021F for ; Thu, 5 Feb 2015 13:47:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23D3320115 for ; Thu, 5 Feb 2015 13:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757513AbbBENrX (ORCPT ); Thu, 5 Feb 2015 08:47:23 -0500 Received: from mail-ig0-f180.google.com ([209.85.213.180]:36478 "EHLO mail-ig0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753087AbbBENrW (ORCPT ); Thu, 5 Feb 2015 08:47:22 -0500 Received: by mail-ig0-f180.google.com with SMTP id b16so11909826igk.1 for ; Thu, 05 Feb 2015 05:47:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bNVNC7PfAUzeu9rP2Hb/UemPi7qMYmSfCPB4uH6ACag=; b=OfyDwMVFuL3QG6uQOrje0QIXP8jX92ICji4fOKCOXVy8vbh8HiEvL8kgNUmCkUd/r2 oDg8NA3FixJnH8Lzars9aFnsVoAFTxvclbQjDKkgfFuaJ2CGD8ijqAOo8m6IMiuFj0Pq vVwDA6+44nEvzRocxb4a6eOmFoH7/CALOQdOMTf/3a639yBxxOILy68B+7WXs07od9Gq 3QKyDOfuNkgqsskvf5uoVyUI1fcDhAdJ3apl+kMfhmc7eLNxkMvgQdtWSrefcDSi7yJ0 oe5pE3/XMCG8Vy2NIQK6kybWKDbIPTaiPr76rFqLZBOqEOvUAHLikWD6CzdfIzS5gfxs 6AEQ== X-Gm-Message-State: ALoCoQny/ikNd2kn8m9eCIt/w5esPTpyP03KJwqullq0igAPftnJ4bmdKFy/rypWR+o8bmgohrah X-Received: by 10.42.78.137 with SMTP id n9mr7441792ick.53.1423144041861; Thu, 05 Feb 2015 05:47:21 -0800 (PST) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by mx.google.com with ESMTPSA id yq1sm2715418igb.21.2015.02.05.05.47.20 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Feb 2015 05:47:20 -0800 (PST) Received: from bob by hash with local (Exim 4.80) (envelope-from ) id 1YJMlL-0004Zb-Cj; Thu, 05 Feb 2015 08:46:31 -0500 From: Bob Copeland To: linux-wireless@vger.kernel.org, johannes@sipsolutions.net Cc: Bob Copeland Subject: [PATCH] mac80211_hwsim: fix error handling in tx_frame_nl Date: Thu, 5 Feb 2015 08:45:43 -0500 Message-Id: <1423143943-17526-1-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 1.7.10.4 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, 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 Correct two problems with the error handling when using the netlink forwarding API: first, the netlink skb is never freed if nla_put() fails; and second, genlmsg_unicast() can fail if the netlink socket is full. In the latter case, the corresponding data skb is not counted as a drop and userspace programs like wmediumd will see TCP stalls due to lost packets. Signed-off-by: Bob Copeland --- drivers/net/wireless/mac80211_hwsim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 74f4e1c..1204853 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -947,7 +947,8 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, goto nla_put_failure; genlmsg_end(skb, msg_head); - genlmsg_unicast(&init_net, skb, dst_portid); + if (genlmsg_unicast(&init_net, skb, dst_portid)) + goto err_free_txskb; /* Enqueue the packet */ skb_queue_tail(&data->pending, my_skb); @@ -956,6 +957,8 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, return; nla_put_failure: + nlmsg_free(skb); +err_free_txskb: printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__); ieee80211_free_txskb(hw, my_skb); data->tx_failed++;