From owner-svn-src-all@freebsd.org Wed Apr 20 21:11:50 2016 Return-Path: Delivered-To: svn-src-all@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 D8887B15017; Wed, 20 Apr 2016 21:11:50 +0000 (UTC) (envelope-from bapt@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 8F2CD1068; Wed, 20 Apr 2016 21:11:50 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3KLBnrD089825; Wed, 20 Apr 2016 21:11:49 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3KLBnWs089824; Wed, 20 Apr 2016 21:11:49 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201604202111.u3KLBnWs089824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Wed, 20 Apr 2016 21:11:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298374 - head/usr.sbin/mpsutil X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2016 21:11:51 -0000 Author: bapt Date: Wed Apr 20 21:11:49 2016 New Revision: 298374 URL: https://svnweb.freebsd.org/changeset/base/298374 Log: Plug leaks Reported by: Coverity CID: 1340155 and 1340156 MFC after: 1 week Modified: head/usr.sbin/mpsutil/mps_flash.c Modified: head/usr.sbin/mpsutil/mps_flash.c ============================================================================== --- head/usr.sbin/mpsutil/mps_flash.c Wed Apr 20 21:04:39 2016 (r298373) +++ head/usr.sbin/mpsutil/mps_flash.c Wed Apr 20 21:11:49 2016 (r298374) @@ -83,6 +83,7 @@ flash_save(int argc, char **argv) if ((size = mps_firmware_get(fd, &firmware_buffer, bios)) < 0) { warnx("Fail to save %s", argv[1]); + close(fd); return (1); } @@ -100,6 +101,7 @@ flash_save(int argc, char **argv) error = errno; warn("write"); free(firmware_buffer); + close(fd); return (error); } written += ret; @@ -189,12 +191,14 @@ flash_update(int argc, char **argv) warnx("Invalid bios: no boot record magic number"); munmap(mem, st.st_size); close(fd); + free(facts); return (1); } if ((st.st_size % 512) != 0) { warnx("Invalid bios: size not a multiple of 512"); munmap(mem, st.st_size); close(fd); + free(facts); return (1); } } else { @@ -206,6 +210,7 @@ flash_update(int argc, char **argv) warnx(" Image Vendor ID: %04x", fwheader->VendorID); munmap(mem, st.st_size); close(fd); + free(facts); return (1); } @@ -215,6 +220,7 @@ flash_update(int argc, char **argv) warnx(" Image Product ID: %04x", fwheader->ProductID); munmap(mem, st.st_size); close(fd); + free(facts); return (1); } } @@ -224,11 +230,13 @@ flash_update(int argc, char **argv) warnx("Fail to update %s", argv[1]); munmap(mem, st.st_size); close(fd); + free(facts); return (1); } munmap(mem, st.st_size); close(fd); + free(facts); printf("%s successfully updated\n", argv[1]); return (0); }