From 38a099e9c632c1ad11487bf9671d5d2e0c8b8258 Mon Sep 17 00:00:00 2001 From: Gollu Appalanaidu Date: Thu, 27 May 2021 12:02:28 +0530 Subject: [PATCH] nvme: add persistent event log action field invalid check Signed-off-by: Gollu Appalanaidu --- nvme.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nvme.c b/nvme.c index 3ad1cd99..c18ac84e 100644 --- a/nvme.c +++ b/nvme.c @@ -913,7 +913,7 @@ static int get_persistent_event_log(int argc, char **argv, const char *log_len = "number of bytes to retrieve"; const char *raw = "use binary output"; void *pevent_log_info; - struct nvme_persistent_event_log_head *pevent_log_head; + struct nvme_persistent_event_log_head *pevent_log_head = NULL; enum nvme_print_flags flags; int err, fd; bool huge; @@ -949,6 +949,13 @@ static int get_persistent_event_log(int argc, char **argv, if (cfg.raw_binary) flags = BINARY; + if (cfg.action > 3) { + fprintf(stderr, "invalid action field: %u\n", cfg.action); + errno = EINVAL; + err = -1; + goto close_fd; + } + pevent_log_head = calloc(sizeof(*pevent_log_head), 1); if (!pevent_log_head) { perror("could not alloc buffer for persistent " \ -- 2.50.1