Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp417617ybz; Wed, 22 Apr 2020 00:26:42 -0700 (PDT) X-Google-Smtp-Source: APiQypLZh6tjWpPvub4XnH0E9wPIhD05Wm7ysH8zEmMbdzzVcuWKo/11CzjDLeHl4Y/jAy144ni0 X-Received: by 2002:a17:907:7211:: with SMTP id dr17mr6507827ejc.296.1587540402487; Wed, 22 Apr 2020 00:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587540402; cv=none; d=google.com; s=arc-20160816; b=Cd23WxeUVryLTS1G84DsosjOm6GHuQxgOh8II6zu71BIKlf/JV4zYxqVfQKpBIUbM1 MFg2EharjFPxq+jbxPPKW1zj+mpbagzte/iouAG8vLdXFyxGF5Gtcf+np/F28wloEkcE uX8ENT+oGGKIECWvrj6dSNjgV2vm6FmH9iT8DHYAbnC60QkEbxXvyKHxuxwKJ33fHzWR U/P5+9WyU4t37pfTyqZIkRwdq0Oij2EQXxUSXVc1V+/venRvyZQw4/+kdDl+PdHzZEDz YI3q7oqx4X/OXIpQ1bb+IFmZIWhrYB9IkUCXqh2HVAMeOjEZSY7sdx1vHs3q9VNISNW/ EmNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=YUkmRxncS2LsfYptHFSy5QKGz1Ji3Q/HjnHhejCckQI=; b=XPeKnUwne8lgXxYOwvkWcxL5m8oL7AAY4vGAJLm0UQys7FdjPzoXEzMX4dSCD4abMW 0bufMWJFyc+EnLY7MOqF6L5ZYSujdiWn3EEfmxPgFTFABH/qiGRSXR5DCkL9AEs94hU6 P2xz0FAhW4AVOy2klUMPUDErf5KKkfzx5ZCdrzW33Vn1mMAW2hJO6dVmpR1MTfD6yvHd ejo821lluIetDSl4NRz0ej7Q2AhES5JSq5gR5OlaWBHxPEXmK9O4qzS05vT1Fj9aWMJH +MXPiXy4ah7c3eb323la5yk/5iR9TeVPgidexFN4YYOv+66aLeOSShxOub3v0DKj+zz2 8kng== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f3si2850438edn.165.2020.04.22.00.26.19; Wed, 22 Apr 2020 00:26:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726041AbgDVHZI (ORCPT + 99 others); Wed, 22 Apr 2020 03:25:08 -0400 Received: from mx.socionext.com ([202.248.49.38]:11042 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbgDVHZI (ORCPT ); Wed, 22 Apr 2020 03:25:08 -0400 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 22 Apr 2020 16:25:06 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id C64DD60057; Wed, 22 Apr 2020 16:25:06 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Wed, 22 Apr 2020 16:25:06 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 30EE51A12D0; Wed, 22 Apr 2020 16:25:06 +0900 (JST) From: Kunihiko Hayashi To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH v2] PCI: endpoint: functions/pci-epf-test: Avoid DMA release when DMA is unsupported Date: Wed, 22 Apr 2020 16:24:47 +0900 Message-Id: <1587540287-10458-1-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.7.4