From 0eca7d92e4a84cc6ea2ca9975d2d3b4cef17a686 Mon Sep 17 00:00:00 2001 From: Li Xi Date: Fri, 7 Mar 2014 12:32:12 +0800 Subject: [PATCH] LU-4728 mdt: fix NULL deference of mdt_fid_lock When enabling hsm_control, mti_exp field of struct mdt_thread_info could be NULL. ldlm_cli_enqueue_local will crash the kernel when dereference it. Signed-off-by: Li Xi Change-Id: I4bdb8222aec378e396e7f544834f6fcf9fdaf777 Reviewed-on: http://review.whamcloud.com/9543 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Faccini Bruno Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index efe4614..669d778 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2393,9 +2393,10 @@ static int mdt_object_local_lock(struct mdt_thread_info *info, * want it slowed down due to possible cancels. */ policy->l_inodebits.bits = MDS_INODELOCK_UPDATE; - rc = mdt_fid_lock(ns, &lh->mlh_pdo_lh, lh->mlh_pdo_mode, - policy, res_id, dlmflags, - &info->mti_exp->exp_handle.h_cookie); + rc = mdt_fid_lock(ns, &lh->mlh_pdo_lh, lh->mlh_pdo_mode, + policy, res_id, dlmflags, + info->mti_exp == NULL ? NULL : + &info->mti_exp->exp_handle.h_cookie); if (unlikely(rc)) RETURN(rc); } @@ -2414,9 +2415,10 @@ static int mdt_object_local_lock(struct mdt_thread_info *info, * going to be sent to client. If it is - mdt_intent_policy() path will * fix it up and turn FL_LOCAL flag off. */ - rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy, - res_id, LDLM_FL_LOCAL_ONLY | dlmflags, - &info->mti_exp->exp_handle.h_cookie); + rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy, + res_id, LDLM_FL_LOCAL_ONLY | dlmflags, + info->mti_exp == NULL ? NULL : + &info->mti_exp->exp_handle.h_cookie); if (rc) mdt_object_unlock(info, o, lh, 1); else if (unlikely(OBD_FAIL_PRECHECK(OBD_FAIL_MDS_PDO_LOCK)) && -- 1.8.3.1