Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3623627imu; Mon, 28 Jan 2019 08:02:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN5P3T2hGyaGsuI3swT3LhiPbZhwrKoTyQlpfkKmsoI8lO8r0O0lq0124Ku+HfxHLZlp6OhC X-Received: by 2002:a62:f54f:: with SMTP id n76mr22459458pfh.59.1548691323541; Mon, 28 Jan 2019 08:02:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691323; cv=none; d=google.com; s=arc-20160816; b=eut2AqyWVA46xhd/jJQMQhOwh+/0Y27SpJWmxEQ9HnD+DLnnJ7kdA5Kam9ZmbmheRA O070Rvp0kUN+zwQnLU71OFNWUAncEkLPZZ9paWdGMhVGoQfgSaPb2iPyvU84pW/u5sko Cnguxw/mpGxjDMciX/mkaDTEqsu0jUoyzJ4b/Pw09IVT99jZ+dPeCqwGdrf3ejUJVu34 YEsuxOCAvsE73ymmkiuLyUbKlEk1dKgKL+40agjLPjxtgYSu2KPOV87vFnGTgar9qWwE daxnegHm24AJ/8tAvhYYcSaPFWJLkirezMUWkKkfjGvzg0eaMy9okIlkKAl1aTxaU8Ff 1WgA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uwYbhc1DAGx4qzB65JAeDjuDD5LOZGgRyppvrEgYApc=; b=Lj0j2fkz2aJX4LYSrI0eTtvepCGmGBVHZfgNFYWThwtcbIDUyWbXpQ1bPMfObnDz57 vZxRORisJm5njDRwW6dWHhNOqSKdabtcECdiyyHR5txv+WkAIFkRqYl5r7Q//O2xkQVZ 1fs99T3YYv4yC+yEP4W0N/vPHgxJearPIMNcLuEt798NF7vx5JrvAz3HbSNPK433CDSP A2U2WxZTt6KDlmHj/0AoIsJCe0OvCAObdtQZW5NZLZSdLa6hOAD4MXHl+Fe120fkNFTu NY2fsUoF8kn6JglfP3sTBMMaGzvQ+Mfs6+NFmaCry4InhVWMwkU/KNU4Hm/FFDVhdUBV dtuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PO3j8j0H; 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 k64si33872380pge.7.2019.01.28.08.01.47; Mon, 28 Jan 2019 08:02:03 -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=PO3j8j0H; 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 S1730963AbfA1QBM (ORCPT + 99 others); Mon, 28 Jan 2019 11:01:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:46454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730934AbfA1QBJ (ORCPT ); Mon, 28 Jan 2019 11:01:09 -0500 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 59A2B21848; Mon, 28 Jan 2019 16:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691268; bh=SfeZGNBJC8y7PsT3PChTE0GMximgE5+qk8Jer44np60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PO3j8j0H90fDuR7PMDDK+ckJuLD4jDn1HxMgR+zF2MG+t1qrpHli2Akm3mqFU6PM5 EAsdwEBhLzXUr5xrhPwJkG7puCoUDvfmrCWEhV4wU2QSFiqLN9rB38UyOS6LLMo7+q vj3MTZx7E2zR4VEODxtOWeNdEocgxSWaGMBpzmL8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anatolij Gustschin , Greg Kroah-Hartman , Sasha Levin , linux-fpga@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 039/258] fpga: altera-cvp: fix 'bad IO access' on x86_64 Date: Mon, 28 Jan 2019 10:55:45 -0500 Message-Id: <20190128155924.51521-39-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anatolij Gustschin [ Upstream commit 187fade88ca0ff2df9d360ca751d948d73db7095 ] If mapping the CvP BAR fails, we still can configure the FPGA via PCI config space access. In this case the iomap pointer is NULL. On x86_64, passing NULL address to pci_iounmap() generates "Bad IO access at port 0x0" output with stack call trace. Fix it. Signed-off-by: Anatolij Gustschin Acked-by: Alan Tull Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/fpga/altera-cvp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index 1f4c26b4794a..7a42c194b944 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c @@ -480,7 +480,8 @@ static int altera_cvp_probe(struct pci_dev *pdev, return 0; err_unmap: - pci_iounmap(pdev, conf->map); + if (conf->map) + pci_iounmap(pdev, conf->map); pci_release_region(pdev, CVP_BAR); err_disable: cmd &= ~PCI_COMMAND_MEMORY; @@ -495,7 +496,8 @@ static void altera_cvp_remove(struct pci_dev *pdev) u16 cmd; fpga_mgr_unregister(mgr); - pci_iounmap(pdev, conf->map); + if (conf->map) + pci_iounmap(pdev, conf->map); pci_release_region(pdev, CVP_BAR); pci_read_config_word(pdev, PCI_COMMAND, &cmd); cmd &= ~PCI_COMMAND_MEMORY; -- 2.19.1