Strangeness in generic_readlink()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  Hello,

Coverity has drawn my attention to a strange code in generic_readlink().
We do there:
        const char *link = inode->i_link;

        if (!link) {
                link = inode->i_op->follow_link(dentry, &cookie);
                if (IS_ERR(link))
                        return PTR_ERR(link);
        }
        res = readlink_copy(buffer, buflen, link);
        if (inode->i_op->put_link)
                inode->i_op->put_link(inode, cookie);

However when inode->i_link is set and the inode also has put_link method,
we would pass uninitialized cookie to put_link.

Now if I understand the code right, each inode is supposed to use either
i_link or cookies so this shouldn't really happen but IMHO it's
unnecessarily fragile. I'd prefer to call put_link only if follow_link was
called in generic_readlink(). Thoughts?

								Honza
-- 
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux