Whamcloud - gitweb
[COVERITY] Free potential null dereference bug in e2fsck
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 31 May 2007 15:42:48 +0000 (11:42 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 31 May 2007 15:42:48 +0000 (11:42 -0400)
At the second conditional iter->file could still be NULL. We need to
check for it again.  Should never happen in practice, but better to be
sure.

Coverity ID: 6: Forward Null

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/ChangeLog
e2fsck/profile.c

index bbd23ad..e6b0fdf 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-31  Theodore Tso  <tytso@mit.edu>
+
+       * profile.c (profile_node_iterator): Avoid potential null
+               dereference bug.
+
 2007-05-22  Theodore Tso  <tytso@mit.edu>
 
        * message.c (expand_inode_expression, expand_percent_expression):
index 5752343..d46833c 100644 (file)
@@ -1265,7 +1265,8 @@ errcode_t profile_node_iterator(void **iter_p, struct profile_node **ret_node,
         * If the file has changed, then the node pointer is invalid,
         * so we'll have search the file again looking for it.
         */
-       if (iter->node && (iter->file->upd_serial != iter->file_serial)) {
+       if (iter->node && (iter->file && 
+                          iter->file->upd_serial != iter->file_serial)) {
                iter->flags &= ~PROFILE_ITER_FINAL_SEEN;
                skip_num = iter->num;
                iter->node = 0;
@@ -1349,8 +1350,6 @@ get_new_file:
        iter->num++;
        if (!p) {
                iter->file = iter->file->next;
-               if (iter->file) {
-               }
                iter->node = 0;
                skip_num = 0;
                goto get_new_file;