i2c: designware: Fix return value check in navi_amd_register_client()
Subsystems (4)
PATCH v2 1/1 i2c: designware: Fix return value check in navi_amd_register_client()
In case of error, the function i2c_new_client_device() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().
---
v1 -> v2: fix description format.
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +2 -2
@@ -132,8 +132,8 @@ static int navi_amd_register_client(struct dw_i2c_dev *dev) info.irq = dev->irq; dev->slave =i2c_new_client_device (&dev->adapter, &info); -if (!dev->slave) -return -ENODEV ; +if (IS_ERR (dev->slave)) +return PTR_ERR (dev->slave);return 0 ; }
Quoted 18 lines · Wei Yongjun
In case of error, the function
i2c_new_client_device()returnsERR_PTR()and never returns NULL. The NULL test in the return value check should be replaced withIS_ERR().Fixes 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU")Reported-by Hulk Robot <[email protected]>Signed-off-by Wei Yongjun <[email protected]>---
v1 -> v2: fix description format.--- drivers/i2c/busses/i2c-designware-pcidrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-designware-pcidrv.c +0
-0
drivers/i2c/busses/i2c-designware-pcidrv.c static int navi_amd_register_client(struct dw_i2c_dev *dev) · line 137
Quoted 8 lines
drivers/i2c/busses/i2c-designware-pcidrv.c +2
-2@@ -132,8 +132,8 @@ static int navi_amd_register_client(struct dw_i2c_dev *dev) info.irq = dev->irq; dev->slave =i2c_new_client_device (&dev->adapter, &info); -if (!dev->slave) -return -ENODEV ; +if (IS_ERR (dev->slave)) +return PTR_ERR (dev->slave);
Hi Wei,
Quoted 20 lines · Wei Yongjun
[CAUTION: External Email]
In case of error, the function
i2c_new_client_device()returnsERR_PTR()and never returns NULL. The NULL test in the return value check should be replaced withIS_ERR().Fixes 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU")Reported-by Hulk Robot <[email protected]>Signed-off-by Wei Yongjun <[email protected]>---
v1 -> v2: fix description format.--- drivers/i2c/busses/i2c-designware-pcidrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-designware-pcidrv.c +0
-0
drivers/i2c/busses/i2c-designware-pcidrv.c static int navi_amd_register_client(struct dw_i2c_dev *dev) · line 136
Quoted 7 lines
drivers/i2c/busses/i2c-designware-pcidrv.c +2
-2@@ -132,8 +132,8 @@ static int navi_amd_register_client(struct dw_i2c_dev *dev) info.irq = dev->irq; dev->slave =i2c_new_client_device (&dev->adapter, &info); -if (!dev->slave) -return -ENODEV ; +if (IS_ERR (dev->slave)) +return PTR_ERR (dev->slave);
I got your point, applying mentioned change in my patch.
drivers/i2c/busses/i2c-designware-pcidrv.c static int navi_amd_register_client(struct dw_i2c_dev *dev)
Quoted 4 lines
drivers/i2c/busses/i2c-designware-pcidrv.c +0
-0return 0 ; }
Thanks,
Sanket
Wolfram Sang
AppliedQuoted 7 lines · Wei Yongjun
In case of error, the function
i2c_new_client_device()returnsERR_PTR()and never returns NULL. The NULL test in the return value check should be replaced withIS_ERR().Fixes 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU")Reported-by Hulk Robot <[email protected]>Signed-off-by Wei Yongjun <[email protected]>
Applied to for-next, thanks!