]> git.droids-corp.org - dpdk.git/commitdiff
crypto/caam_jr: fix memory leak and illegal access
authorGagandeep Singh <g.singh@nxp.com>
Tue, 9 Apr 2019 06:18:38 +0000 (06:18 +0000)
committerAkhil Goyal <akhil.goyal@nxp.com>
Thu, 18 Apr 2019 14:01:28 +0000 (16:01 +0200)
Opendir() returns allocated storage which must be freed at the
end of function or in case any return on error. so freeing the
allocation using closedir in an error case.

Coverity issue: 323507
Coverity issue: 325880
Fixes: e7a45f3cc245 ("crypto/caam_jr: add UIO specific operations")
Cc: stable@dpdk.org
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/crypto/caam_jr/caam_jr_uio.c

index bf872a220a902358626feeb8a3b1652e6b5c6b64..afd75c9a628709f67d09a9ab41d445c1b4371bda 100644 (file)
@@ -362,8 +362,8 @@ free_job_ring(uint32_t uio_fd)
                        job_ring->register_base_addr,
                        (unsigned long)job_ring->map_size, strerror(errno));
        } else
-               CAAM_JR_DEBUG("  JR UIO memory unmapped at %p",
-                               job_ring->register_base_addr);
+               CAAM_JR_DEBUG("JR UIO memory is unmapped");
+
        job_ring->register_base_addr = NULL;
 }
 
@@ -445,7 +445,11 @@ sec_configure(void)
                        ret = file_read_first_line(SEC_UIO_DEVICE_SYS_ATTR_PATH,
                                        dir->d_name, "name", uio_name);
                        CAAM_JR_INFO("sec device uio name: %s", uio_name);
-                       SEC_ASSERT(ret == 0, -1, "file_read_first_line failed");
+                       if (ret != 0) {
+                               CAAM_JR_ERR("file_read_first_line failed\n");
+                               closedir(d);
+                               return -1;
+                       }
 
                        if (file_name_match_extract(uio_name,
                                                SEC_UIO_DEVICE_NAME,