Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp173577imd; Wed, 31 Oct 2018 16:48:13 -0700 (PDT) X-Google-Smtp-Source: AJdET5e/6/2e52YxChd3EuZ2Z6b9SYNix1IXcZUg7WVaLdQNzJfgaVP8HezK/o//Cwpi1ot2mO/Q X-Received: by 2002:a17:902:860a:: with SMTP id f10-v6mr5348560plo.96.1541029693900; Wed, 31 Oct 2018 16:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029693; cv=none; d=google.com; s=arc-20160816; b=OghFFVak8ln5SROimPyAs8Y4FajNaRzWsWVUAkAKbHTskRKx+ufKDJxnwz/9zY8d0x VZ6cEVYyw3WZLAT516wKvBbgGP6TnlAnv17TCaPgxPlzxkWt+ayL2vhj7m8dUbPF96pM RfRWjHr+LLNmUMhNmADMSySrZnI1Y4anhP1bhl5P0So0zVcVAg03IMjqEKogUeBZgEM9 jz+HZwzKxywWfoKl8V4BVYd1eOzL7RlUEZwrNKv+EvDlyaXz7vlYIx3hXVanQYBfkNn2 hZwUS8825HU0bKZ9hTr/c4RHLpxDkPX5OjMW4fHHFWxoGdQjgrx07219tWY/ga7rume6 Z6YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Zm5BfoCd1USYW4KJ4OX93zA/DjbuMWLPTQ6vVcKSyZE=; b=PgHjuYCcdtgj3bElut6f2UQzdHGKHbQaIzHPVx8vnU2PL2H5M0/+S6gebWUlSvyKui RoNcYPIUU5N9QHX9J6PuOoHjgLWy8MdDD9ZGphzkDvdp0an1k4KJeIk0kqT7vP/+wnt1 0Kxojnxrmvfq9jlzhpxxjstVqenSx9D93a0j/eVVAfsbpEP058IsZaYViyPFkWF4QNVY 07zEEgSG0lTFEXgGudGg0dMjoIp2Yjzy73dVFAbQ5ycNdKdLWwq8JFVAKBzcEbDwKMaF gZ4dZkw0KtKAoZRSoHPI33xfSTy/+DXOSp4LO0EC0M3hnRCv/RxxZUO2xfbo+uBMF/6I 2DyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gw16Hp+o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si29421194pgl.446.2018.10.31.16.47.59; Wed, 31 Oct 2018 16:48:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gw16Hp+o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728803AbeKAIr4 (ORCPT + 99 others); Thu, 1 Nov 2018 04:47:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:54564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728583AbeKAIHG (ORCPT ); Thu, 1 Nov 2018 04:07:06 -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 1CAB020664; Wed, 31 Oct 2018 23:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027215; bh=cve0JzjkBBXhjrqg833vz0Rlg8TWz0LtQLnu86rwY2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gw16Hp+omLNdTGS3KMf4Jk3qDDL+94kSzHrNx5bn+5Focrbq/+c8/LowURL6hJPp9 Nu53PuDE8E/TB8pMhSREuwNGonBQl+efzN5tnkHA44WT1IUVzsffkqU6cYHYYyxK/f RA9o0WrCXWDW0z1Y0Z1+02wc6suXDm1WSzsQNlZY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Maya Erez , Kalle Valo , Sasha Levin Subject: [PATCH AUTOSEL 4.19 080/146] wil6210: fix RX buffers release and unmap Date: Wed, 31 Oct 2018 19:04:35 -0400 Message-Id: <20181031230541.28822-80-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maya Erez [ Upstream commit 84f16fbb62384fb209cd35741d94eb00b5ca2746 ] RX SKBs are released in both wil6210 rmmod and RX handle. As there is no lock to protect the buffers DMA unmap, the SKB pointer in buff_arr is used to check if the buffer memory was already released. Setting wil->rx_buff_mgmt.buff_arr[buff_id].skb to NULL before the DMA memory unmap will prevent duplicate unmapping of the same memory. Move the buffer ID to the free list also in case the SKB is NULL. Signed-off-by: Maya Erez Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/wil6210/txrx_edma.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/wil6210/txrx_edma.c b/drivers/net/wireless/ath/wil6210/txrx_edma.c index bca61cb44c37..3e7fc2983cbb 100644 --- a/drivers/net/wireless/ath/wil6210/txrx_edma.c +++ b/drivers/net/wireless/ath/wil6210/txrx_edma.c @@ -279,9 +279,6 @@ static void wil_move_all_rx_buff_to_free_list(struct wil6210_priv *wil, u16 buff_id; *d = *_d; - pa = wil_rx_desc_get_addr_edma(&d->dma); - dmalen = le16_to_cpu(d->dma.length); - dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE); /* Extract the SKB from the rx_buff management array */ buff_id = __le16_to_cpu(d->mac.buff_id); @@ -291,10 +288,15 @@ static void wil_move_all_rx_buff_to_free_list(struct wil6210_priv *wil, } skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb; wil->rx_buff_mgmt.buff_arr[buff_id].skb = NULL; - if (unlikely(!skb)) + if (unlikely(!skb)) { wil_err(wil, "No Rx skb at buff_id %d\n", buff_id); - else + } else { + pa = wil_rx_desc_get_addr_edma(&d->dma); + dmalen = le16_to_cpu(d->dma.length); + dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE); + kfree_skb(skb); + } /* Move the buffer from the active to the free list */ list_move(&wil->rx_buff_mgmt.buff_arr[buff_id].list, @@ -906,6 +908,9 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil, wil->rx_buff_mgmt.buff_arr[buff_id].skb = NULL; if (!skb) { wil_err(wil, "No Rx skb at buff_id %d\n", buff_id); + /* Move the buffer from the active list to the free list */ + list_move(&wil->rx_buff_mgmt.buff_arr[buff_id].list, + &wil->rx_buff_mgmt.free); goto again; } -- 2.17.1