Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9122341pxu; Mon, 28 Dec 2020 07:10:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9GTfqAKD20TKVrJt/Y4a+oct+LCwXoRGg+XMfbWr2j2RYTMLADiKrN0ZMrLV4RqSNhoyZ X-Received: by 2002:a17:906:d8dc:: with SMTP id re28mr42275381ejb.168.1609168237624; Mon, 28 Dec 2020 07:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609168237; cv=none; d=google.com; s=arc-20160816; b=xM2vre072UAm/MDpEIlmd/VTmDgh04Jv/L9SPJ1DgvVeEW+iDd55G4KWoSQUFapFp3 ZSzQVvt61W48+1G6VI9c0QrArtqBq5dNIBMx/a0KmI8vIfh0YwyqSHkDVkM1DzwvhjkV XRVnPzF9me2jgrDMn52GxlZ4oIIos9/nogYYL+kcY56mi6YZmPccjTFsiVXg9hm5wgXr 4fbVZO/2PE+LAdrWAsBmBqAvcle3oIq6VZc07jdvR84tsuuGVheH2/Q0tj4r6xBVCtR/ QgVCRFbGm1BYx1ewjIoRzbl71W4gKYrTFChWm57YkLuwxaqB1T1aTiEuaWSJo+yGd8Gj 22mQ== 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=P7BiOJIrb1E/LbTxHnxOStkdgsTdlv9cZQ5sSr+njjY=; b=cJ5HS6V18yyTG6rNQlkSuei/Lfza9rhx7kEjEiIVtXM297BetC7kP0iFRAqz8LOX0O Qw+DHeHSmGZ4CJ2YCWzahle3whPzgcq9uXiAD3k7HNDi2EfdBlNwgWdJw5LFhzmFExpM KriE08YUa1uVq9K0856tMQsY8S3Rl9hZ0EVlPHht+IWwCEVxgcPN2wHV2eUnIEU1ZGlz AINBfBYKk9Se8QMifd//AYSEmpkfHcKeYVxxDagaoN0pzfZVlxv0vo26BMVIMhV04+q2 H+RQxLqOfDICVdagmXy1ihIXHVuO+xHl6JBHyV6Jnme9o0Z1bow4qJYelPEurA7oIqN8 zA7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="b/1L3P2P"; 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 h4si18241960eje.526.2020.12.28.07.10.12; Mon, 28 Dec 2020 07:10:37 -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="b/1L3P2P"; 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 S2438649AbgL1PHj (ORCPT + 99 others); Mon, 28 Dec 2020 10:07:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:41626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438651AbgL1OIW (ORCPT ); Mon, 28 Dec 2020 09:08:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB3B9205CB; Mon, 28 Dec 2020 14:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164487; bh=yaf97o6Ob8aT8UTb3q+E73Rr51snSRdZKeDNZNHzUqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/1L3P2Pge+p/ybhFVdZOZQOw1FqYPSPeYI+1EDNyrnRSwDxHdqtghx/1zjT3qHOZ O3Bml36Mg2OnuucxosTJ9nYASkPEFPEZZ1q/x4zq/etI/BODxphZdHorUi0oLY+bdm rz0Te5vyq9fAOozH8TIhLkLhjlSbXUmkj9OCKveY= 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 5.10 197/717] orinoco: Move context allocation after processing the skb Date: Mon, 28 Dec 2020 13:43:15 +0100 Message-Id: <20201228125030.408857464@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 b849d27bd741e..d1fc948364c79 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1223,13 +1223,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, @@ -1237,6 +1230,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