Whamcloud - gitweb
LU-13942 obd: check if sbi->ll_md_exp is initialized 12/39812/6
authorArtem Blagodarenko <artem.blagodarenko@hpe.com>
Fri, 21 Aug 2020 17:43:38 +0000 (13:43 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 2 Jun 2021 17:47:41 +0000 (17:47 +0000)
Null reference at the start of obd_statfs() function is possible
because of ll_fill_super vs lctl race.

ll_md_exp is initialized in ll_fill_super()->
client_common_fill_super(), but if mount process stucks
in lustre_process_log() it doesn't reach client_common_fill_super().

Change-Id: Ife72a62ba42573e2a9c6d244e36cde738b70c15a
hpe-bug-id: LUS-9150
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-on: https://es-gerrit.dev.cray.com/157732
Reviewed-by: Alexander Zarochentsev <c17826@cray.com>
Tested-by: Alexander Lezhoev <c17454@cray.com>
Reviewed-by: Andriy Skulysh <c17819@cray.com>
Reviewed-on: https://review.whamcloud.com/39812
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/obd_class.h

index 1dc5f12..6be7628 100644 (file)
@@ -1046,13 +1046,14 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
                             struct obd_statfs *osfs, time64_t max_age,
                             __u32 flags)
 {
-       struct obd_device *obd = exp->exp_obd;
+       struct obd_device *obd;
        int rc = 0;
 
        ENTRY;
-       if (unlikely(obd == NULL))
+       if (unlikely(exp == NULL || exp->exp_obd == NULL))
                RETURN(-EINVAL);
 
+       obd = exp->exp_obd;
        OBD_CHECK_DEV_ACTIVE(obd);
 
        if (unlikely(!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs)) {