From patchwork Tue Jun 23 19:50:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 191532 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp2288856ile; Tue, 23 Jun 2020 13:01:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw8JdiI+YIf+EzXt856sofF0/MBMtN3rHQEAdumR1LbarTSoLeEwL5U+pRQsCdHT2iqVe3 X-Received: by 2002:a50:8143:: with SMTP id 61mr7664644edc.202.1592942517175; Tue, 23 Jun 2020 13:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592942517; cv=none; d=google.com; s=arc-20160816; b=jxz9UE3ojgoy9aJawWkAKsJP8Sa9DjV2Y1JsQRnk90kRtCHJRjGHgn1X0LuGHJg/xB RRlE5LgKRQDZ1MqM4dCiVvXHLvqGBh10zoaNBMIWOred2AQ6d1ZDjWOL5DExzK55TcOL k7T5HSNpPfkuR3yoefiW0JR7EhiGVGPn5ImFXNbH7iiRArTeO+dGJlxWpG2aTyCIUXYW pXDVzevn3v7rn1DskT4ee6jxQj4zx7T7zJtf4Yz4sMN1iHaPs8zUAAScXxdrRWjlPuZt UWZBHmcKP4jmwLejMQ/XUdEqkOB/B1y5Zaicb9DiQy0hjNtD5R57fqcFzqVSeswtqhNq fppA== 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=ouImxZYzK9kxKFRlj+w2nCLpn3WsdyTWDydWJHhX0J8=; b=JDJVUWBO/jcYO5mcYCGzaWIlWTLrBGe1US7OueCfyQt1Qqi6lua5DztMVDtq2FNnv2 tEKcuJNQ4AGY1eLPNWkmwcm22SpZYLu/nAx+GuPeuz1w6StKinfK/YbGMuIfqn1LVSKZ HlZCzH3ceZLumyoxdvnRcdnh1wO8p2KkM01umaZDrZmpKDa/QM0+3O4QPz5TBct1tucp WoEUU/c2M8k5Ltox8bLyEfEjPLRDeWcvUakQQeizEx3qpKTaXmIrXjJajzbUN6eS5ILX W3h4ydp68AwmdI0WSji6QDxZvj5NaTnkrPrAKLDVhW4sn1zCOHBMHW68Z1czgzX89mn2 AROg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HAZLwo6H; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 b23si3777014ejb.465.2020.06.23.13.01.57; Tue, 23 Jun 2020 13:01:57 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=HAZLwo6H; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387719AbgFWUBy (ORCPT + 15 others); Tue, 23 Jun 2020 16:01:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:38764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387714AbgFWUBw (ORCPT ); Tue, 23 Jun 2020 16:01:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 92D0A2078A; Tue, 23 Jun 2020 20:01:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592942512; bh=IJOs31q3U0GUA/Gt9yQ3tZenC2Ks1uwhy0P91NDVngA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HAZLwo6HbmiQ31pDlbWA2fsRZRi+opLWnwyZnWrz7Doa90CFKNK37gIwc6JsseJ/H lj1yl3kuPla9KQHUdEWC3Ze9NZ6Vz5yd6V6CZC5h7LfBbVBoaMtnjNemguY+XXR+6z Nk+AiKeZpYUPARpTGVaXTWR6FVx8FNJObjVL4TB4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kunihiko Hayashi , Lorenzo Pieralisi , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 5.7 027/477] PCI: endpoint: functions/pci-epf-test: Fix DMA channel release Date: Tue, 23 Jun 2020 21:50:24 +0200 Message-Id: <20200623195408.891413807@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195407.572062007@linuxfoundation.org> References: <20200623195407.572062007@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Kunihiko Hayashi [ Upstream commit 0e86d981f9b7252e9716c5137cd8e4d9ad8ef32f ] 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 trigger a NULL pointer dereference because dma_chan is not set. Avoid calling dma_release_channel() if epf_test->dma_supported is false. Link: https://lore.kernel.org/r/1587540287-10458-1-git-send-email-hayashi.kunihiko@socionext.com Fixes: 5ebf3fc59bd2 ("PCI: endpoint: functions/pci-epf-test: Add DMA support to transfer data") Signed-off-by: Kunihiko Hayashi [lorenzo.pieralisi@arm.com: commit log] Signed-off-by: Lorenzo Pieralisi Acked-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin --- drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 60330f3e37516..c89a9561439f9 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; }