i2c: designware: Fix return value check in navi_amd_register_client()
authorWei Yongjun <weiyongjun1@huawei.com>
Wed, 7 Apr 2021 03:11:37 +0000 (03:11 +0000)
committerWolfram Sang <wsa@kernel.org>
Thu, 8 Apr 2021 20:47:48 +0000 (22:47 +0200)
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().

Fixes: 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-designware-pcidrv.c

index 7ca0017..0f409a4 100644 (file)
@@ -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;
 }