[ofa-general] [PATCH] mlx4: Add bad flow check when freeing in mlx4_buf_free (potential Oops)

Jack Morgenstein jackm at dev.mellanox.co.il
Thu Nov 1 00:37:44 PDT 2007


mlx4: Bad flow check is missing from mlx4_buf_free().

This could result in a kernel Oops (NULL dereference).

Signed-off-by: Ali Ayoub <ali at mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>

---

Roland,

Please try and get this one into 2.6.24 -- it is a bug fix.
Jack

diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c
index f8d63d3..b226e01 100644
--- a/drivers/net/mlx4/alloc.c
+++ b/drivers/net/mlx4/alloc.c
@@ -171,9 +171,10 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf)
 				  buf->u.direct.map);
 	else {
 		for (i = 0; i < buf->nbufs; ++i)
-			dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
-					  buf->u.page_list[i].buf,
-					  buf->u.page_list[i].map);
+			if (buf->u.page_list[i].buf)
+				dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
+						  buf->u.page_list[i].buf,
+						  buf->u.page_list[i].map);
 		kfree(buf->u.page_list);
 	}
 }



More information about the general mailing list