linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Stephen Boyd <sboyd@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	Xuefeng Li <lixuefeng@loongson.cn>
Subject: Re: [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
Date: Thu, 28 May 2020 10:27:42 +0800	[thread overview]
Message-ID: <51c21311-a301-1a55-3eb1-a11583e7df43@loongson.cn> (raw)
In-Reply-To: <159060638492.88029.3855641102752089121@swboyd.mtv.corp.google.com>

On 05/28/2020 03:06 AM, Stephen Boyd wrote:
> Quoting Tiezhu Yang (2020-05-27 07:39:21)
>> The return value about hisi_reset_init() is not correct, fix it.
>>
>> Fixes: e9a2310fb689 ("reset: hisilicon: fix potential NULL pointer dereference")
> hisi_reset_init() returns NULL on error in that commit. This patch
> doesn't make sense.

Hi Stephen,

The initial aim of this patch is to use correct return value about
hisi_reset_init(), maybe NULL is OK, but the return value in this
patch is more accurate.

In the current code, it always returns -ENOMEM when call function
hisi_reset_init() failed which is not proper, because in the function
hisi_reset_init(), devm_platform_ioremap_resource() may returns -EINVAL,
-EBUSY or -ENOMEM if failed.

devm_platform_ioremap_resource()
         devm_ioremap_resource()
                 __devm_ioremap_resource()


static void __iomem *
__devm_ioremap_resource(struct device *dev, const struct resource *res,
             enum devm_ioremap_type type)
{
     resource_size_t size;
     void __iomem *dest_ptr;

     BUG_ON(!dev);

     if (!res || resource_type(res) != IORESOURCE_MEM) {
         dev_err(dev, "invalid resource\n");
         return IOMEM_ERR_PTR(-EINVAL);
     }

     size = resource_size(res);

     if (!devm_request_mem_region(dev, res->start, size, dev_name(dev))) {
         dev_err(dev, "can't request region for resource %pR\n", res);
         return IOMEM_ERR_PTR(-EBUSY);
     }

     dest_ptr = __devm_ioremap(dev, res->start, size, type);
     if (!dest_ptr) {
         dev_err(dev, "ioremap failed for resource %pR\n", res);
         devm_release_mem_region(dev, res->start, size);
         dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
     }

     return dest_ptr;
}

Thanks,
Tiezhu Yang

>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>>


  reply	other threads:[~2020-05-28  2:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 14:39 [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init() Tiezhu Yang
2020-05-27 14:39 ` [PATCH v4 2/2] clk: Allow COMPILE_TEST for subdir hisilicon in Makefile Tiezhu Yang
2020-05-31 21:05   ` kbuild test robot
2020-06-02  1:43     ` Tiezhu Yang
2020-05-27 19:06 ` [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init() Stephen Boyd
2020-05-28  2:27   ` Tiezhu Yang [this message]
2020-05-28 23:15     ` Stephen Boyd
2020-05-29  2:03       ` Tiezhu Yang
2020-05-29  3:58         ` Stephen Boyd
2020-05-29  4:02           ` Tiezhu Yang
2020-05-29  4:31             ` Stephen Boyd
2020-05-29  6:44               ` Tiezhu Yang
2020-05-29  9:36                 ` Stephen Boyd
2020-05-29 10:20                   ` Tiezhu Yang
2020-05-29 21:14                     ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51c21311-a301-1a55-3eb1-a11583e7df43@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).