]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
nvme zns: segmentation fault in cmd "nvme zns zone-mgmt-send"
authorAravind Ramesh <aravind.ramesh@wdc.com>
Mon, 29 Jun 2020 04:49:29 +0000 (10:19 +0530)
committerKeith Busch <kbusch@kernel.org>
Tue, 30 Jun 2020 17:30:01 +0000 (11:30 -0600)
zone_mgmt_send function calls strlen() on a null ptr causing the
segmentation fault. Check the pointer instead of len.

Signed-off-by: Aravind Ramesh <Aravind.Ramesh@wdc.com>
plugins/zns/zns.c

index 803887d5ff8ee07bc51406df837f64758313ac07..dbe9ad7cb5ba775ed31a1d7a6ab8ad746120079e 100644 (file)
@@ -264,15 +264,14 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu
                goto close_fd;
        }
 
-       if (cfg.zsa == NVME_ZNS_ZSA_SET_DESC_EXT){
-               if(!cfg.data_len){
+       if (cfg.zsa == NVME_ZNS_ZSA_SET_DESC_EXT) {
+               if(!cfg.data_len) {
                        cfg.data_len = get_zdes_bytes(fd, cfg.namespace_id);
-                       if (cfg.data_len == 0){
+                       if (cfg.data_len == 0) {
                                fprintf(stderr, 
                                "Zone Descriptor Extensions are not supported\n");
                                goto close_fd;
-                       }
-                       else if (cfg.data_len < 0) {
+                       } else if (cfg.data_len < 0) {
                                err = cfg.data_len;
                                goto close_fd;
                        }
@@ -296,9 +295,8 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu
                        perror("read");
                        goto close_ffd;
                }
-       }
-       else{
-               if (strlen(cfg.file) || cfg.data_len){
+       } else {
+               if (cfg.file || cfg.data_len) {
                        fprintf(stderr, 
                        "data, data_len only valid with set extended descriptor\n");
                        err = -EINVAL;