[dpdk-dev] net/mlx5: fix wrong exception handling

Message ID 20170530010259.48823-1-yskoh@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Yongseok Koh May 30, 2017, 1:02 a.m. UTC
  A sanity check is required in priv_fdir_disable(). If resizing Rx queue
fails, this can cause a crash by referencing a NULL pointer.

Cc: stable@dpdk.org
Fixes: 76f5c99e6840 ("mlx5: support flow director")
Fixes: 0cdddf4d0626 ("net/mlx5: split Rx queue structure")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_fdir.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Adrien Mazarguil May 30, 2017, 7:48 a.m. UTC | #1
On Mon, May 29, 2017 at 06:02:59PM -0700, Yongseok Koh wrote:
> A sanity check is required in priv_fdir_disable(). If resizing Rx queue
> fails, this can cause a crash by referencing a NULL pointer.
> 
> Cc: stable@dpdk.org
> Fixes: 76f5c99e6840 ("mlx5: support flow director")
> Fixes: 0cdddf4d0626 ("net/mlx5: split Rx queue structure")
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>

Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
  
Ferruh Yigit June 1, 2017, 10:24 a.m. UTC | #2
On 5/30/2017 8:48 AM, Adrien Mazarguil wrote:
> On Mon, May 29, 2017 at 06:02:59PM -0700, Yongseok Koh wrote:
>> A sanity check is required in priv_fdir_disable(). If resizing Rx queue
>> fails, this can cause a crash by referencing a NULL pointer.
>>
>> Cc: stable@dpdk.org
>> Fixes: 76f5c99e6840 ("mlx5: support flow director")
>> Fixes: 0cdddf4d0626 ("net/mlx5: split Rx queue structure")
>>
>> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> 
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_fdir.c b/drivers/net/mlx5/mlx5_fdir.c
index f80c58b4d..1cff41bab 100644
--- a/drivers/net/mlx5/mlx5_fdir.c
+++ b/drivers/net/mlx5/mlx5_fdir.c
@@ -733,9 +733,11 @@  priv_fdir_disable(struct priv *priv)
 
 	/* Destroy flow director context in each RX queue. */
 	for (i = 0; (i != priv->rxqs_n); i++) {
-		struct rxq_ctrl *rxq_ctrl =
-			container_of((*priv->rxqs)[i], struct rxq_ctrl, rxq);
+		struct rxq_ctrl *rxq_ctrl;
 
+		if (!(*priv->rxqs)[i])
+			continue;
+		rxq_ctrl = container_of((*priv->rxqs)[i], struct rxq_ctrl, rxq);
 		if (!rxq_ctrl->fdir_queue)
 			continue;
 		priv_fdir_queue_destroy(priv, rxq_ctrl->fdir_queue);