From owner-svn-src-stable@freebsd.org Tue May 30 22:46:01 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66BBBBF03A3; Tue, 30 May 2017 22:46:01 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 34D637E6EA; Tue, 30 May 2017 22:46:01 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4UMk0Vg075988; Tue, 30 May 2017 22:46:00 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4UMk0FW075987; Tue, 30 May 2017 22:46:00 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201705302246.v4UMk0FW075987@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 30 May 2017 22:46:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r319266 - stable/10/sbin/camcontrol X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 May 2017 22:46:01 -0000 Author: asomers Date: Tue May 30 22:46:00 2017 New Revision: 319266 URL: https://svnweb.freebsd.org/changeset/base/319266 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/10/sbin/camcontrol/fwdownload.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/camcontrol/fwdownload.c ============================================================================== --- stable/10/sbin/camcontrol/fwdownload.c Tue May 30 22:45:01 2017 (r319265) +++ stable/10/sbin/camcontrol/fwdownload.c Tue May 30 22:46:00 2017 (r319266) @@ -550,8 +550,7 @@ fw_validate_ibm(struct cam_device *dev, int retry_coun 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, camcontr 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_ 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 * 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 * 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 * 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 * fprintf(stdout, "Firmware download successful\n"); bailout: + cam_freeccb(ccb); free(buf); return (retval); }