staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
authorNeilBrown <neilb@suse.com>
Thu, 29 Mar 2018 04:26:48 +0000 (15:26 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Apr 2018 12:46:39 +0000 (14:46 +0200)
ldlm_lock_create() gets a resource, but don't put it on
all failure paths. It should.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c

index b8fd778..614caa4 100644 (file)
@@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
                return ERR_CAST(res);
 
        lock = ldlm_lock_new(res);
-       if (!lock)
+       if (!lock) {
+               ldlm_resource_putref(res);
                return ERR_PTR(-ENOMEM);
+       }
 
        lock->l_req_mode = mode;
        lock->l_ast_data = data;
@@ -1595,6 +1597,8 @@ out:
        return ERR_PTR(rc);
 }
 
+
+
 /**
  * Enqueue (request) a lock.
  * On the client this is called from ldlm_cli_enqueue_fini