Skip to content

Commit

Permalink
Merge tag 'configfs-for-5.12' of git://git.infradead.org/users/hch/co…
Browse files Browse the repository at this point in the history
…nfigfs

Pull configfs fix from Christoph Hellwig:

 - fix a use-after-free in __configfs_open_file (Daiyue Zhang)

* tag 'configfs-for-5.12' of git://git.infradead.org/users/hch/configfs:
  configfs: fix a use-after-free in __configfs_open_file
  • Loading branch information
torvalds committed Mar 12, 2021
2 parents b77b5fd + 14fbbc8 commit 8d9d53d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/configfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type

attr = to_attr(dentry);
if (!attr)
goto out_put_item;
goto out_free_buffer;

if (type & CONFIGFS_ITEM_BIN_ATTR) {
buffer->bin_attr = to_bin_attr(dentry);
Expand All @@ -391,7 +391,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
/* Grab the module reference for this attribute if we have one */
error = -ENODEV;
if (!try_module_get(buffer->owner))
goto out_put_item;
goto out_free_buffer;

error = -EACCES;
if (!buffer->item->ci_type)
Expand Down Expand Up @@ -435,8 +435,6 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type

out_put_module:
module_put(buffer->owner);
out_put_item:
config_item_put(buffer->item);
out_free_buffer:
up_read(&frag->frag_sem);
kfree(buffer);
Expand Down

0 comments on commit 8d9d53d

Please sign in to comment.