diff options
author | Alan Somers <asomers@FreeBSD.org> | 2018-02-23 00:17:50 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2018-02-23 00:17:50 +0000 |
commit | d68b76a9deb5173425f0ed0d5d2fd7a922a4bb69 (patch) | |
tree | 25523fdb1cdc9b109843dee367b330ff76c7cbca /usr.sbin/mptutil/mpt_volume.c | |
parent | 97e9382d5657d7b07162d6c5c9eb3d6957e0e802 (diff) | |
download | src-d68b76a9deb5173425f0ed0d5d2fd7a922a4bb69.tar.gz src-d68b76a9deb5173425f0ed0d5d2fd7a922a4bb69.zip |
Fix numerous Coverity issues in mptutil
Most are memory or file descriptor leaks. Three were unannotated
fallthroughs in a switch/case statement. One was an integer overflow before
widen.
Reported by: Coverity
CID: 1007463 1007462 1007461 1007460 1007459 1007458 1007457
CID: 1006855 1006854 1006853 1006852 1006851 1006850 1006849
CID: 1006848 1006845 1006844 1006843 1006842 1006841 1006840
CID: 1006839 1006838 1006837 1006836 1006835 1006834 1006833
CID: 1006832 1006831 1006831 1006830 1006829 1008334 1008170
CID: 1008169 1008168
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D11013
Notes
Notes:
svn path=/head/; revision=329845
Diffstat (limited to 'usr.sbin/mptutil/mpt_volume.c')
-rw-r--r-- | usr.sbin/mptutil/mpt_volume.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.sbin/mptutil/mpt_volume.c b/usr.sbin/mptutil/mpt_volume.c index 0e437ed03de6..9c160542f51c 100644 --- a/usr.sbin/mptutil/mpt_volume.c +++ b/usr.sbin/mptutil/mpt_volume.c @@ -100,11 +100,14 @@ volume_name(int ac, char **av) if (vnames == NULL) { error = errno; warn("Failed to fetch volume names"); + close(fd); return (error); } if (vnames->Header.PageType != MPI_CONFIG_PAGEATTR_CHANGEABLE) { warnx("Volume name is read only"); + free(vnames); + close(fd); return (EOPNOTSUPP); } printf("mpt%u changing volume %s name from \"%s\" to \"%s\"\n", @@ -116,6 +119,8 @@ volume_name(int ac, char **av) if (mpt_write_config_page(fd, vnames, NULL) < 0) { error = errno; warn("Failed to set volume name"); + free(vnames); + close(fd); return (error); } @@ -152,6 +157,7 @@ volume_status(int ac, char **av) error = mpt_lookup_volume(fd, av[1], &VolumeBus, &VolumeID); if (error) { warnc(error, "Invalid volume: %s", av[1]); + close(fd); return (error); } @@ -160,6 +166,7 @@ volume_status(int ac, char **av) NULL, NULL, 0); if (error) { warnc(error, "Fetching volume status failed"); + close(fd); return (error); } @@ -226,12 +233,15 @@ volume_cache(int ac, char **av) error = mpt_lookup_volume(fd, av[1], &VolumeBus, &VolumeID); if (error) { warnc(error, "Invalid volume: %s", av[1]); + close(fd); return (error); } volume = mpt_vol_info(fd, VolumeBus, VolumeID, NULL); - if (volume == NULL) + if (volume == NULL) { + close(fd); return (errno); + } Settings = volume->VolumeSettings.Settings; @@ -243,6 +253,7 @@ volume_cache(int ac, char **av) if (NewSettings == Settings) { warnx("volume cache unchanged"); + free(volume); close(fd); return (0); } |