Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30af99db authored by Ulka Vaze's avatar Ulka Vaze Committed by Greg Kroah-Hartman
Browse files

staging: lustre: lmv: Error not handled for lmv_find_target



This issue is found by smatch; has been reported as-
Unchecked usage of potential ERR_PTR result in lmv_hsm_req_count
and lmv_hsm_req_build. Added ERR_PTR in both functions and also
return value check added.

Signed-off-by: default avatarUlka Vaze <ulka.vaze@yahoo.in>
Signed-off-by: default avatarAditya Pandit <panditadityashreesh@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6523
Reviewed-on: http://review.whamcloud.com/14918


Reviewed-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e202d55b
Loading
Loading
Loading
Loading
+18 −7
Original line number Original line Diff line number Diff line
@@ -736,13 +736,15 @@ static int lmv_hsm_req_count(struct lmv_obd *lmv,
	/* count how many requests must be sent to the given target */
	/* count how many requests must be sent to the given target */
	for (i = 0; i < hur->hur_request.hr_itemcount; i++) {
	for (i = 0; i < hur->hur_request.hr_itemcount; i++) {
		curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid);
		curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid);
		if (IS_ERR(curr_tgt))
			return PTR_ERR(curr_tgt);
		if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid))
		if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid))
			nr++;
			nr++;
	}
	}
	return nr;
	return nr;
}
}


static void lmv_hsm_req_build(struct lmv_obd *lmv,
static int lmv_hsm_req_build(struct lmv_obd *lmv,
			     struct hsm_user_request *hur_in,
			     struct hsm_user_request *hur_in,
			     const struct lmv_tgt_desc *tgt_mds,
			     const struct lmv_tgt_desc *tgt_mds,
			     struct hsm_user_request *hur_out)
			     struct hsm_user_request *hur_out)
@@ -756,6 +758,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv,
	for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) {
	for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) {
		curr_tgt = lmv_find_target(lmv,
		curr_tgt = lmv_find_target(lmv,
					   &hur_in->hur_user_item[i].hui_fid);
					   &hur_in->hur_user_item[i].hui_fid);
		if (IS_ERR(curr_tgt))
			return PTR_ERR(curr_tgt);
		if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) {
		if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) {
			hur_out->hur_user_item[nr_out] =
			hur_out->hur_user_item[nr_out] =
				hur_in->hur_user_item[i];
				hur_in->hur_user_item[i];
@@ -765,6 +769,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv,
	hur_out->hur_request.hr_itemcount = nr_out;
	hur_out->hur_request.hr_itemcount = nr_out;
	memcpy(hur_data(hur_out), hur_data(hur_in),
	memcpy(hur_data(hur_out), hur_data(hur_in),
	       hur_in->hur_request.hr_data_len);
	       hur_in->hur_request.hr_data_len);

	return 0;
}
}


static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len,
static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len,
@@ -1041,15 +1047,17 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
		} else {
		} else {
			/* split fid list to their respective MDS */
			/* split fid list to their respective MDS */
			for (i = 0; i < count; i++) {
			for (i = 0; i < count; i++) {
				unsigned int		nr, reqlen;
				int			rc1;
				struct hsm_user_request *req;
				struct hsm_user_request *req;
				size_t reqlen;
				int nr, rc1;


				tgt = lmv->tgts[i];
				tgt = lmv->tgts[i];
				if (!tgt || !tgt->ltd_exp)
				if (!tgt || !tgt->ltd_exp)
					continue;
					continue;


				nr = lmv_hsm_req_count(lmv, hur, tgt);
				nr = lmv_hsm_req_count(lmv, hur, tgt);
				if (nr < 0)
					return nr;
				if (nr == 0) /* nothing for this MDS */
				if (nr == 0) /* nothing for this MDS */
					continue;
					continue;


@@ -1061,10 +1069,13 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
				if (!req)
				if (!req)
					return -ENOMEM;
					return -ENOMEM;


				lmv_hsm_req_build(lmv, hur, tgt, req);
				rc1 = lmv_hsm_req_build(lmv, hur, tgt, req);
				if (rc1 < 0)
					goto hsm_req_err;


				rc1 = obd_iocontrol(cmd, tgt->ltd_exp, reqlen,
				rc1 = obd_iocontrol(cmd, tgt->ltd_exp, reqlen,
						    req, uarg);
						    req, uarg);
hsm_req_err:
				if (rc1 != 0 && rc == 0)
				if (rc1 != 0 && rc == 0)
					rc = rc1;
					rc = rc1;
				kvfree(req);
				kvfree(req);