diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2013-02-20 12:24:52 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-02-24 04:36:08 -0500 |
commit | c1f63c8fe85a63ccf308909237216f55711e5434 (patch) | |
tree | daa3a6de55352b6b7392c750b6d3715bc611fd3f /drivers/scsi | |
parent | e2bea6df3261dac1ae400452ddab07babb4fc5f3 (diff) |
[SCSI] hpsa: reorganize error handling in hpsa_passthru_ioctl
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/hpsa.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 38c8aa5e85b4..a7c3d4711535 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -2959,6 +2959,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) | |||
2959 | struct CommandList *c; | 2959 | struct CommandList *c; |
2960 | char *buff = NULL; | 2960 | char *buff = NULL; |
2961 | union u64bit temp64; | 2961 | union u64bit temp64; |
2962 | int rc = 0; | ||
2962 | 2963 | ||
2963 | if (!argp) | 2964 | if (!argp) |
2964 | return -EINVAL; | 2965 | return -EINVAL; |
@@ -2978,8 +2979,8 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) | |||
2978 | /* Copy the data into the buffer we created */ | 2979 | /* Copy the data into the buffer we created */ |
2979 | if (copy_from_user(buff, iocommand.buf, | 2980 | if (copy_from_user(buff, iocommand.buf, |
2980 | iocommand.buf_size)) { | 2981 | iocommand.buf_size)) { |
2981 | kfree(buff); | 2982 | rc = -EFAULT; |
2982 | return -EFAULT; | 2983 | goto out_kfree; |
2983 | } | 2984 | } |
2984 | } else { | 2985 | } else { |
2985 | memset(buff, 0, iocommand.buf_size); | 2986 | memset(buff, 0, iocommand.buf_size); |
@@ -2987,8 +2988,8 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) | |||
2987 | } | 2988 | } |
2988 | c = cmd_special_alloc(h); | 2989 | c = cmd_special_alloc(h); |
2989 | if (c == NULL) { | 2990 | if (c == NULL) { |
2990 | kfree(buff); | 2991 | rc = -ENOMEM; |
2991 | return -ENOMEM; | 2992 | goto out_kfree; |
2992 | } | 2993 | } |
2993 | /* Fill in the command type */ | 2994 | /* Fill in the command type */ |
2994 | c->cmd_type = CMD_IOCTL_PEND; | 2995 | c->cmd_type = CMD_IOCTL_PEND; |
@@ -3027,22 +3028,22 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) | |||
3027 | memcpy(&iocommand.error_info, c->err_info, | 3028 | memcpy(&iocommand.error_info, c->err_info, |
3028 | sizeof(iocommand.error_info)); | 3029 | sizeof(iocommand.error_info)); |
3029 | if (copy_to_user(argp, &iocommand, sizeof(iocommand))) { | 3030 | if (copy_to_user(argp, &iocommand, sizeof(iocommand))) { |
3030 | kfree(buff); | 3031 | rc = -EFAULT; |
3031 | cmd_special_free(h, c); | 3032 | goto out; |
3032 | return -EFAULT; | ||
3033 | } | 3033 | } |
3034 | if (iocommand.Request.Type.Direction == XFER_READ && | 3034 | if (iocommand.Request.Type.Direction == XFER_READ && |
3035 | iocommand.buf_size > 0) { | 3035 | iocommand.buf_size > 0) { |
3036 | /* Copy the data out of the buffer we created */ | 3036 | /* Copy the data out of the buffer we created */ |
3037 | if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) { | 3037 | if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) { |
3038 | kfree(buff); | 3038 | rc = -EFAULT; |
3039 | cmd_special_free(h, c); | 3039 | goto out; |
3040 | return -EFAULT; | ||
3041 | } | 3040 | } |
3042 | } | 3041 | } |
3043 | kfree(buff); | 3042 | out: |
3044 | cmd_special_free(h, c); | 3043 | cmd_special_free(h, c); |
3045 | return 0; | 3044 | out_kfree: |
3045 | kfree(buff); | ||
3046 | return rc; | ||
3046 | } | 3047 | } |
3047 | 3048 | ||
3048 | static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) | 3049 | static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) |