[FIX] prevent issues 08/46908/2
authorAnatolii Nikulin <nikulin.a@samsung.com>
Thu, 27 Aug 2015 06:55:50 +0000 (09:55 +0300)
committerAnatolii Nikulin <nikulin.a@samsung.com>
Thu, 27 Aug 2015 09:54:12 +0000 (12:54 +0300)
fix 4 issues from prevent:
NULL_RETURNS
CONSTANT_EXPRESSION_RESULT
NO_EFFECT

Change-Id: I1385346d039a354a862e516e3b48c841502bf630
Signed-off-by: Anatolii Nikulin <nikulin.a@samsung.com>
fbiprobe/fbiprobe.c
us_manager/img/img_file.c
us_manager/img/img_proc.c

index bd51162..9690294 100644 (file)
@@ -340,7 +340,7 @@ int fbi_probe_copy(struct probe_info *dest, const struct probe_info *source)
        struct fbi_var_data *vars;
        struct fbi_step *steps_source;
        struct fbi_step *steps_dest = NULL;
-       uint8_t i;
+       uint8_t i, n;
        int ret = 0;
 
        memcpy(dest, source, sizeof(*source));
@@ -362,6 +362,7 @@ int fbi_probe_copy(struct probe_info *dest, const struct probe_info *source)
                        steps_dest = kmalloc(steps_size, GFP_KERNEL);
                        if (steps_dest == NULL) {
                                print_err("can not alloc data\n");
+                               n = i;
                                ret = -ENOMEM;
                                goto err;
                        }
@@ -375,7 +376,7 @@ int fbi_probe_copy(struct probe_info *dest, const struct probe_info *source)
 
        return ret;
 err:
-       while (--i >= 0)
+       for (i = 0; i < n; i++)
                kfree(vars[i].steps);
        kfree(vars);
        return ret;
index c670ca7..2b5bbcd 100644 (file)
@@ -42,6 +42,11 @@ struct img_file *create_img_file(struct dentry *dentry)
        struct img_file *file;
 
        file = kmalloc(sizeof(*file), GFP_KERNEL);
+       if (file == NULL) {
+               pr_err("%s: failed to allocate memory\n", __func__);
+               return NULL;
+       }
+
        file->dentry = dentry;
        INIT_LIST_HEAD(&file->ip_list);
        INIT_LIST_HEAD(&file->list);
index 2029c2e..e591b27 100644 (file)
@@ -181,14 +181,17 @@ void img_proc_copy_to_sspt(struct img_proc *i_proc, struct sspt_proc *proc)
 {
        struct sspt_file *file;
        struct img_file *i_file;
-       struct img_ip *i_ip;
 
        read_lock(&i_proc->rwlock);
        list_for_each_entry(i_file, &i_proc->file_list, list) {
                file = sspt_proc_find_file_or_new(proc, i_file->dentry);
 
-               list_for_each_entry(i_ip, &i_file->ip_list, list)
-                       sspt_file_add_ip(file, i_ip->addr, i_ip->info);
+               if (file) {
+                       struct img_ip *i_ip;
+
+                       list_for_each_entry(i_ip, &i_file->ip_list, list)
+                               sspt_file_add_ip(file, i_ip->addr, i_ip->info);
+               }
        }
        read_unlock(&i_proc->rwlock);
 }