platform/x86/siemens: simatic-ipc-batt: fix wrong pointer pass to PTR_ERR()
authorYang Yingliang <yangyingliang@huawei.com>
Wed, 9 Aug 2023 08:12:27 +0000 (16:12 +0800)
committerHans de Goede <hdegoede@redhat.com>
Wed, 9 Aug 2023 20:02:50 +0000 (22:02 +0200)
Fix wrong pointer pass to PTR_ERR() if devm_gpiod_get_index() fails.

Fixes: 917f54340794 ("platform/x86: simatic-ipc: add CMOS battery monitoring")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230809081227.1221267-1-yangyingliang@huawei.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/siemens/simatic-ipc-batt.c

index d66b996..15c08c4 100644 (file)
@@ -198,7 +198,7 @@ int simatic_ipc_batt_probe(struct platform_device *pdev, struct gpiod_lookup_tab
                        flags = GPIOD_OUT_LOW;
                priv.gpios[2] = devm_gpiod_get_index(dev, "CMOSBattery meter", 2, flags);
                if (IS_ERR(priv.gpios[2])) {
-                       err = PTR_ERR(priv.gpios[1]);
+                       err = PTR_ERR(priv.gpios[2]);
                        priv.gpios[2] = NULL;
                        goto out;
                }