staging: lustre/ptlrpc: small leak on allocation failure
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 24 Nov 2016 11:12:04 +0000 (14:12 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Nov 2016 20:44:01 +0000 (21:44 +0100)
We should free "desc" before returning NULL.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ptlrpc/client.c

index ac959ef1fab090d9584355a5aa9cf51aa53eac0c..804741362bc029b24899663852e3138a64a48500 100644 (file)
@@ -128,12 +128,12 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
                GET_KIOV(desc) = kcalloc(nfrags, sizeof(*GET_KIOV(desc)),
                                         GFP_NOFS);
                if (!GET_KIOV(desc))
-                       goto out;
+                       goto free_desc;
        } else {
                GET_KVEC(desc) = kcalloc(nfrags, sizeof(*GET_KVEC(desc)),
                                         GFP_NOFS);
                if (!GET_KVEC(desc))
-                       goto out;
+                       goto free_desc;
        }
 
        spin_lock_init(&desc->bd_lock);
@@ -154,7 +154,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
                LNetInvalidateHandle(&desc->bd_mds[i]);
 
        return desc;
-out:
+free_desc:
+       kfree(desc);
        return NULL;
 }