platform/mellanox: Check devm_hwmon_device_register_with_groups() return value
authorKunwu Chan <chentao@kylinos.cn>
Fri, 1 Dec 2023 05:54:47 +0000 (13:54 +0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 4 Dec 2023 13:01:46 +0000 (15:01 +0200)
devm_hwmon_device_register_with_groups() returns an error pointer upon
failure. Check its return value for errors.

Compile-tested only.

Fixes: 1a218d312e65 ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver")
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Suggested-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20231201055447.2356001-1-chentao@kylinos.cn
[ij: split the change into two]
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/mellanox/mlxbf-pmc.c

index d0d1cfc55c5f2c45a6a87adff7734ab136f91f57..1dd84c7a79de97f44b25c48fd241db068492b4f9 100644 (file)
@@ -2075,6 +2075,8 @@ static int mlxbf_pmc_probe(struct platform_device *pdev)
 
        pmc->hwmon_dev = devm_hwmon_device_register_with_groups(
                dev, "bfperf", pmc, pmc->groups);
+       if (IS_ERR(pmc->hwmon_dev))
+               return PTR_ERR(pmc->hwmon_dev);
        platform_set_drvdata(pdev, pmc);
 
        return 0;