a couple of leaks on failure exits missing fdput()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQQqUNBr3gm4hGXdBJlZ7Krx/gZQ6wUCZllLrAAKCRBZ7Krx/gZQ
 65n8AP40w8ghf88QMpI6jhxmxQdaiGFQp+AohS/iwyX7t8PgqgEAuhkcmGJpGahr
 GZq6/dxugqyNwCtNJPBWAr2x4GXbaA0=
 =+J5A
 -----END PGP SIGNATURE-----

Merge tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull struct file leak fixes from Al Viro:
 "a couple of leaks on failure exits missing fdput()"

* tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  lirc: rc_dev_get_from_fd(): fix file leak
  powerpc: fix a file leak in kvm_vcpu_ioctl_enable_cap()
This commit is contained in:
Linus Torvalds 2024-07-26 10:26:33 -07:00
commit dd90ad50cb
2 changed files with 6 additions and 2 deletions

View File

@ -1984,8 +1984,10 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
break;
r = -ENXIO;
if (!xive_enabled())
if (!xive_enabled()) {
fdput(f);
break;
}
r = -EPERM;
dev = kvm_device_from_filp(f.file);

View File

@ -828,8 +828,10 @@ struct rc_dev *rc_dev_get_from_fd(int fd, bool write)
return ERR_PTR(-EINVAL);
}
if (write && !(f.file->f_mode & FMODE_WRITE))
if (write && !(f.file->f_mode & FMODE_WRITE)) {
fdput(f);
return ERR_PTR(-EPERM);
}
fh = f.file->private_data;
dev = fh->rc;