Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9226480pxu; Mon, 28 Dec 2020 09:49:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRgbLMb49P6d2JaA4iZ+1J8HwgVIvUvY9vFMlWMpxQgj5GyL4/DMJCRs7EF9zi9dRLnAqD X-Received: by 2002:a05:6402:139a:: with SMTP id b26mr43331203edv.47.1609177745272; Mon, 28 Dec 2020 09:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609177745; cv=none; d=google.com; s=arc-20160816; b=Itjlj9a/CgwMqaB0eTGdLVeQ1NA63NQB8vOzobkruV3/Y+at4fkQLR8dXWDcJdBJp6 zKKZ9sdFVYUy9bAMq+fGN81KaI+TK3/Jfsx87YJReyDi+PwLhIpX7qWAaNHESm8eayA4 jxY+OlJ9EOQgyjy+3AyvQGD7Vm3CHvU2eRMTIR3ExRAYlHw+K8b0IsenUZpyioURMngs 5N86gMQrjyuYj/jLy1RupnU4KATKm4sgsL8m1MMYuNNI4Ziaq2wueeKtPv7qwvc+f3LY YNezAhdcDw11A9ygEizQn+WuK2X8qtzOhSEmsW1fvf439Y4g/ED1TyCpmkacCbE2WySX r17A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e4kyblCMulIUFmHut+U8ZSjVWWqt14VRWWgUZc67eVU=; b=SsuLeqWbhaX/P4mFDTl/iLbFDlCAr7QA7vjkKtR9zIoNJe/jQohej9FFE/stkRTZvw rS99++d0lzsZl4RWg5NRx9Sf4OVFar0AumfuzU0A2SXTz2/LX5+qv2i8+Ubd0r8mx10s If3wVCHM5OHlfodlMb1k3banZIVlEkSlqyKSmKtxFqqvEWbPPpwARXeKWeh/yCE9ZMxZ s6fJAEsGgdoiBtw51SsooT/410gut5SalNHsl6UKWjkK8/Sly0I/P6XWpcs2gnY8Qeor joez8faVFeV5VIhn+jQx5K9rBAdavQD1qC9j6LD5ph70zSRQnzW4YHp7jyolGJ4ZMjVy 12YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B6ixqs+4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si20688260edr.271.2020.12.28.09.48.43; Mon, 28 Dec 2020 09:49:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B6ixqs+4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732450AbgL1NOO (ORCPT + 99 others); Mon, 28 Dec 2020 08:14:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:42294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732432AbgL1NON (ORCPT ); Mon, 28 Dec 2020 08:14:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD10320728; Mon, 28 Dec 2020 13:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161212; bh=noDZoDl+h9FBLAcMyfJuTNY2SxLgQcSRzut6Y4ZkC+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B6ixqs+4ZZK1m5y48rLxas0CkyWdlzKFMK8izzhplp9kYlHIxxM+ltr7rZOCvyRNq qTAWDq1kWUdplxDpTVcJouEcLjtTXfQXffTQCFc9TeZ8rNbVJ2bWd9R9IP9KWM6pp4 x/2iAUvBQRg6qkuf/oZx5v7B6Go/P54uylJnAOCA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , Kalle Valo , Sasha Levin Subject: [PATCH 4.14 110/242] orinoco: Move context allocation after processing the skb Date: Mon, 28 Dec 2020 13:48:35 +0100 Message-Id: <20201228124910.103250765@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior [ Upstream commit a31eb615646a63370aa1da1053c45439c7653d83 ] ezusb_xmit() allocates a context which is leaked if orinoco_process_xmit_skb() returns an error. Move ezusb_alloc_ctx() after the invocation of orinoco_process_xmit_skb() because the context is not needed so early. ezusb_access_ltv() will cleanup the context in case of an error. Fixes: bac6fafd4d6a0 ("orinoco: refactor xmit path") Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-2-bigeasy@linutronix.de Signed-off-by: Sasha Levin --- .../net/wireless/intersil/orinoco/orinoco_usb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 5a64674a5c8da..74a313e6d98f2 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1237,13 +1237,6 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev) if (skb->len < ETH_HLEN) goto drop; - ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0); - if (!ctx) - goto busy; - - memset(ctx->buf, 0, BULK_BUF_SIZE); - buf = ctx->buf->data; - tx_control = 0; err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control, @@ -1251,6 +1244,13 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev) if (err) goto drop; + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0); + if (!ctx) + goto drop; + + memset(ctx->buf, 0, BULK_BUF_SIZE); + buf = ctx->buf->data; + { __le16 *tx_cntl = (__le16 *)buf; *tx_cntl = cpu_to_le16(tx_control); -- 2.27.0