diff options
author | asomers <asomers@FreeBSD.org> | 2017-05-30 22:46:00 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2017-05-30 22:46:00 +0000 |
commit | 8872da9dd903cd4bc3426c50cd1d7121028ac913 (patch) | |
tree | 998149e94a6a323aaf9f849758cc4956af7573ab | |
parent | b6ed275261198dcfc86c8abb2240ce30bf0ea10e (diff) | |
download | FreeBSD-src-8872da9dd903cd4bc3426c50cd1d7121028ac913.zip FreeBSD-src-8872da9dd903cd4bc3426c50cd1d7121028ac913.tar.gz |
MFC r317759:
Fix memory leaks in camcontrol
Reported by: Coverity
CID: 1331674, 1331675
Reviewed by: ken
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D10588
-rw-r--r-- | sbin/camcontrol/fwdownload.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sbin/camcontrol/fwdownload.c b/sbin/camcontrol/fwdownload.c index d587414..fe41305 100644 --- a/sbin/camcontrol/fwdownload.c +++ b/sbin/camcontrol/fwdownload.c @@ -550,8 +550,7 @@ fw_validate_ibm(struct cam_device *dev, int retry_count, int timeout, int fd, fprintf(stdout, "Firmware file is valid for this drive.\n"); retval = 0; bailout: - if (ccb != NULL) - cam_freeccb(ccb); + cam_freeccb(ccb); return (retval); } @@ -744,8 +743,8 @@ fw_check_device_ready(struct cam_device *dev, camcontrol_devtype devtype, goto bailout; } bailout: - if (ccb != NULL) - cam_freeccb(ccb); + free(ptr); + cam_freeccb(ccb); return (retval); } @@ -895,8 +894,7 @@ fw_download_img(struct cam_device *cam_dev, struct fw_vendor *vp, bailout: if (quiet == 0) progress_complete(&progress, size - img_size); - if (ccb != NULL) - cam_freeccb(ccb); + cam_freeccb(ccb); return (retval); } @@ -905,6 +903,7 @@ fwdownload(struct cam_device *device, int argc, char **argv, char *combinedopt, int printerrors, int task_attr, int retry_count, int timeout) { + union ccb *ccb = NULL; struct fw_vendor *vp; char *fw_img_path = NULL; struct ata_params *ident_buf = NULL; @@ -947,8 +946,6 @@ fwdownload(struct cam_device *device, int argc, char **argv, if ((devtype == CC_DT_ATA) || (devtype == CC_DT_ATA_BEHIND_SCSI)) { - union ccb *ccb; - ccb = cam_getccb(device); if (ccb == NULL) { warnx("couldn't allocate CCB"); @@ -958,7 +955,6 @@ fwdownload(struct cam_device *device, int argc, char **argv, if (ata_do_identify(device, retry_count, timeout, ccb, &ident_buf) != 0) { - cam_freeccb(ccb); retval = 1; goto bailout; } @@ -1030,6 +1026,7 @@ fwdownload(struct cam_device *device, int argc, char **argv, fprintf(stdout, "Firmware download successful\n"); bailout: + cam_freeccb(ccb); free(buf); return (retval); } |