From 34092ff5ae44c997918f970f100b46727c684855 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Sat, 3 Sep 2016 04:42:18 +0530 Subject: [PATCH] LU-7949 osd: Move assignment below LASSERT() 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 Change-Id: I80922d372ee768c42d5d34be8222fd5e089bbda5 Reviewed-on: http://review.whamcloud.com/22428 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_quota.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_quota.c b/lustre/osd-ldiskfs/osd_quota.c index e426b43..8f9d5a4 100644 --- a/lustre/osd-ldiskfs/osd_quota.c +++ b/lustre/osd-ldiskfs/osd_quota.c @@ -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 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; @@ -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); + 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) { -- 1.8.3.1