]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
RDMA/amso1100: Add check if cache memory was allocated before freeing it
authorSvetlana Mavrina <another.karnil@gmail.com>
Sun, 12 Jan 2014 11:56:09 +0000 (11:56 +0000)
committerRoland Dreier <roland@purestorage.com>
Thu, 23 Jan 2014 07:03:59 +0000 (23:03 -0800)
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>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/amso1100/c2_intr.c

index 8951db4ae29d42ad2b12d4281c67c911748c2f78..3a17d9b36dbac2b947d7d09318878f00cc2e0403 100644 (file)
@@ -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;
        }