Commit cde5f109 authored by John L. Hammond's avatar John L. Hammond Committed by Greg Kroah-Hartman

staging: lustre: ldlm: fix a use after free in ldlm_resource_get()

If lvbo initialization has failed then save the return status (from
lr_lvb_len) before putting the resource.
Signed-off-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5305
Reviewed-on: http://review.whamcloud.com/11017Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarEmoly Liu <emoly.liu@intel.com>
Reviewed-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2e0ca344
...@@ -1091,6 +1091,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, ...@@ -1091,6 +1091,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
struct cfs_hash_bd bd; struct cfs_hash_bd bd;
__u64 version; __u64 version;
int ns_refcount = 0; int ns_refcount = 0;
int rc;
LASSERT(!parent); LASSERT(!parent);
LASSERT(ns->ns_rs_hash); LASSERT(ns->ns_rs_hash);
...@@ -1140,8 +1141,9 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, ...@@ -1140,8 +1141,9 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
} }
if (unlikely(res->lr_lvb_len < 0)) { if (unlikely(res->lr_lvb_len < 0)) {
rc = res->lr_lvb_len;
ldlm_resource_putref(res); ldlm_resource_putref(res);
res = ERR_PTR(res->lr_lvb_len); res = ERR_PTR(rc);
} }
return res; return res;
} }
...@@ -1152,8 +1154,6 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, ...@@ -1152,8 +1154,6 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) { if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
int rc;
OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2); OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2);
rc = ns->ns_lvbo->lvbo_init(res); rc = ns->ns_lvbo->lvbo_init(res);
if (rc < 0) { if (rc < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment