lkml.org 
[lkml]   [2020]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 1/2] clk: hisilicon: Use correct return value about hisi_reset_init()
From
Date
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>
>> ---
>>

\
 
 \ /
  Last update: 2020-05-28 04:28    [W:0.113 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site