From: Jan Kara Subject: Strangeness in generic_readlink() Date: Wed, 15 Jul 2015 10:36:16 +0200 Message-ID: <20150715083616.GB22609@quack.suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org To: Al Viro Return-path: Received: from cantor2.suse.de ([195.135.220.15]:50854 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751812AbbGOIgV (ORCPT ); Wed, 15 Jul 2015 04:36:21 -0400 Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 SUSE Labs, CR