Skip to contentSkip to conversation

amso1100: Add check if cache memory was allocated before freeing it

PATCH New Svetlana Mavrina 1 participant 1 message Jan 12, 2014 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amso1100: Add check if cache memory was allocated before freeing it

From: Svetlana Mavrina <[email protected]>

There is a path in handle_vq() where kmem_cache_free()
can be called with pointer to a local variable.
It can happen if vq_repbuf_alloc() failed to allocate memory from cache and req is NULL.

The patch adds check if cache memory was allocated before freeing it.

Found by Linux Driver Verification project (linuxtesting.org).

---
 drivers/infiniband/hw/amso1100/c2_intr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/amso1100/c2_intr.c +2 -1
index 8951db4ae29d..3a17d9b36dba 100644
@@ -169,7 +169,8 @@ static void handle_vq(struct c2_dev *c2dev, u32 mq_index)
 		 * We should never get here, as the adapter should
 		 * never send us a reply that we're not expecting.
 		 */
-		vq_repbuf_free(c2dev, host_msg);
+		if (reply_msg != NULL)
+			vq_repbuf_free(c2dev, host_msg);
 		pr_debug("handle_vq: UNEXPECTEDLY got NULL req\n");
 		return;
 	}
Signature · 1 line
1.8.1.2