Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp879896pxk; Thu, 17 Sep 2020 20:10:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWAyKuX5h7rJNGyLNGv1NtvLiyaWcdRuHzORnOEKUUak+rAWFE1FCCI2k7xNBxdSNpi+zQ X-Received: by 2002:a17:906:e0c7:: with SMTP id gl7mr33336753ejb.109.1600398625413; Thu, 17 Sep 2020 20:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398625; cv=none; d=google.com; s=arc-20160816; b=y8C/Rs9garnf59EtI7hlY+SQgsYmBiVN1u9VNDw6uamvpz5grgH/s1F7A/+woZAiE1 80exSWDDVLNNG8AlyLj5A2SOrQaZePZs6MhTtqbZsAXBRBF80AA/wxX4FtGb+cxiG0tY Ts73IPW53smf7sAQVIZumCRT2KofcTfq5fgl++0C/eQcn2xKx7WXYZ0AdJDp7qsAl0uW n6jIU8UN5DaYya+FjCR9RLyVKDg3l9MU3KwUGVjxyDe1jSeg/kQcA7ZBAI0ipAq2fmA1 F7SBlL8wtkuBitmnD0oFIgyXKutSTFNOnI439/CqdLhexo8XKAFnncXqd2hzcP+bZp2Q RERA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tvfpEHQx7URn++rM8iQaMi5uDTLEVGt0az2S9MxDHyM=; b=lyZTPz23PwcxVhjOllYlmAMlwizslOz6AE5RKWL7eqpxrLkaAUH1DXTkAqCSI633I4 9Svp5YY3rXP47tRqyTTA/H2BMO9nvrFJ8/iT40odjEUvljBlYgh/4KtpHhZ+V53QTAcs dQuXqs4Z+V8hCS3ja5dfjbDwbl5LIXk1fxZK662bZEJ710df14AfBz73Xxoi/ZHZo4K9 jTSZJIPRz2ghJ5fhrqg3vwnuBbeqUbY+W8Fu3BC44cIOx/t6bPAeTHTDxe7Ds+nHBB2y KWt5DqkKBUlshBlW3WJROTma/VQ6Qqc7aa+sm1ByucF3tyri2i8cKwnefVzC4SQz+oNd XAGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AD5O4+Qc; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si1076024edt.550.2020.09.17.20.10.02; Thu, 17 Sep 2020 20:10:25 -0700 (PDT) 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=@kernel.org header.s=default header.b=AD5O4+Qc; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730643AbgIRDHH (ORCPT + 99 others); Thu, 17 Sep 2020 23:07:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:50584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727167AbgIRCDu (ORCPT ); Thu, 17 Sep 2020 22:03:50 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7580E23600; Fri, 18 Sep 2020 02:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394630; bh=StopoSPyCs7EocPsq1Gp2kQ/vfNkfLuq7EPGBHDEt7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AD5O4+QcRjFfmVpVKcYJRkqMJU1RXEJrbikUu3CEcmZGgmCg5fiavj7chnGma2tKA bVkNjPVgee+ilEei1DLut1t4/i6vMplj2T6uOiPMdXRjOXKKOnXEViXwzDg0uABSIo 9Qqe6/IMS+WOaO/3Skb6lguw+dweaN/JLxFNLHS4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Felix Fietkau , Sasha Levin , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.4 130/330] mt76: fix handling full tx queues in mt76_dma_tx_queue_skb_raw Date: Thu, 17 Sep 2020 21:57:50 -0400 Message-Id: <20200918020110.2063155-130-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felix Fietkau [ Upstream commit 93eaec7625f13cffb593b471405b017c7e64d4ee ] Fixes a theoretical issue where it could potentially overwrite an existing descriptor entry (and leaking its skb) Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/dma.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index 6249a46c19762..026d996612fbe 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -261,10 +261,13 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid, struct mt76_queue_buf buf; dma_addr_t addr; + if (q->queued + 1 >= q->ndesc - 1) + goto error; + addr = dma_map_single(dev->dev, skb->data, skb->len, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev->dev, addr))) - return -ENOMEM; + goto error; buf.addr = addr; buf.len = skb->len; @@ -275,6 +278,10 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid, spin_unlock_bh(&q->lock); return 0; + +error: + dev_kfree_skb(skb); + return -ENOMEM; } static int -- 2.25.1