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@xxxxxxxx>, and Herb Wartens <wartens2@xxxxxxxx> ----------------------------------------------------------------------------- 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@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html