2020-07-13 03:36:19

by Xu Wang

[permalink] [raw]
Subject: [PATCH] fsi: fsi-occ: fix return value check in occ_probe()

In case of error, the function platform_device_register_full()
returns ERR_PTR() and never returns NULL. The NULL test in the
return value check should be replaced with IS_ERR().

Signed-off-by: Xu Wang <[email protected]>
---
drivers/fsi/fsi-occ.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
index 7da9c81759ac..9eeb856c8905 100644
--- a/drivers/fsi/fsi-occ.c
+++ b/drivers/fsi/fsi-occ.c
@@ -555,7 +555,7 @@ static int occ_probe(struct platform_device *pdev)

hwmon_dev_info.id = occ->idx;
hwmon_dev = platform_device_register_full(&hwmon_dev_info);
- if (!hwmon_dev)
+ if (IS_ERR(hwmon_dev))
dev_warn(dev, "failed to create hwmon device\n");

return 0;
--
2.17.1


2020-07-13 14:24:48

by Eddie James

[permalink] [raw]
Subject: Re: [PATCH] fsi: fsi-occ: fix return value check in occ_probe()


On 7/12/20 10:33 PM, Xu Wang wrote:
> In case of error, the function platform_device_register_full()
> returns ERR_PTR() and never returns NULL. The NULL test in the
> return value check should be replaced with IS_ERR().


Thanks,

Reviewed-by: Eddie James <[email protected]>


>
> Signed-off-by: Xu Wang <[email protected]>
> ---
> drivers/fsi/fsi-occ.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
> index 7da9c81759ac..9eeb856c8905 100644
> --- a/drivers/fsi/fsi-occ.c
> +++ b/drivers/fsi/fsi-occ.c
> @@ -555,7 +555,7 @@ static int occ_probe(struct platform_device *pdev)
>
> hwmon_dev_info.id = occ->idx;
> hwmon_dev = platform_device_register_full(&hwmon_dev_info);
> - if (!hwmon_dev)
> + if (IS_ERR(hwmon_dev))
> dev_warn(dev, "failed to create hwmon device\n");
>
> return 0;

2020-07-20 14:47:51

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH] fsi: fsi-occ: fix return value check in occ_probe()

On 7/12/20 8:33 PM, Xu Wang wrote:
> In case of error, the function platform_device_register_full()
> returns ERR_PTR() and never returns NULL. The NULL test in the
> return value check should be replaced with IS_ERR().
>
> Signed-off-by: Xu Wang <[email protected]>

Reviewed-by: Guenter Roeck <[email protected]>

> ---
> drivers/fsi/fsi-occ.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
> index 7da9c81759ac..9eeb856c8905 100644
> --- a/drivers/fsi/fsi-occ.c
> +++ b/drivers/fsi/fsi-occ.c
> @@ -555,7 +555,7 @@ static int occ_probe(struct platform_device *pdev)
>
> hwmon_dev_info.id = occ->idx;
> hwmon_dev = platform_device_register_full(&hwmon_dev_info);
> - if (!hwmon_dev)
> + if (IS_ERR(hwmon_dev))
> dev_warn(dev, "failed to create hwmon device\n");
>
> return 0;
>