Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2468415pxb; Mon, 19 Apr 2021 06:30:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIEXoj1m9THvDrIqScOL1k//F3Wm0qlwaGgHoMxyxzDqD8nkK++zaISNkh5CTo+AjVsSMK X-Received: by 2002:a17:907:6192:: with SMTP id mt18mr22571188ejc.530.1618839034376; Mon, 19 Apr 2021 06:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618839034; cv=none; d=google.com; s=arc-20160816; b=wWPrtELz3E3Gl9tlc9ha2hGhWPkL5N5p5llVgen4VNM3zmvY2gInLZXcFiG1gqpLXs C9nD8JfM0LFJIGP4uwjIxvaYS33mwyow1pocCvLeC57wlSAMjUT2frNV+k4QRBO5CvX2 fSe4VTTIoehzbLnCvl2jW8cxDw+bVZIntEGp4y48fvb9ZQSOrScKjeAWm/NUx2YN6xO+ NB100cMkkQFC6o5q13bMrpFG99yOyIJgtN9aJWcdZ1JKNI4PnS3ugKeZhJeRgKNL82zh shBXdS+3n5k5WAnCV3xMn5rsDXSO8m3mlYDFYXkIxrb9hcJR32KSKFWPnlXaoFS6ERu6 yd2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RW2H5XIPY6QsH7gM+Z0AnWNbza6KDYPFp5A3VyD9w6w=; b=f/PZVEgjmpbJ8GuXQyxUUM+TtbXoHEv4qHMByINjocdv6H8M1hpjWFoErkQAuRidMj b0F5F7xcQhmTr98TgiV5Tk1JYBlk/Isi2od80Cz/xTm0BJuchQVGuvXdruXjHkHjcNAg aIzWS41oRt4Ah9F6zetHhxoWHxzROhYbVcoceo+7Zwcwbq+ACkNzNP4hcKVCmcdSE//c zklRfHEbzAlUcW5kmvH7c92kw1MiMpHQohFC4I1GLmHDSStbYOl4KSTb9nzM1cMNGE5t tfQ4aZ0EnSY7BoYHRfR3uhDM2RxAlurY/PYmxkucXf8BHN2qmtWyv2FiC92+fzpdnOX6 AixA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o9i5zgho; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si7427905edc.63.2021.04.19.06.30.09; Mon, 19 Apr 2021 06:30:34 -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=@linuxfoundation.org header.s=korg header.b=o9i5zgho; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242289AbhDSN1D (ORCPT + 99 others); Mon, 19 Apr 2021 09:27:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241302AbhDSNUZ (ORCPT ); Mon, 19 Apr 2021 09:20:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C5C66613E4; Mon, 19 Apr 2021 13:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838171; bh=h/oMOtZ4b3Lu1QUgWmshCmfFJ+JNBlKbRPav86MrSsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o9i5zghoLaS0xhx9HtKU3ixt+wItPzFOXWfnEhfUO9tk4vJ/3ZFZemYr/lfgg8RKT wc0t3CMP3GEuCXiwxPv2ZxArBFNUtaL8f6dkPcI4bz9mHFxdq1UAUyjLfxlJ5DxAWm pOOrdhr/9VYtdXhHWXfUJi/q3enPbj898w3F5BIE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 041/103] pcnet32: Use pci_resource_len to validate PCI resource Date: Mon, 19 Apr 2021 15:05:52 +0200 Message-Id: <20210419130529.211334512@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130527.791982064@linuxfoundation.org> References: <20210419130527.791982064@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guenter Roeck [ Upstream commit 66c3f05ddc538ee796321210c906b6ae6fc0792a ] pci_resource_start() is not a good indicator to determine if a PCI resource exists or not, since the resource may start at address 0. This is seen when trying to instantiate the driver in qemu for riscv32 or riscv64. pci 0000:00:01.0: reg 0x10: [io 0x0000-0x001f] pci 0000:00:01.0: reg 0x14: [mem 0x00000000-0x0000001f] ... pcnet32: card has no PCI IO resources, aborting Use pci_resouce_len() instead. Signed-off-by: Guenter Roeck Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/amd/pcnet32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c index 187b0b9a6e1d..f78daba60b35 100644 --- a/drivers/net/ethernet/amd/pcnet32.c +++ b/drivers/net/ethernet/amd/pcnet32.c @@ -1534,8 +1534,7 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent) } pci_set_master(pdev); - ioaddr = pci_resource_start(pdev, 0); - if (!ioaddr) { + if (!pci_resource_len(pdev, 0)) { if (pcnet32_debug & NETIF_MSG_PROBE) pr_err("card has no PCI IO resources, aborting\n"); err = -ENODEV; @@ -1548,6 +1547,8 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent) pr_err("architecture does not support 32bit PCI busmaster DMA\n"); goto err_disable_dev; } + + ioaddr = pci_resource_start(pdev, 0); if (!request_region(ioaddr, PCNET32_TOTAL_SIZE, "pcnet32_probe_pci")) { if (pcnet32_debug & NETIF_MSG_PROBE) pr_err("io address range already allocated\n"); -- 2.30.2