[Cluster-devel] [bug report] new ->follow_link() and ->put_link() calling conventions

Dan Carpenter dan.carpenter at oracle.com
Tue Aug 31 10:07:30 UTC 2021


Hello GFS2 devs,

The ancient patch 680baacbca69: "new ->follow_link() and ->put_link()
calling conventions" from May 2, 2015, leads to the following
Smatch static checker warning:

	fs/gfs2/inode.c:1806 gfs2_get_link()
	error: passing non negative 13 to ERR_PTR

fs/gfs2/inode.c
    1788 static const char *gfs2_get_link(struct dentry *dentry,
    1789                                  struct inode *inode,
    1790                                  struct delayed_call *done)
    1791 {
    1792         struct gfs2_inode *ip = GFS2_I(inode);
    1793         struct gfs2_holder i_gh;
    1794         struct buffer_head *dibh;
    1795         unsigned int size;
    1796         char *buf;
    1797         int error;
    1798 
    1799         if (!dentry)
    1800                 return ERR_PTR(-ECHILD);
    1801 
    1802         gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
                                                          ^
i_gh.gh_flags = 0;  The async flag is not set.

    1803         error = gfs2_glock_nq(&i_gh);

So that means gfs2_glock_nq() can return GLR_TRYFAILED (13).

    1804         if (error) {
    1805                 gfs2_holder_uninit(&i_gh);
--> 1806                 return ERR_PTR(error);
                                ^^^^^^^^^^^^^^
Which will lead to an Oops in the caller.

    1807         }
    1808 
    1809         size = (unsigned int)i_size_read(&ip->i_inode);
    1810         if (size == 0) {
    1811                 gfs2_consist_inode(ip);
    1812                 buf = ERR_PTR(-EIO);
    1813                 goto out;
    1814         }
    1815 
    1816         error = gfs2_meta_inode_buffer(ip, &dibh);
    1817         if (error) {

regards,
dan carpenter




More information about the Cluster-devel mailing list