Commit cdca8d0c authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[PATCH] possible of memory leak of driverfs_mknod()

This patch fixes memory leak of driverfs_mknod(), and changes odd
error code.
parent 3334a8ca
...@@ -130,14 +130,15 @@ struct inode *driverfs_get_inode(struct super_block *sb, int mode, int dev) ...@@ -130,14 +130,15 @@ struct inode *driverfs_get_inode(struct super_block *sb, int mode, int dev)
static int driverfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev) static int driverfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev)
{ {
struct inode *inode = driverfs_get_inode(dir->i_sb, mode, dev); struct inode *inode;
int error = -EPERM; int error = -ENOSPC;
if (dentry->d_inode) if (dentry->d_inode)
return -EEXIST; return -EEXIST;
/* only allow create if ->d_fsdata is not NULL (so we can assume it /* only allow create if ->d_fsdata is not NULL (so we can assume it
* comes from the driverfs API below. */ * comes from the driverfs API below. */
inode = driverfs_get_inode(dir->i_sb, mode, dev);
if (inode) { if (inode) {
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
dget(dentry); dget(dentry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment