From 5ed65fd0594741e69999216db27d85f7f6f7f5d6 Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Wed, 26 Sep 2018 08:45:20 -0400 Subject: [PATCH] LU-10806 target: skip discard for a missing obt_lut If error happens at tgt_init, obt_lut is zeroed. The error handle path destroys export and calls tgt_grant_discard which access to non allocated memory. The patch skips release grant for zero obt_lut. BUG: unable to handle kernel NULL pointer dereference at 0000000000000378 IP: [] _raw_spin_lock+0xc/0x30 [] ? tgt_grant_discard+0x35/0x190 [ptlrpc] [] ? tgt_client_free+0x17e/0x3b0 [ptlrpc] [] mdt_destroy_export+0x87/0x200 [mdt] Signed-off-by: Alexander Boyko Cray-bug-id: LUS-6260 Change-Id: Iccd80cb753122727156430e2593340c32841451c Reviewed-on: https://review.whamcloud.com/33240 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Andriy Skulysh Reviewed-by: Oleg Drokin --- lustre/target/tgt_grant.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lustre/target/tgt_grant.c b/lustre/target/tgt_grant.c index 8465052..42b5a67 100644 --- a/lustre/target/tgt_grant.c +++ b/lustre/target/tgt_grant.c @@ -1062,9 +1062,14 @@ EXPORT_SYMBOL(tgt_grant_connect); void tgt_grant_discard(struct obd_export *exp) { struct obd_device *obd = exp->exp_obd; - struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd; + struct lu_target *lut = class_exp2tgt(exp); struct tg_export_data *ted = &exp->exp_target_data; + struct tg_grants_data *tgd; + + if (!lut) + return; + tgd = &lut->lut_tgd; spin_lock(&tgd->tgd_grant_lock); LASSERTF(tgd->tgd_tot_granted >= ted->ted_grant, "%s: tot_granted %llu cli %s/%p ted_grant %ld\n", -- 1.8.3.1