]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix coverity defects: CID 150953, 147603, 147610
authorluozhengzheng <luo.zhengzheng@zte.com.cn>
Wed, 5 Oct 2016 01:15:57 +0000 (09:15 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 5 Oct 2016 01:15:57 +0000 (18:15 -0700)
coverity scan CID:150953,type: uninitialized scalar variable
coverity scan CID:147603,type: Resource leak
coverity scan CID:147610,type: Resource leak

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5209

cmd/zfs/zfs_main.c
lib/libzpool/kernel.c
module/icp/io/aes.c

index bf9a7924801f46e79e47ad27d35e3420cf01af19..fedc1a04da34af95424dce59e7db26df945b4f57 100644 (file)
@@ -6120,8 +6120,11 @@ share_mount(int op, int argc, char **argv)
                start_progress_timer();
                get_all_datasets(&dslist, &count, verbose);
 
-               if (count == 0)
+               if (count == 0) {
+                       if (options != NULL)
+                               free(options);
                        return (0);
+               }
 
                qsort(dslist, count, sizeof (void *), libzfs_dataset_cmp);
 
@@ -6153,8 +6156,11 @@ share_mount(int op, int argc, char **argv)
                 */
 
                /* Reopen MNTTAB to prevent reading stale data from open file */
-               if (freopen(MNTTAB, "r", mnttab_file) == NULL)
+               if (freopen(MNTTAB, "r", mnttab_file) == NULL) {
+                       if (options != NULL)
+                               free(options);
                        return (ENOENT);
+               }
 
                while (getmntent(mnttab_file, &entry) == 0) {
                        if (strcmp(entry.mnt_fstype, MNTTYPE_ZFS) != 0 ||
@@ -6184,6 +6190,9 @@ share_mount(int op, int argc, char **argv)
                }
        }
 
+       if (options != NULL)
+               free(options);
+
        return (ret);
 }
 
index 60dda39a8e8c6392611d8214758ff3e338977d84..579626220457067e429c353f4ac6ee5b74233480 100755 (executable)
@@ -599,8 +599,8 @@ cv_broadcast(kcondvar_t *cv)
 int
 vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
 {
-       int fd;
-       int dump_fd;
+       int fd = -1;
+       int dump_fd = -1;
        vnode_t *vp;
        int old_umask = 0;
        char *realpath;
@@ -698,6 +698,8 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
        if (fstat64_blk(fd, &st) == -1) {
                err = errno;
                close(fd);
+               if (dump_fd != -1)
+                       close(dump_fd);
                return (err);
        }
 
index ada697eb6d5295db3fa96322760988d5a972f2e5..7fd66be3e063261782e9d13d0c7b8b187d5c766b 100644 (file)
@@ -1282,7 +1282,7 @@ aes_common_init_ctx(aes_ctx_t *aes_ctx, crypto_spi_ctx_template_t *template,
 {
        int rv = CRYPTO_SUCCESS;
        void *keysched;
-       size_t size;
+       size_t size = 0;
 
        if (template == NULL) {
                if ((keysched = aes_alloc_keysched(&size, kmflag)) == NULL)