Commit 20818a0c authored by Al Viro's avatar Al Viro

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 09fada5b
...@@ -654,9 +654,8 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) ...@@ -654,9 +654,8 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
if (!(filp->f_mode & FMODE_WRITE)) if (!(filp->f_mode & FMODE_WRITE))
ro = 1; ro = 1;
if (filp->f_path.dentry) inode = filp->f_path.dentry->d_inode;
inode = filp->f_path.dentry->d_inode; if ((!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))) {
if (!inode || (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))) {
LINFO(curlun, "invalid file type: %s\n", filename); LINFO(curlun, "invalid file type: %s\n", filename);
goto out; goto out;
} }
...@@ -665,7 +664,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) ...@@ -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 read the file, it's no good.
* If we can't write the file, use it read-only. * 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); LINFO(curlun, "file not readable: %s\n", filename);
goto out; goto out;
} }
...@@ -707,16 +706,15 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) ...@@ -707,16 +706,15 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
goto out; goto out;
} }
get_file(filp);
curlun->ro = ro; curlun->ro = ro;
curlun->filp = filp; curlun->filp = filp;
curlun->file_length = size; curlun->file_length = size;
curlun->num_sectors = num_sectors; curlun->num_sectors = num_sectors;
LDBG(curlun, "open backing file: %s\n", filename); LDBG(curlun, "open backing file: %s\n", filename);
rc = 0; return 0;
out: out:
filp_close(filp, current->files); fput(filp);
return rc; return rc;
} }
......
...@@ -275,17 +275,17 @@ static int gaudio_close_snd_dev(struct gaudio *gau) ...@@ -275,17 +275,17 @@ static int gaudio_close_snd_dev(struct gaudio *gau)
/* Close control device */ /* Close control device */
snd = &gau->control; snd = &gau->control;
if (snd->filp) if (snd->filp)
filp_close(snd->filp, current->files); filp_close(snd->filp, NULL);
/* Close PCM playback device and setup substream */ /* Close PCM playback device and setup substream */
snd = &gau->playback; snd = &gau->playback;
if (snd->filp) if (snd->filp)
filp_close(snd->filp, current->files); filp_close(snd->filp, NULL);
/* Close PCM capture device and setup substream */ /* Close PCM capture device and setup substream */
snd = &gau->capture; snd = &gau->capture;
if (snd->filp) if (snd->filp)
filp_close(snd->filp, current->files); filp_close(snd->filp, NULL);
return 0; return 0;
} }
......
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