Skip to contentSkip to conversation

IB/mlx5: fix error code in get_port_caps()

PATCH Superseded Dan Carpenter 3 participants 4 messages Jan 12, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/mlx5: fix error code in get_port_caps()

We should return -ENOMEM on allocation failure instead of success.

Fixes e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters')
drivers/infiniband/hw/mlx5/main.c +1 -1
index 8a87404..cc4ac1e 100644
@@ -997,7 +997,7 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
 	struct ib_device_attr *dprops = NULL;
 	struct ib_port_attr *pprops = NULL;
 	struct mlx5_general_caps *gen;
-	int err = 0;
+	int err = -ENOMEM;
 	int port;
 
 	gen = &dev->mdev->caps.gen;
#1 lore raw
Quoted 1 line · Dan Carpenter

We should return -ENOMEM on allocation failure instead of success.

Probably not a big deal, but the commit message is not clear at all. From the fix, it doesn't look like the code was returning -ENOMEM on success.

julia

Quoted 21 lines
Fixes e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters')
drivers/infiniband/hw/mlx5/main.c +1 -2
index 8a87404..cc4ac1e 100644
@@ -997,7 +997,7 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
 	struct ib_device_attr *dprops = NULL;
 	struct ib_port_attr *pprops = NULL;
 	struct mlx5_general_caps *gen;
-	int err = 0;
+	int err = -ENOMEM;
 	int port;
 
 	gen = &dev->mdev->caps.gen;
--

To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

PATCH v2 1/1 IB/mlx5: fix error code in get_port_caps()

The current code returns success when kmalloc() fails. It should return an error code, -ENOMEM.

Fixes e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters')

---
v2: re-write changelog

drivers/infiniband/hw/mlx5/main.c +1 -1
index 8a87404..cc4ac1e 100644
@@ -997,7 +997,7 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
 	struct ib_device_attr *dprops = NULL;
 	struct ib_port_attr *pprops = NULL;
 	struct mlx5_general_caps *gen;
-	int err = 0;
+	int err = -ENOMEM;
 	int port;
 
 	gen = &dev->mdev->caps.gen;
Acked-by on v1 1/1
#3 lore raw
In reply to Dan Carpenter

Thanks!

Quoted 22 lines · Dan Carpenter

We should return -ENOMEM on allocation failure instead of success.

Fixes e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters')
drivers/infiniband/hw/mlx5/main.c +1 -2
index 8a87404..cc4ac1e 100644
@@ -997,7 +997,7 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
 	struct ib_device_attr *dprops = NULL;
 	struct ib_port_attr *pprops = NULL;
 	struct mlx5_general_caps *gen;
-	int err = 0;
+	int err = -ENOMEM;
 	int port;
 
 	gen = &dev->mdev->caps.gen;
--

To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html