diff options
author | asomers <asomers@FreeBSD.org> | 2017-04-24 16:07:30 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2017-04-24 16:07:30 +0000 |
commit | 35bd9938c89ecb18156ca1ebc2da9b4e5339e0f7 (patch) | |
tree | 7a6afddf10a1debf9b9282dad1c7c5ab96fc0d06 /sbin | |
parent | 3c8d119ce1db45d1f054bb3c1bfa71d993fafc94 (diff) | |
download | FreeBSD-src-35bd9938c89ecb18156ca1ebc2da9b4e5339e0f7.zip FreeBSD-src-35bd9938c89ecb18156ca1ebc2da9b4e5339e0f7.tar.gz |
MFC r312558:
Misc Coverity fixes in camcontrol(8)
CID 1229913 Fix output of "camcontrol persist -i report_capabilities".
The reported Persistent Reservation Types were wrong in all
cases.
CID 1356029 Annotate the code so Coverity will know that this is a false
positive.
CID 1366830 Fix a memory leak in "camcontrol timestamp -s"
CID 1366832 Fix a segfault that could be caused by bad drive firmware
Also, fix the man page entry for the "camcontrol epc state" command to match
what the code does.
Reviewed by: ken, wblock
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9239
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/camcontrol/camcontrol.8 | 14 | ||||
-rw-r--r-- | sbin/camcontrol/epc.c | 1 | ||||
-rw-r--r-- | sbin/camcontrol/persist.c | 14 | ||||
-rw-r--r-- | sbin/camcontrol/timestamp.c | 4 |
4 files changed, 27 insertions, 6 deletions
diff --git a/sbin/camcontrol/camcontrol.8 b/sbin/camcontrol/camcontrol.8 index f7069c8..653c9bc 100644 --- a/sbin/camcontrol/camcontrol.8 +++ b/sbin/camcontrol/camcontrol.8 @@ -2385,6 +2385,20 @@ this power condition will be affected. .It state Enable or disable a particular power condition. .Bl -tag -width 7n +.It Fl e +Enable the power condition. +One of +.Fl e +or +.Fl d +is required. +.It Fl d +Disable the power condition. +One of +.Fl d +or +.Fl e +is required. .It Fl p Ar cond Specify the power condition: Idle_a, Idle_b, Idle_c, Standby_y, Standby_z. This argument is required. diff --git a/sbin/camcontrol/epc.c b/sbin/camcontrol/epc.c index 783db59..3b74d08 100644 --- a/sbin/camcontrol/epc.c +++ b/sbin/camcontrol/epc.c @@ -783,6 +783,7 @@ epc(struct cam_device *device, int argc, char **argv, char *combinedopt, warnx("Must specify a timer value (-T time)"); error = 1; } + /* FALLTHROUGH */ case ATA_SF_EPC_SET_STATE: if (enable == -1) { warnx("Must specify enable (-e) or disable (-d)"); diff --git a/sbin/camcontrol/persist.c b/sbin/camcontrol/persist.c index 34beb2e..226517f 100644 --- a/sbin/camcontrol/persist.c +++ b/sbin/camcontrol/persist.c @@ -241,9 +241,11 @@ persist_print_cap(struct scsi_per_res_cap *cap, uint32_t valid_len) { uint32_t length; int check_type_mask = 0; + uint32_t type_mask; length = scsi_2btoul(cap->length); length = MIN(length, valid_len); + type_mask = scsi_2btoul(cap->type_mask); if (length < __offsetof(struct scsi_per_res_cap, type_mask)) { fprintf(stdout, "Insufficient data (%u bytes) to report " @@ -345,20 +347,20 @@ persist_print_cap(struct scsi_per_res_cap *cap, uint32_t valid_len) fprintf(stdout, "Supported Persistent Reservation Types:\n"); fprintf(stdout, " Write Exclusive - All Registrants " "(WR_EX_AR): %d\n", - (cap->type_mask[0] & SPRI_TM_WR_EX_AR)? 1 : 0); + (type_mask & SPRI_TM_WR_EX_AR)? 1 : 0); fprintf(stdout, " Exclusive Access - Registrants Only " "(EX_AC_RO): %d\n", - (cap->type_mask[0] & SPRI_TM_EX_AC_RO) ? 1 : 0); + (type_mask & SPRI_TM_EX_AC_RO) ? 1 : 0); fprintf(stdout, " Write Exclusive - Registrants Only " "(WR_EX_RO): %d\n", - (cap->type_mask[0] & SPRI_TM_WR_EX_RO)? 1 : 0); + (type_mask & SPRI_TM_WR_EX_RO)? 1 : 0); fprintf(stdout, " Exclusive Access (EX_AC): %d\n", - (cap->type_mask[0] & SPRI_TM_EX_AC) ? 1 : 0); + (type_mask & SPRI_TM_EX_AC) ? 1 : 0); fprintf(stdout, " Write Exclusive (WR_EX): %d\n", - (cap->type_mask[0] & SPRI_TM_WR_EX) ? 1 : 0); + (type_mask & SPRI_TM_WR_EX) ? 1 : 0); fprintf(stdout, " Exclusive Access - All Registrants " "(EX_AC_AR): %d\n", - (cap->type_mask[1] & SPRI_TM_EX_AC_AR) ? 1 : 0); + (type_mask & SPRI_TM_EX_AC_AR) ? 1 : 0); } else { fprintf(stdout, "Persistent Reservation Type Mask is NOT " "valid\n"); diff --git a/sbin/camcontrol/timestamp.c b/sbin/camcontrol/timestamp.c index 6c1f5f0..771c8f7 100644 --- a/sbin/camcontrol/timestamp.c +++ b/sbin/camcontrol/timestamp.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -139,6 +140,8 @@ set_restore_flags(struct cam_device *device, uint8_t *flags, int set_flag, * Create the control page at the correct point in the mode_buf, it * starts after the header and the blk description. */ + assert(hdr_and_blk_length <= + sizeof(mode_buf) - sizeof(struct scsi_control_ext_page)); control_page = (struct scsi_control_ext_page *)&mode_buf [hdr_and_blk_length]; if (set_flag != 0) { @@ -241,6 +244,7 @@ report_timestamp(struct cam_device *device, uint64_t *ts, int task_attr, bailout: if (ccb != NULL) cam_freeccb(ccb); + free(report_buf); return error; } |