Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 May 2017 21:18:13 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r318817 - stable/11/sbin/camcontrol
Message-ID:  <201705242118.v4OLIDZs023534@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed May 24 21:18:13 2017
New Revision: 318817
URL: https://svnweb.freebsd.org/changeset/base/318817

Log:
  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

Modified:
  stable/11/sbin/camcontrol/fwdownload.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/camcontrol/fwdownload.c
==============================================================================
--- stable/11/sbin/camcontrol/fwdownload.c	Wed May 24 21:02:53 2017	(r318816)
+++ stable/11/sbin/camcontrol/fwdownload.c	Wed May 24 21:18:13 2017	(r318817)
@@ -550,8 +550,7 @@ fw_validate_ibm(struct cam_device *dev, 
 		fprintf(stdout, "Firmware file is valid for this drive.\n");
 	retval = 0;
 bailout:
-	if (ccb != NULL)
-		cam_freeccb(ccb);
+	cam_freeccb(ccb);
 
 	return (retval);
 }
@@ -753,8 +752,8 @@ fw_check_device_ready(struct cam_device 
 		goto bailout;
 	}
 bailout:
-	if (ccb != NULL)
-		cam_freeccb(ccb);
+	free(ptr);
+	cam_freeccb(ccb);
 
 	return (retval);
 }
@@ -913,8 +912,7 @@ fw_download_img(struct cam_device *cam_d
 bailout:
 	if (quiet == 0)
 		progress_complete(&progress, size - img_size);
-	if (ccb != NULL)
-		cam_freeccb(ccb);
+	cam_freeccb(ccb);
 	return (retval);
 }
 
@@ -923,6 +921,7 @@ fwdownload(struct cam_device *device, in
     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;
@@ -965,8 +964,6 @@ fwdownload(struct cam_device *device, in
 
 	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");
@@ -976,7 +973,6 @@ fwdownload(struct cam_device *device, in
 
 		if (ata_do_identify(device, retry_count, timeout, ccb,
 		    		    &ident_buf) != 0) {
-			cam_freeccb(ccb);
 			retval = 1;
 			goto bailout;
 		}
@@ -1048,6 +1044,7 @@ fwdownload(struct cam_device *device, in
 		fprintf(stdout, "Firmware download successful\n");
 
 bailout:
+	cam_freeccb(ccb);
 	free(buf);
 	return (retval);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705242118.v4OLIDZs023534>