Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9457968pxu; Mon, 28 Dec 2020 17:16:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFy1a3Fl8mXyL/c7v0MWFwVh2jvuOp4mAsdheOxfgU68KTwCpJ3Z5C7FRQaFblQmEk6Ekf X-Received: by 2002:a05:6402:1b91:: with SMTP id cc17mr14676141edb.259.1609204569586; Mon, 28 Dec 2020 17:16:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609204569; cv=none; d=google.com; s=arc-20160816; b=Mvhd6iIPatdAaQmzlFAYc1vCszWFXQ4ki4mFbrcLigkeECw3Qi6Opj7xVZqRo7Jkon rzd9jHXgtvacZi4f3wPgVYRR31tpZxKB3iRWAKUT3u8MUGbP9UIj9oXKTO+Nc3dCm/mk XBB2d0kU+3e/IDXreaOby6WWNCSsHfI17hCfzp/gPvpILCSIPCizWlngAkbf6d1flq9Y 3nXWexjCI7edIOAmlozimLL1ACshiWGYcE+AoGne6rJQkI3/ri8qoqa8KUXAoPu2upey kMO21g2mQG/lFDM7uWdnK8qwA+roxbBbNEbwNYYgkoWC8KAWiohvC6g+XgcsiSN4d1HT Bn4g== 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=M5qqUhOBJu4Ifa5QpuaoIKeJZt4cC5xsVaJLeycM2Uo=; b=Yh97CwQ4TYyKh6Xt3KOUZeF4kGdSC+kxvcWtUOtVGcbOSkGJShZdzISs+25YA5JFgc ZNfDMq0UTKOAtZhKx2uxBJtFe3yJGRFvZsSH3ZXe7zJ/SaqSEGpUhnY/QSwbHFfg5NMK CmblILZjKQTvKkVduteLHoBFaJ5OVIXjj/RHmIYMaDIFoE5weDVDGf96ZxB7j+x5ZUJe cI4grSLomqwzRu9cdtDXITLCHhtImbZps8pSkTn1dq5s5XhpFmF+Dx8/VDOu1J6Ywvwl Am1x16QClLzwopVZ5ZkZdBU7juVm940F7wUjiMFgXaRw331RxIbs4DNaf/1/x59oodg0 gBCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="stxY/3Vd"; 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 z7si21303260edx.473.2020.12.28.17.15.47; Mon, 28 Dec 2020 17:16:09 -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="stxY/3Vd"; 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 S2635004AbgL1Qq5 (ORCPT + 99 others); Mon, 28 Dec 2020 11:46:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:52398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727738AbgL1Mz5 (ORCPT ); Mon, 28 Dec 2020 07:55:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 83A372242A; Mon, 28 Dec 2020 12:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160117; bh=jliTJ6MxvOT1ZzojDgzKGZaR8dfMrwuKCxrVViWIqKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=stxY/3VdES4d1qazfURR+bn3VdiNOk6ocpHn6YzLYLJ6+50DZPfSr8byEJWsTDGqb 2tQ7cFHbJOfPPk0LSpKkvdFU+XFTpW/uQbBvIUS5L2MfQX9j+01VSmO4+vj8wRFj7b t+exhr+ffHU+K6yrPoZEMugj0gvkcgSmNeOKtpug= 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.4 057/132] orinoco: Move context allocation after processing the skb Date: Mon, 28 Dec 2020 13:49:01 +0100 Message-Id: <20201228124849.198997606@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124846.409999325@linuxfoundation.org> References: <20201228124846.409999325@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 --- drivers/net/wireless/orinoco/orinoco_usb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c index 3c5baccd67922..8eb73d54b1d6d 100644 --- a/drivers/net/wireless/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/orinoco/orinoco_usb.c @@ -1224,13 +1224,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, @@ -1238,6 +1231,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