public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amso1100: Add check if cache memory was allocated before freeing it
@ 2014-01-12 11:56 Svetlana Mavrina
  0 siblings, 0 replies; only message in thread
From: Svetlana Mavrina @ 2014-01-12 11:56 UTC (permalink / raw)
  To: tom
  Cc: Svetlana Mavrina, swise, roland, sean.hefty, hal.rosenstock,
	linux-rdma, linux-kernel, ldv-project

From: Svetlana Mavrina <another.karnil@gmail.com>

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).

Signed-off-by: Svetlana Mavrina <another.karnil@gmail.com>
Reviewed-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/infiniband/hw/amso1100/c2_intr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/amso1100/c2_intr.c b/drivers/infiniband/hw/amso1100/c2_intr.c
index 8951db4ae29d..3a17d9b36dba 100644
--- a/drivers/infiniband/hw/amso1100/c2_intr.c
+++ b/drivers/infiniband/hw/amso1100/c2_intr.c
@@ -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;
 	}
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-12 11:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-12 11:56 [PATCH] amso1100: Add check if cache memory was allocated before freeing it Svetlana Mavrina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox