]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
platform/mellanox: mlxreg-hotplug: Add check for negative adapter number
authorVadim Pasternak <vadimp@mellanox.com>
Fri, 26 Jan 2018 19:03:45 +0000 (19:03 +0000)
committerDarren Hart (VMware) <dvhart@infradead.org>
Wed, 31 Jan 2018 18:36:50 +0000 (10:36 -0800)
Verify before creation of hotplug device if the associated adapter number
is negative. It could be in case hotplug event is not associated with
hotplug device.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
drivers/platform/mellanox/mlxreg-hotplug.c

index bcb564fd9f046a99d4a8ce39a42dc79dbcaa7edf..0dfa1ca0d05b02179a45b0590ea7b809cfceab45 100644 (file)
@@ -96,6 +96,13 @@ struct mlxreg_hotplug_priv_data {
 static int mlxreg_hotplug_device_create(struct device *dev,
                                        struct mlxreg_core_data *data)
 {
+       /*
+        * Return if adapter number is negative. It could be in case hotplug
+        * event is not associated with hotplug device.
+        */
+       if (data->hpdev.nr < 0)
+               return 0;
+
        data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr);
        if (!data->hpdev.adapter) {
                dev_err(dev, "Failed to get adapter for bus %d\n",