Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp439012ybz; Wed, 22 Apr 2020 01:00:30 -0700 (PDT) X-Google-Smtp-Source: APiQypJDiT84kqYjEPzf9E49NipvzR3uksKUXi1XZfedBkZ9O/W+CAJdcNw7DCbpr0Ma/Tsvg/f2 X-Received: by 2002:a17:906:374b:: with SMTP id e11mr26037817ejc.283.1587542430621; Wed, 22 Apr 2020 01:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587542430; cv=none; d=google.com; s=arc-20160816; b=VU9RYdQ5qa8v/ecvfkMhG20FFLKGw0bWXuVG0o9oaMhPLAVwdCgPNGxX45Vs6Mm7BY /5TGYOH4l2m74MlcjmquIF4WIQnZnzsEcaJLj7fVLzSMSEr9XNWBlDxleDe27h+UbagM 6wxaLO3qg/ykROZ8uCNbIUESEj/lqFwhaCjYfKWVnInARwvscexZaaJxAmDIEZ8JZkY+ K2WD4iSIxhhVB97t3wCGOhAih0UWYk+415ymWvWOM62nQiql2zzK8/gLFjiqXUegjVuf S6tmDIKNnkSnO4LUGc4m6huJXoWMKyUrhmN40XGk0r939Pztt7wmSA7OMJJCROe3cISm 0srQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=20AKh3G777jQFV57EX4UtFeCp7GDZMZq/5EgmU1NXL8=; b=vQab7Y9xNW14TFVkQc+QxKr9wso6fvQhHxtnvwRZ5vb3n6OpG1WaZWtQRMAXFDBfDn UBXLQaoYXwbWf2bX+4jTVVUlbzcgegR6F+g/S1qbp01jdZBEfC0xbHB0zuJHwVN5u/P7 llb+yWZceNSmjVNs4f4JPirV2Ic3jpc+PmZhIB95nNSMl1vmKoG0xPa5FwJvTlIB/lk3 nxTxNa2mgEVOz3QqoW3PKJeIDc7uL/pkt2VtzgMsuAUHO6Jy9fKUh2nvDZ/vn/JakTFQ 60HpdRbe4FnmDgFI+NNxDj1j/3rGISfmr3dQKiT79hdPKXXa/auQkh6xZ25bDkNMAuYO 8F9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Bpp8EBJE; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oo21si2890015ejb.453.2020.04.22.01.00.07; Wed, 22 Apr 2020 01:00:30 -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=@ti.com header.s=ti-com-17Q1 header.b=Bpp8EBJE; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726078AbgDVH4p (ORCPT + 99 others); Wed, 22 Apr 2020 03:56:45 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:57958 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbgDVH4p (ORCPT ); Wed, 22 Apr 2020 03:56:45 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03M7ubO6066220; Wed, 22 Apr 2020 02:56:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587542197; bh=20AKh3G777jQFV57EX4UtFeCp7GDZMZq/5EgmU1NXL8=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=Bpp8EBJE4ahCgNIXCcNZzdAxhLeuDYXiuLRfSKvXjD9kE9RzPVGxACBpCSbEhpInW d0OlYcECAif/vO/MYWsgbdKhM2o7ShEJIqrmRD+jzURcfFHDny1bb09xAOzmg2tDqe 6PEkmH8DDdIF6ztQ3AfAcOcSDtthMZhj22zLhoD8= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03M7ubID092056; Wed, 22 Apr 2020 02:56:37 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 22 Apr 2020 02:56:37 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 22 Apr 2020 02:56:37 -0500 Received: from [10.250.233.85] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03M7uYD8041618; Wed, 22 Apr 2020 02:56:35 -0500 Subject: Re: [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported To: Kunihiko Hayashi , Lorenzo Pieralisi , Bjorn Helgaas CC: , References: <1587540287-10458-1-git-send-email-hayashi.kunihiko@socionext.com> From: Kishon Vijay Abraham I Message-ID: <95116fe1-7908-1948-9f1e-bf4c8b5f2e2d@ti.com> Date: Wed, 22 Apr 2020 13:26:34 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1587540287-10458-1-git-send-email-hayashi.kunihiko@socionext.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kunihiko, On 4/22/2020 12:54 PM, Kunihiko Hayashi wrote: > When unbinding pci_epf_test, pci_epf_test_clean_dma_chan() is called in > pci_epf_test_unbind() even though epf_test->dma_supported is false. > As a result, dma_release_channel() will occur null pointer access because > dma_chan isn't set. > > This avoids calling dma_release_channel() if epf_test->dma_supported > is false. > > Fixes: a1d105d4ab8e ("PCI: endpoint: functions/pci-epf-test: Add DMA support to transfer data") > Signed-off-by: Kunihiko Hayashi Thank you for fixing this. Acked-by: Kishon Vijay Abraham I Regards Kishon > --- > drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c > index 60330f3e..c89a956 100644 > --- a/drivers/pci/endpoint/functions/pci-epf-test.c > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c > @@ -187,6 +187,9 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test) > */ > static void pci_epf_test_clean_dma_chan(struct pci_epf_test *epf_test) > { > + if (!epf_test->dma_supported) > + return; > + > dma_release_channel(epf_test->dma_chan); > epf_test->dma_chan = NULL; > } >