Goldwyn Rodrigues <rgoldwyn@xxxxxxx> wrote: Goldwyn Rodrigues <rgoldwyn@xxxxxxx> wrote: > > +static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) > > +{ > > + struct fs_context *fc; > > + struct vfsmount *mnt; > > + int ret; > > + > > + BUG_ON(!d_inode(mntpt)); > > + > > + fc = vfs_new_fs_context(&afs_fs_type, mntpt, 0, > > + FS_CONTEXT_FOR_SUBMOUNT); > > + if (IS_ERR(fc)) > > + return ERR_CAST(fc); > > + > > + ret = afs_mntpt_set_params(fc, mntpt); > > + if (ret < 0) > > + goto error_fc; > > + > > + ret = vfs_get_tree(fc); > > + if (ret < 0) > > + goto error_fc; > > + > > + mnt = vfs_create_mount(fc, 0); > > + if (IS_ERR(mnt)) { > > + ret = PTR_ERR(mnt); > > + goto error_fc; > > + } > > > > - free_page((unsigned long) devname); > > - free_page((unsigned long) options); > > - _leave(" = %p", mnt); > > + put_fs_context(fc); > > return mnt; > > > Why are you performing a put_fs_context(fc) in the success code path? Do > we not need a reference of fc anymore? No. This is the ->d_automount() hook. The context is created at the top of the function, configuration is done, the superblock is obtained, a mount object is created (for which we get a ref returned). After that point, we don't need the context any more and no one else is going to clean it up for us. David