Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3412159imu; Sun, 11 Nov 2018 14:28:41 -0800 (PST) X-Google-Smtp-Source: AJdET5dWx5XKhzsjUkGHuEo5J3o4hcirakjvDsWC+33xYRDx7sT4hECnH8EptU/786IrLrdyJiWB X-Received: by 2002:a17:902:32a4:: with SMTP id z33-v6mr17169877plb.168.1541975321748; Sun, 11 Nov 2018 14:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541975321; cv=none; d=google.com; s=arc-20160816; b=CLBWouCv2mzmmq5KeqiJhjtWkiCWyzCt0QK1M5crqOJRZB+ryW9TbstIiOmkzbCxie 6a6rLwWP1Gt/9BwEHwInxaBEZHGqFqApkYon73vDjG5/EF1FewTHiVriMWHImdp9RpQW GGX5OzdEwHfWFejjnTYj/E/7leKjUTiggErYqJfA/eOHzfKQDTZRMzEEelI+yVqTqp9o NI7WryErjPSIqoXq2qwoKV9vRxfdDrPBqB6xORfQJGMHE/hG8D42WCeaYNauqjGAc34D jIXqyTU7xFt5NHjRzuLsxSZ1UhUsMvOMa3P6TI4H0qBgbPTIcZCdPKBu9bEakVuGB3hK j74Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dC+YdwTdyUquILSQO8ATEbODCh6C8FXvkRO7SC+2FZU=; b=OrcK86RInpFptKSmmpVzr5QGNklLzjuGmaRe7cc3/WnGP6JLzcb3vKO6o22Z9htorj UoiDfi3jWNedex8Ht41W6Gw51nma+GkrFgnR5F8jdLjl55Eu7r3Y92cXCj03Cy+ODehI 29lIijsxBwKbCAvJEC1DAy8jWpYO4Zhn8UTEUWqsgRz8SOqO2tMxoHcfdoAsCAp9F9Ep vkH7U2A6VKpF4jOSUKM+XSVqAgO3TeRnVwtTNWGFsr20mnlvsnSiIS2A7zQF1XvQABMg Vy2/v/hoOyQvwcIWjdu5wN+kSO9QlPLJaz/YGdTE0vplHaaxGSGbKWMzIsaagbPOePoU Fodg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ApBbgU/l"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13-v6si15484581pgp.145.2018.11.11.14.28.25; Sun, 11 Nov 2018 14:28:41 -0800 (PST) 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="ApBbgU/l"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731249AbeKLIRb (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:60706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731012AbeKLIRa (ORCPT ); Mon, 12 Nov 2018 03:17:30 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 833FF21582; Sun, 11 Nov 2018 22:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975254; bh=OtL1vIwBQ7+pfGowdws6SVXiXQKmkUKP4EPSEYTjtF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ApBbgU/lH4Vo9XbMRLiOc4udMzAJ50zPFtnRgO00zHENxPrvhFxUS7o2NJywwisTN zu3hT2MNGTcp+CcoNL2BSq3zhdc/dgY1cV4/Ecm4MIFG0nJ4VhxZzOIodc/FRPcNhX 7aJ3J2L180DaW0rHfM2P+y+LuNeIdegVcMWk57gg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maya Erez , Kalle Valo , Sasha Levin Subject: [PATCH 4.19 125/361] wil6210: fix RX buffers release and unmap Date: Sun, 11 Nov 2018 14:17:52 -0800 Message-Id: <20181111221637.671021663@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/wil6210/txrx_edma.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- 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 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 } 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 @@ again: 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; }