Fix memory leaks in camcontrol
Reported by: Coverity CID: 1331674, 1331675 Reviewed by: ken MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D10588
This commit is contained in:
parent
65d648c082
commit
e018cf091c
@ -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");
|
fprintf(stdout, "Firmware file is valid for this drive.\n");
|
||||||
retval = 0;
|
retval = 0;
|
||||||
bailout:
|
bailout:
|
||||||
if (ccb != NULL)
|
cam_freeccb(ccb);
|
||||||
cam_freeccb(ccb);
|
|
||||||
|
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
@ -753,8 +752,8 @@ fw_check_device_ready(struct cam_device *dev, camcontrol_devtype devtype,
|
|||||||
goto bailout;
|
goto bailout;
|
||||||
}
|
}
|
||||||
bailout:
|
bailout:
|
||||||
if (ccb != NULL)
|
free(ptr);
|
||||||
cam_freeccb(ccb);
|
cam_freeccb(ccb);
|
||||||
|
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
@ -913,8 +912,7 @@ fw_download_img(struct cam_device *cam_dev, struct fw_vendor *vp,
|
|||||||
bailout:
|
bailout:
|
||||||
if (quiet == 0)
|
if (quiet == 0)
|
||||||
progress_complete(&progress, size - img_size);
|
progress_complete(&progress, size - img_size);
|
||||||
if (ccb != NULL)
|
cam_freeccb(ccb);
|
||||||
cam_freeccb(ccb);
|
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,6 +921,7 @@ fwdownload(struct cam_device *device, int argc, char **argv,
|
|||||||
char *combinedopt, int printerrors, int task_attr, int retry_count,
|
char *combinedopt, int printerrors, int task_attr, int retry_count,
|
||||||
int timeout)
|
int timeout)
|
||||||
{
|
{
|
||||||
|
union ccb *ccb = NULL;
|
||||||
struct fw_vendor *vp;
|
struct fw_vendor *vp;
|
||||||
char *fw_img_path = NULL;
|
char *fw_img_path = NULL;
|
||||||
struct ata_params *ident_buf = NULL;
|
struct ata_params *ident_buf = NULL;
|
||||||
@ -965,8 +964,6 @@ fwdownload(struct cam_device *device, int argc, char **argv,
|
|||||||
|
|
||||||
if ((devtype == CC_DT_ATA)
|
if ((devtype == CC_DT_ATA)
|
||||||
|| (devtype == CC_DT_ATA_BEHIND_SCSI)) {
|
|| (devtype == CC_DT_ATA_BEHIND_SCSI)) {
|
||||||
union ccb *ccb;
|
|
||||||
|
|
||||||
ccb = cam_getccb(device);
|
ccb = cam_getccb(device);
|
||||||
if (ccb == NULL) {
|
if (ccb == NULL) {
|
||||||
warnx("couldn't allocate CCB");
|
warnx("couldn't allocate CCB");
|
||||||
@ -976,7 +973,6 @@ fwdownload(struct cam_device *device, int argc, char **argv,
|
|||||||
|
|
||||||
if (ata_do_identify(device, retry_count, timeout, ccb,
|
if (ata_do_identify(device, retry_count, timeout, ccb,
|
||||||
&ident_buf) != 0) {
|
&ident_buf) != 0) {
|
||||||
cam_freeccb(ccb);
|
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto bailout;
|
goto bailout;
|
||||||
}
|
}
|
||||||
@ -1048,6 +1044,7 @@ fwdownload(struct cam_device *device, int argc, char **argv,
|
|||||||
fprintf(stdout, "Firmware download successful\n");
|
fprintf(stdout, "Firmware download successful\n");
|
||||||
|
|
||||||
bailout:
|
bailout:
|
||||||
|
cam_freeccb(ccb);
|
||||||
free(buf);
|
free(buf);
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user