From bed1cbb3db18e01b933f1a799b4f4fd4ff707cfa Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 27 Dec 2016 22:15:39 +0530 Subject: [PATCH 1/1] LU-7947 obdclass: Move assignment below LASSERT() This patch moves 'loghandle->lgh_hdr' assignment call below LASSERT(). This avoids a case when loghandle parameter is NULL and dereferencing the NULL pointer would fault before it reaches LASSERT(). Test-Parameters: trivial Signed-off-by: Arshad Hussain Change-Id: Ie9bcd172a264e104dca300a8bac04d2bd132efb0 Reviewed-on: https://review.whamcloud.com/24561 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- lustre/obdclass/llog.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 78c9e5d..274ba97 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -196,7 +196,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, { struct llog_thread_info *lgi = llog_info(env); struct dt_device *dt; - struct llog_log_hdr *llh = loghandle->lgh_hdr; + struct llog_log_hdr *llh; struct thandle *th; int rc; int rc1; @@ -204,6 +204,12 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, ENTRY; + LASSERT(loghandle != NULL); + LASSERT(loghandle->lgh_ctxt != NULL); + LASSERT(loghandle->lgh_obj != NULL); + + llh = loghandle->lgh_hdr; + CDEBUG(D_RPCTRACE, "Canceling %d in log "DFID"\n", index, PFID(&loghandle->lgh_id.lgl_oi.oi_fid)); @@ -212,10 +218,6 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, RETURN(-EINVAL); } - LASSERT(loghandle != NULL); - LASSERT(loghandle->lgh_ctxt != NULL); - LASSERT(loghandle->lgh_obj != NULL); - dt = lu2dt_dev(loghandle->lgh_obj->do_lu.lo_dev); th = dt_trans_create(env, dt); -- 1.8.3.1