diff mbox

[v11,11/12] platform/mellanox: mlxreg-hotplug: Add check for negative adapter number value

Message ID 1516826098-125036-3-git-send-email-vadimp@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Darren Hart
Headers show

Commit Message

Vadim Pasternak Jan. 24, 2018, 8:34 p.m. UTC
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>
---
 drivers/platform/mellanox/mlxreg-hotplug.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Darren Hart Jan. 25, 2018, 10:16 p.m. UTC | #1
On Wed, Jan 24, 2018 at 08:34:57PM +0000, Vadim Pasternak wrote:
> 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>
> ---
>  drivers/platform/mellanox/mlxreg-hotplug.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
> index b891ec7..c806451 100644
> --- a/drivers/platform/mellanox/mlxreg-hotplug.c
> +++ b/drivers/platform/mellanox/mlxreg-hotplug.c
> @@ -95,6 +95,14 @@ struct mlxreg_hotplug_priv_data {
>  
>  static int mlxreg_hotplug_device_create(struct mlxreg_core_data *data)
>  {
> +	/*
> +	 * Return if adapter number is negative. Return if adapter number is
> +	 * negative. It could be in case hotplug event is not associated with

First sentence repeated twice. I've corrected this.
diff mbox

Patch

diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index b891ec7..c806451 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -95,6 +95,14 @@  struct mlxreg_hotplug_priv_data {
 
 static int mlxreg_hotplug_device_create(struct mlxreg_core_data *data)
 {
+	/*
+	 * Return if adapter number is negative. 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)
 		return -EFAULT;