Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: fix dentry leak upon mkdir failure.

syzbot is reporting that nfsd_mkdir() forgot to remove dentry created by
d_alloc_name() when __nfsd_mkdir() failed (due to memory allocation fault
injection) [1].

[1] https://syzkaller.appspot.com/bug?id=ce41a1f769ea4637ebffedf004a803e8405b4674

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+2c95195d5d433f6ed6cb@syzkaller.appspotmail.com>
Fixes: e8a79fb14f6b76b5 ("nfsd: add nfsd/clients directory")
[bfields: clean up in nfsd_mkdir instead of __nfsd_mkdir]
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Tetsuo Handa and committed by
J. Bruce Fields
d6846bfb 609488bc

+1
+1
fs/nfsd/nfsctl.c
··· 1205 1205 inode_unlock(dir); 1206 1206 return dentry; 1207 1207 out_err: 1208 + dput(dentry); 1208 1209 dentry = ERR_PTR(ret); 1209 1210 goto out; 1210 1211 }