Browse Source

platform/mellanox: mlxreg-hotplug: Add check for negative adapter number

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>
Vadim Pasternak 7 years ago
parent
commit
7805fa8d78
1 changed files with 7 additions and 0 deletions
  1. 7 0
      drivers/platform/mellanox/mlxreg-hotplug.c

+ 7 - 0
drivers/platform/mellanox/mlxreg-hotplug.c

@@ -96,6 +96,13 @@ struct mlxreg_hotplug_priv_data {
 static int mlxreg_hotplug_device_create(struct device *dev,
 static int mlxreg_hotplug_device_create(struct device *dev,
 					struct mlxreg_core_data *data)
 					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);
 	data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr);
 	if (!data->hpdev.adapter) {
 	if (!data->hpdev.adapter) {
 		dev_err(dev, "Failed to get adapter for bus %d\n",
 		dev_err(dev, "Failed to get adapter for bus %d\n",