Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dan.carpenter@oracle.com>
Acked-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20211110074346.GB5176@kili
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Dan Carpenter and committed by
Hans de Goede
287273a8 fa55b7dc

+3 -2
+3 -2
drivers/platform/mellanox/mlxreg-lc.c
··· 413 413 int size) 414 414 { 415 415 struct mlxreg_hotplug_device *dev = devs; 416 - int i; 416 + int i, ret; 417 417 418 418 /* Create static I2C device feeding by auxiliary or main power. */ 419 419 for (i = 0; i < size; i++, dev++) { ··· 423 423 dev->brdinfo->type, dev->nr, dev->brdinfo->addr); 424 424 425 425 dev->adapter = NULL; 426 + ret = PTR_ERR(dev->client); 426 427 goto fail_create_static_devices; 427 428 } 428 429 } ··· 436 435 i2c_unregister_device(dev->client); 437 436 dev->client = NULL; 438 437 } 439 - return IS_ERR(dev->client); 438 + return ret; 440 439 } 441 440 442 441 static void