summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/storage_common.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-07-22 21:23:33 +0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-29 21:24:21 +0400
commit20818a0caa84adbfe2f1e9c0e036f5b09a9692a2 (patch)
tree1e5281da3ca21fa0d7fdccd1d6e93277bdff5ba1 /drivers/usb/gadget/storage_common.c
parent09fada5b5f1f56502bb14f36a69a2c31cea262be (diff)
downloadlinux-20818a0caa84adbfe2f1e9c0e036f5b09a9692a2.tar.gz
linux-20818a0caa84adbfe2f1e9c0e036f5b09a9692a2.tar.bz2
linux-20818a0caa84adbfe2f1e9c0e036f5b09a9692a2.zip
gadgetfs: clean up
sigh... * opened files have non-NULL dentries and non-NULL inodes * close_filp() needs current->files only if the file had been in descriptor table. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/usb/gadget/storage_common.c')
-rw-r--r--drivers/usb/gadget/storage_common.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 8081ca3a70a2..f92943246820 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -654,9 +654,8 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
if (!(filp->f_mode & FMODE_WRITE))
ro = 1;
- if (filp->f_path.dentry)
- inode = filp->f_path.dentry->d_inode;
- if (!inode || (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))) {
+ inode = filp->f_path.dentry->d_inode;
+ if ((!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))) {
LINFO(curlun, "invalid file type: %s\n", filename);
goto out;
}
@@ -665,7 +664,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
* If we can't read the file, it's no good.
* If we can't write the file, use it read-only.
*/
- if (!filp->f_op || !(filp->f_op->read || filp->f_op->aio_read)) {
+ if (!(filp->f_op->read || filp->f_op->aio_read)) {
LINFO(curlun, "file not readable: %s\n", filename);
goto out;
}
@@ -707,16 +706,15 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
goto out;
}
- get_file(filp);
curlun->ro = ro;
curlun->filp = filp;
curlun->file_length = size;
curlun->num_sectors = num_sectors;
LDBG(curlun, "open backing file: %s\n", filename);
- rc = 0;
+ return 0;
out:
- filp_close(filp, current->files);
+ fput(filp);
return rc;
}