Whamcloud - gitweb
LU-7949 osd: Move assignment below LASSERT() 28/22428/2
authorArshad Hussain <arshad.hussain@seagate.com>
Fri, 2 Sep 2016 23:12:18 +0000 (04:42 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 21 Sep 2016 02:56:09 +0000 (02:56 +0000)
This patch moves osd_dt_dev() call and assignment of
qsd_instance below LASSERT() under function osd_declare_qid().
This avoids a case of dereferencing osd_thandle parameter
when passed as NULL. Although osd_dt_dev() does its own
checking it is better to move it below LASSERT(). Patch
also adds LASSERT() after osd_dt_dev() call.

Signed-off-by: Arshad Hussain <arshad.hussain@seagate.com>
Change-Id: I80922d372ee768c42d5d34be8222fd5e089bbda5
Reviewed-on: http://review.whamcloud.com/22428
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_quota.c

index e426b43..8f9d5a4 100644 (file)
@@ -510,8 +510,8 @@ int osd_declare_qid(const struct lu_env *env, struct osd_thandle *oh,
                    struct lquota_id_info *qi, struct osd_object *obj,
                    bool enforce, int *flags)
 {
                    struct lquota_id_info *qi, struct osd_object *obj,
                    bool enforce, int *flags)
 {
-       struct osd_device       *dev = osd_dt_dev(oh->ot_super.th_dev);
-       struct qsd_instance     *qsd = dev->od_quota_slave;
+       struct osd_device       *dev;
+       struct qsd_instance     *qsd;
        struct inode            *inode = NULL;
        int                      i, rc = 0, crd;
        bool                     found = false;
        struct inode            *inode = NULL;
        int                      i, rc = 0, crd;
        bool                     found = false;
@@ -521,6 +521,11 @@ int osd_declare_qid(const struct lu_env *env, struct osd_thandle *oh,
        LASSERTF(oh->ot_id_cnt <= OSD_MAX_UGID_CNT, "count=%d\n",
                 oh->ot_id_cnt);
 
        LASSERTF(oh->ot_id_cnt <= OSD_MAX_UGID_CNT, "count=%d\n",
                 oh->ot_id_cnt);
 
+       dev = osd_dt_dev(oh->ot_super.th_dev);
+       LASSERT(dev != NULL);
+
+       qsd = dev->od_quota_slave;
+
        for (i = 0; i < oh->ot_id_cnt; i++) {
                if (oh->ot_id_array[i] == qi->lqi_id.qid_uid &&
                    osd_qid_type(oh, i) == qi->lqi_type) {
        for (i = 0; i < oh->ot_id_cnt; i++) {
                if (oh->ot_id_array[i] == qi->lqi_id.qid_uid &&
                    osd_qid_type(oh, i) == qi->lqi_type) {