Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9036478pxu; Mon, 28 Dec 2020 05:05:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvEDu+apmxOhs7w8Eu/8lrrQJbLbyuAQVYEKbgb2Z8+5bNKpyyYn7PBfgACcOl+z6h1Emt X-Received: by 2002:a50:c209:: with SMTP id n9mr41945905edf.123.1609160706062; Mon, 28 Dec 2020 05:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160706; cv=none; d=google.com; s=arc-20160816; b=OTo6/J/93M887cGj1IndCKIYgBzELZQYRYEytEFQx28jHRu+9X8i22HWtwplEM/dkj cCc46MOQCbD9/9G1hi/edWx6jDr59lvM8oaRWARlCseEMDwT03VzES/Zj3KWcHg1iK+d kTJTczbkFijFmurJ0ImgbKMhwQ402/+qQK/l0ZBcv7gfzSxF9U9X07ZmggtvYguoh9qi Y0VQzxHFiGuDTt8WphtzJOZxAd5Xt1tOhskzekvbEBzfWALJ5DSDFOiyvg6HiBsQuO4G m8WoROvEuOGdbV9ysfmFzRXuG5I30KEvLVS6w4zUWNqMn6uFaStwKy0XShCJNziApZ4I cUTw== 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=BcZyAmeDydRzN55O1kCcjNmmNSo05suTelOmFZ5jL2o=; b=EX5hkc1LxGU9M6uhCU8tNODNbVJ+BGAIAsi1TuiC0F/mit9Vo/oE0Lq+ECSCcw+jF5 0wtinZma3ReiagmKeyYU+yzG97/aeSkguIFpgMfM84HahDnKu3KmMwvLGb6A1vPSNpV/ 0nRefJNjC7EBuFFFx2NSIP7wTGynTzrp6NrKuiBM8NGASrYNF5mKjHos9ghxanLQAHvq uHyppZOSowiZl/5tNihz4tZ6M0hM+CHl6AR0/5UmaceIzf2Q7drtnR+VKwNy+wA5X+Xu hcjL7Pi86OT3KuTPpZ4qcqRrjJUot8dgRzqxAqq45HE5E1UtQaJBtV5U20vnnDlk1u7E PeAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lm1f36AC; 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 d16si19629836edp.251.2020.12.28.05.04.41; Mon, 28 Dec 2020 05:05:06 -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=Lm1f36AC; 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 S1730068AbgL1NCW (ORCPT + 99 others); Mon, 28 Dec 2020 08:02:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:58244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730056AbgL1NCU (ORCPT ); Mon, 28 Dec 2020 08:02:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 29935208B6; Mon, 28 Dec 2020 13:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160524; bh=qhDfQ2L5gkXut6BkNW3v3ZYyBtI5jQZJYTNpSA/GefY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lm1f36ACYe1An6wTYiPkxHhrJdHdravCfeZJENgjx+xZ0U2L9TwSPVA5pV+R9kv4S lXX8IIcuCOmTze26gb21M5JWNSyvzPd08M4/zwEDqT5IzzdK8YeSPjaESZLwykt4cW ViY5onWg4XXgSGi+SUAZzdutW/7K/Bhu+71cjmzk= 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.9 080/175] orinoco: Move context allocation after processing the skb Date: Mon, 28 Dec 2020 13:48:53 +0100 Message-Id: <20201228124857.110446927@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 4e91c74fcfad9..de928938c7a1c 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/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