[<prev] [next>] [day] [month] [year] [list]
Message-Id: <200702100211.l1A2BiQE007552@igsi.llnl.gov>
Date: Fri, 9 Feb 2007 18:11:44 -0800
From: "Brian D. Behlendorf" <behlendorf1@...l.gov>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org, adilger@...sterfs.com,
behlendorf1@...l.gov, wartens2@...l.gov
Subject: e2fsprogs coverity patch <cid-9.diff>
Lawrence Livermore National Labs recently ran the source code
analysis tool Coverity over the e2fsprogs-1.39 source to see
if it would identify any significant bugs. The analysis
turned up 38 mostly minor issues which are enumerated here
with patches. We went through and resolved these issues
but would love to see these mostly minor changes reviewed
and commited upstream.
Thanks,
Brian Behlendorf <behlendorf1@...l.gov>, and
Herb Wartens <wartens2@...l.gov>
-----------------------------------------------------------------------------
Coverity ID: 9: Null Returns
dict_lookup() can potentially return a NULL dnode_t. It is not
checked in two places in the clone_file() function. Looks to be
safe to check if n is not NULL. If n is NULL then point out the
error.
Index: e2fsprogs+chaos/e2fsck/pass1b.c
===================================================================
--- e2fsprogs+chaos.orig/e2fsck/pass1b.c
+++ e2fsprogs+chaos/e2fsck/pass1b.c
@@ -752,19 +752,33 @@ static int clone_file(e2fsck_t ctx, ext2
* them to point to the new EA block.
*/
n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk));
- db = (struct dup_block *) dnode_get(n);
- for (ino_el = db->inode_list; ino_el; ino_el = ino_el->next) {
- if (ino_el->inode == ino)
- continue;
- n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode));
- di = (struct dup_inode *) dnode_get(n);
- if (di->inode.i_file_acl == blk) {
- di->inode.i_file_acl = dp->inode.i_file_acl;
- e2fsck_write_inode(ctx, ino_el->inode,
- &di->inode, "clone file EA");
- decrement_badcount(ctx, blk, db);
+ if (n) {
+ db = (struct dup_block *) dnode_get(n);
+ for (ino_el = db->inode_list; ino_el; ino_el = ino_el->next) {
+ if (ino_el->inode == ino)
+ continue;
+ n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode));
+ if (n) {
+ di = (struct dup_inode *) dnode_get(n);
+ if (di->inode.i_file_acl == blk) {
+ di->inode.i_file_acl = dp->inode.i_file_acl;
+ e2fsck_write_inode(ctx, ino_el->inode,
+ &di->inode, "clone file EA");
+ decrement_badcount(ctx, blk, db);
+ }
+ }
+ else {
+ com_err("clone_file", 0,
+ _("internal error; can't find dup_blk for %u\n"),
+ ino_el->inode);
+ }
}
}
+ else {
+ com_err("clone_file", 0,
+ _("internal error; can't find dup_blk for %u\n"),
+ blk);
+ }
}
retval = 0;
errout:
-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists