From: Dan Carpenter Date: Wed, 10 Nov 2021 07:43:46 +0000 (+0300) Subject: platform/mellanox: mlxreg-lc: fix error code in mlxreg_lc_create_static_devices() X-Git-Tag: v6.6.17~8471^2~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=287273a80be5d45d59d1742557cab69cabf0ef3c;p=platform%2Fkernel%2Flinux-rpi.git platform/mellanox: mlxreg-lc: fix error code in mlxreg_lc_create_static_devices() This code should be using PTR_ERR() instead of IS_ERR(). And because it's using the wrong "dev->client" pointer, the IS_ERR() check will be false, meaning the function returns success. Fixes: 62f9529b8d5c ("platform/mellanox: mlxreg-lc: Add initial support for Nvidia line card devices") Signed-off-by: Dan Carpenter Acked-by: Vadim Pasternak Link: https://lore.kernel.org/r/20211110074346.GB5176@kili Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- diff --git a/drivers/platform/mellanox/mlxreg-lc.c b/drivers/platform/mellanox/mlxreg-lc.c index 0b7f58f..c897a2f 100644 --- a/drivers/platform/mellanox/mlxreg-lc.c +++ b/drivers/platform/mellanox/mlxreg-lc.c @@ -413,7 +413,7 @@ mlxreg_lc_create_static_devices(struct mlxreg_lc *mlxreg_lc, struct mlxreg_hotpl int size) { struct mlxreg_hotplug_device *dev = devs; - int i; + int i, ret; /* Create static I2C device feeding by auxiliary or main power. */ for (i = 0; i < size; i++, dev++) { @@ -423,6 +423,7 @@ mlxreg_lc_create_static_devices(struct mlxreg_lc *mlxreg_lc, struct mlxreg_hotpl dev->brdinfo->type, dev->nr, dev->brdinfo->addr); dev->adapter = NULL; + ret = PTR_ERR(dev->client); goto fail_create_static_devices; } } @@ -435,7 +436,7 @@ fail_create_static_devices: i2c_unregister_device(dev->client); dev->client = NULL; } - return IS_ERR(dev->client); + return ret; } static void