Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5121546ybe; Tue, 17 Sep 2019 03:01:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwI4xgU+Ijp+aHIWK4rtuNfwZ9A+WBhZ8YM7krYfjbcVHkirSv1LthPpY2UAGFkNHS0dQW8 X-Received: by 2002:a17:906:ecea:: with SMTP id qt10mr3992961ejb.23.1568714504177; Tue, 17 Sep 2019 03:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568714504; cv=none; d=google.com; s=arc-20160816; b=indq/a719dIDaLhofacWR34C07TJ90Eh2fDT3AYdMNWDPt18AaPYJOhrGlLMoIJsDm X6pfSoW+oZ+k7fHnGL0Cvy2xtLUNv7tq2G8nnsxwTdiVYgeFTKA8dpHO8N1/tjHzZAVr oyC5AWHPXxOK3ZbFJ0SOCMJLZB27ExfjlEoiaP6v5Nj3V6t54nfldJe2ZcZYeezAdzPs X7UXaZDdungIA5wUzg+DcpDUkPRuigQEfB+CS074gkWcoyUTQSU/jacSUcFvnoSbUJfH AVkZEwFHIaRRjNBtfURzE6By08TNzQks9DZzeWEvfd8zdDzczEwoHlbzN+H9ml2jkUKR VKRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GuVy/dTL0zVi8KB992cYfUvwyuZX5WJTHthmI6rNOT0=; b=EWMp7XmIIvD0Onmvr2O+opTiI9wGY4ethPvNDbAMrAXLIobmU0Xdmhr8UZCp2zkIyg fT5KSdtrClGacwLyvg5WFVMB6akqVUAEF6BBXK30F8ZuXHhC6oHZOFWPZ8zABYB6Ks9L vJ/eexZdo4KRhBR2mTIPdiplLLUwXMpqqt2ysC6zsmTUR1TwjEfpe8w5Tznxew4ZXkvh 5RF9ZUMdqSYYjGsnN1HUMgfin6apwuoW0f8DNuSsoF4bPQD4WCaLGmMPGVX6fNfOYdFu rXehIlSBPjSz5n0wMc274qBnz9hBBJa/hIzmuoigMkPB+0Xvc1mWm4x8DDDUulaj9bh/ Q58g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bg7owd06; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c31si1054267edb.309.2019.09.17.03.01.20; Tue, 17 Sep 2019 03:01:44 -0700 (PDT) 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=@linaro.org header.s=google header.b=Bg7owd06; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727112AbfIQJX1 (ORCPT + 99 others); Tue, 17 Sep 2019 05:23:27 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44177 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbfIQJX0 (ORCPT ); Tue, 17 Sep 2019 05:23:26 -0400 Received: by mail-lf1-f68.google.com with SMTP id q11so2260319lfc.11 for ; Tue, 17 Sep 2019 02:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GuVy/dTL0zVi8KB992cYfUvwyuZX5WJTHthmI6rNOT0=; b=Bg7owd06h9hLmdCxdxpcsTn4LUAfPv+Fcad1/azM2mPLlkqQ4BA424Bz+zbIl7/0Hs eKql7oCqUtjwx6PXZjoG/nwv5HrreuTAcvZ22zX5/ZSYJ3TM5Rinqf7M8W82SSWcvMWg YSLh9gDvs6Mqwvm5x9/8dVcbnvYrMQ/KeSV3CfLkQVfLHExiI3Dhk7e7l6N5u2Lz2//t 7q9JTi9j2t3cIjkWN+E3eFFZgLeB1Z94tulowjh6MTjXFfEIUDCNsqWeDKB8Or4vFAv2 0dohKXmgO1WZpJVIDpYo839ISYtq/0s54FIlTR+binuYt/vRVT5HXVG0FRBUr7DAK/JI IASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GuVy/dTL0zVi8KB992cYfUvwyuZX5WJTHthmI6rNOT0=; b=HEnHr4uRSG6t85z/X6FzXl1fHITewMiA8Jysefi64EQ17k4MLs/7y19O1fk3KORzl9 ViQ6FNR8IJYe8xsqdqTONYZ+bFFE9EVRDgGX5XViZWOe/2aH3oW6lPHlgKwzZeLAz0FS GPm2qsk2huvI9Aq6K/B4ccmfdEh09avBt8ToYeCDZfVqUhVRO86TYDs+tjruvhaGn597 wS7NuKlBJVJFuBBhgOlPXjQDYMrEnUqFRW9ymOilTkwR1vFLCTyg5wZTRUPOWV5ADlIi nwZyrkd/lfsK0UWYghg/5OzO8D54dc8o3jsOh0TORTS7jPwb/xvpnOlOD6b4bAEQcr/L dUHg== X-Gm-Message-State: APjAAAXml1iwqT5ECATXGOV/4sxmUcS3tpoqLEWAooMnKCOIGj0PHybq Qx8fiVM6KC4RaTZEn3orukTIPEHA8HPKuv4f48sdKA== X-Received: by 2002:a19:3f47:: with SMTP id m68mr1524926lfa.108.1568712205010; Tue, 17 Sep 2019 02:23:25 -0700 (PDT) MIME-Version: 1.0 References: <20190917085627.4562-1-mail@aurabindo.in> In-Reply-To: <20190917085627.4562-1-mail@aurabindo.in> From: Baolin Wang Date: Tue, 17 Sep 2019 17:23:13 +0800 Message-ID: Subject: Re: [PATCH] spi: sifive: check return value for platform_get_resource() To: Aurabindo Jayamohanan Cc: Mark Brown , palmer@sifive.com, paul.walmsley@sifive.com, linux-spi , linux-riscv@lists.infradead.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Sep 2019 at 17:12, Aurabindo Jayamohanan wrote: > > platform_get_resource() may return NULL. If it is so, return -ENXIO > > Signed-off-by: Aurabindo Jayamohanan > --- > drivers/spi/spi-sifive.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c > index 93ec2c6cdbfd..67485067a694 100644 > --- a/drivers/spi/spi-sifive.c > +++ b/drivers/spi/spi-sifive.c > @@ -308,6 +308,12 @@ static int sifive_spi_probe(struct platform_device *pdev) > platform_set_drvdata(pdev, master); > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + if (!res) { > + dev_err(&pdev->dev, "no IOMEM resource found\n"); > + ret = -ENXIO; > + goto put_master; > + } Seems unnecessary, the devm_ioremap_resource() already validated if the resource is available. -- Baolin Wang Best Regards