Whamcloud - gitweb
LU-10806 target: skip discard for a missing obt_lut 40/33240/2
authorAlexander Boyko <c17825@cray.com>
Wed, 26 Sep 2018 12:45:20 +0000 (08:45 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 5 Oct 2018 22:26:05 +0000 (22:26 +0000)
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: [<ffffffff816b6b5c>] _raw_spin_lock+0xc/0x30
[<ffffffffc0ff7c15>] ? tgt_grant_discard+0x35/0x190 [ptlrpc]
[<ffffffffc0fcbe2e>] ? tgt_client_free+0x17e/0x3b0 [ptlrpc]
[<ffffffffc1414097>] mdt_destroy_export+0x87/0x200 [mdt]

Signed-off-by: Alexander Boyko <c17825@cray.com>
Cray-bug-id: LUS-6260
Change-Id: Iccd80cb753122727156430e2593340c32841451c
Reviewed-on: https://review.whamcloud.com/33240
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Andriy Skulysh <c17819@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/target/tgt_grant.c

index 8465052..42b5a67 100644 (file)
@@ -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",