2021-10-08 07:49:51

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next] xen-pciback: Fix return in pm_ctrl_init()

Return NULL instead of passing to ERR_PTR while err is zero,
this fix smatch warnings:
drivers/xen/xen-pciback/conf_space_capability.c:163
pm_ctrl_init() warn: passing zero to 'ERR_PTR'

Fixes: a92336a1176b ("xen/pciback: Drop two backends, squash and cleanup some code.")
Signed-off-by: YueHaibing <[email protected]>
---
drivers/xen/xen-pciback/conf_space_capability.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/xen-pciback/conf_space_capability.c b/drivers/xen/xen-pciback/conf_space_capability.c
index 22f13abbe913..5e53b4817f16 100644
--- a/drivers/xen/xen-pciback/conf_space_capability.c
+++ b/drivers/xen/xen-pciback/conf_space_capability.c
@@ -160,7 +160,7 @@ static void *pm_ctrl_init(struct pci_dev *dev, int offset)
}

out:
- return ERR_PTR(err);
+ return err ? ERR_PTR(err) : NULL;
}

static const struct config_field caplist_pm[] = {
--
2.17.1


2021-10-08 15:04:02

by Jürgen Groß

[permalink] [raw]
Subject: Re: [PATCH -next] xen-pciback: Fix return in pm_ctrl_init()

On 08.10.21 09:44, YueHaibing wrote:
> Return NULL instead of passing to ERR_PTR while err is zero,
> this fix smatch warnings:
> drivers/xen/xen-pciback/conf_space_capability.c:163
> pm_ctrl_init() warn: passing zero to 'ERR_PTR'
>
> Fixes: a92336a1176b ("xen/pciback: Drop two backends, squash and cleanup some code.")
> Signed-off-by: YueHaibing <[email protected]>

Reviewed-by: Juergen Gross <[email protected]>


Juergen


Attachments:
OpenPGP_0xB0DE9DD628BF132F.asc (3.06 kB)
OpenPGP public key
OpenPGP_signature (505.00 B)
OpenPGP digital signature
Download all attachments

2021-10-27 21:26:15

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH -next] xen-pciback: Fix return in pm_ctrl_init()


On 10/8/21 11:01 AM, Juergen Gross wrote:
> On 08.10.21 09:44, YueHaibing wrote:
>> Return NULL instead of passing to ERR_PTR while err is zero,
>> this fix smatch warnings:
>> drivers/xen/xen-pciback/conf_space_capability.c:163
>>   pm_ctrl_init() warn: passing zero to 'ERR_PTR'
>>
>> Fixes: a92336a1176b ("xen/pciback: Drop two backends, squash and cleanup some code.")
>> Signed-off-by: YueHaibing <[email protected]>
>
> Reviewed-by: Juergen Gross <[email protected]>
>


Applied to for-linux-5.16.


-boris