diff options
author | Ulka Vaze <ulka.vaze@yahoo.in> | 2017-01-28 19:04:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-02-03 07:01:37 -0500 |
commit | 30af99db7ab3483f5ce83ccb890533c9378c2ced (patch) | |
tree | 6f75449e78377a38e66ecbef547b6c30182354d8 | |
parent | e202d55b05f29f7d17548167b84764bb951b5b90 (diff) |
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: Ulka Vaze <ulka.vaze@yahoo.in>
Signed-off-by: Aditya Pandit <panditadityashreesh@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6523
Reviewed-on: http://review.whamcloud.com/14918
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/lustre/lustre/lmv/lmv_obd.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 6a3b83f7857c..915415c41668 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c | |||
@@ -736,16 +736,18 @@ static int lmv_hsm_req_count(struct lmv_obd *lmv, | |||
736 | /* count how many requests must be sent to the given target */ | 736 | /* count how many requests must be sent to the given target */ |
737 | for (i = 0; i < hur->hur_request.hr_itemcount; i++) { | 737 | for (i = 0; i < hur->hur_request.hr_itemcount; i++) { |
738 | curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid); | 738 | curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid); |
739 | if (IS_ERR(curr_tgt)) | ||
740 | return PTR_ERR(curr_tgt); | ||
739 | if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) | 741 | if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) |
740 | nr++; | 742 | nr++; |
741 | } | 743 | } |
742 | return nr; | 744 | return nr; |
743 | } | 745 | } |
744 | 746 | ||
745 | static void lmv_hsm_req_build(struct lmv_obd *lmv, | 747 | static int lmv_hsm_req_build(struct lmv_obd *lmv, |
746 | struct hsm_user_request *hur_in, | 748 | struct hsm_user_request *hur_in, |
747 | const struct lmv_tgt_desc *tgt_mds, | 749 | const struct lmv_tgt_desc *tgt_mds, |
748 | struct hsm_user_request *hur_out) | 750 | struct hsm_user_request *hur_out) |
749 | { | 751 | { |
750 | int i, nr_out; | 752 | int i, nr_out; |
751 | struct lmv_tgt_desc *curr_tgt; | 753 | struct lmv_tgt_desc *curr_tgt; |
@@ -756,6 +758,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, | |||
756 | for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) { | 758 | for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) { |
757 | curr_tgt = lmv_find_target(lmv, | 759 | curr_tgt = lmv_find_target(lmv, |
758 | &hur_in->hur_user_item[i].hui_fid); | 760 | &hur_in->hur_user_item[i].hui_fid); |
761 | if (IS_ERR(curr_tgt)) | ||
762 | return PTR_ERR(curr_tgt); | ||
759 | if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) { | 763 | if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) { |
760 | hur_out->hur_user_item[nr_out] = | 764 | hur_out->hur_user_item[nr_out] = |
761 | hur_in->hur_user_item[i]; | 765 | hur_in->hur_user_item[i]; |
@@ -765,6 +769,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, | |||
765 | hur_out->hur_request.hr_itemcount = nr_out; | 769 | hur_out->hur_request.hr_itemcount = nr_out; |
766 | memcpy(hur_data(hur_out), hur_data(hur_in), | 770 | memcpy(hur_data(hur_out), hur_data(hur_in), |
767 | hur_in->hur_request.hr_data_len); | 771 | hur_in->hur_request.hr_data_len); |
772 | |||
773 | return 0; | ||
768 | } | 774 | } |
769 | 775 | ||
770 | static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, | 776 | 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, | |||
1041 | } else { | 1047 | } else { |
1042 | /* split fid list to their respective MDS */ | 1048 | /* split fid list to their respective MDS */ |
1043 | for (i = 0; i < count; i++) { | 1049 | for (i = 0; i < count; i++) { |
1044 | unsigned int nr, reqlen; | ||
1045 | int rc1; | ||
1046 | struct hsm_user_request *req; | 1050 | struct hsm_user_request *req; |
1051 | size_t reqlen; | ||
1052 | int nr, rc1; | ||
1047 | 1053 | ||
1048 | tgt = lmv->tgts[i]; | 1054 | tgt = lmv->tgts[i]; |
1049 | if (!tgt || !tgt->ltd_exp) | 1055 | if (!tgt || !tgt->ltd_exp) |
1050 | continue; | 1056 | continue; |
1051 | 1057 | ||
1052 | nr = lmv_hsm_req_count(lmv, hur, tgt); | 1058 | nr = lmv_hsm_req_count(lmv, hur, tgt); |
1059 | if (nr < 0) | ||
1060 | return nr; | ||
1053 | if (nr == 0) /* nothing for this MDS */ | 1061 | if (nr == 0) /* nothing for this MDS */ |
1054 | continue; | 1062 | continue; |
1055 | 1063 | ||
@@ -1061,10 +1069,13 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, | |||
1061 | if (!req) | 1069 | if (!req) |
1062 | return -ENOMEM; | 1070 | return -ENOMEM; |
1063 | 1071 | ||
1064 | lmv_hsm_req_build(lmv, hur, tgt, req); | 1072 | rc1 = lmv_hsm_req_build(lmv, hur, tgt, req); |
1073 | if (rc1 < 0) | ||
1074 | goto hsm_req_err; | ||
1065 | 1075 | ||
1066 | rc1 = obd_iocontrol(cmd, tgt->ltd_exp, reqlen, | 1076 | rc1 = obd_iocontrol(cmd, tgt->ltd_exp, reqlen, |
1067 | req, uarg); | 1077 | req, uarg); |
1078 | hsm_req_err: | ||
1068 | if (rc1 != 0 && rc == 0) | 1079 | if (rc1 != 0 && rc == 0) |
1069 | rc = rc1; | 1080 | rc = rc1; |
1070 | kvfree(req); | 1081 | kvfree(req); |