diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-22 13:23:33 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-29 13:24:21 -0400 |
commit | 20818a0caa84adbfe2f1e9c0e036f5b09a9692a2 (patch) | |
tree | 1e5281da3ca21fa0d7fdccd1d6e93277bdff5ba1 /drivers/usb | |
parent | 09fada5b5f1f56502bb14f36a69a2c31cea262be (diff) |
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')
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 12 | ||||
-rw-r--r-- | drivers/usb/gadget/u_uac1.c | 6 |
2 files changed, 8 insertions, 10 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) | |||
654 | if (!(filp->f_mode & FMODE_WRITE)) | 654 | if (!(filp->f_mode & FMODE_WRITE)) |
655 | ro = 1; | 655 | ro = 1; |
656 | 656 | ||
657 | if (filp->f_path.dentry) | 657 | inode = filp->f_path.dentry->d_inode; |
658 | inode = filp->f_path.dentry->d_inode; | 658 | if ((!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))) { |
659 | if (!inode || (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))) { | ||
660 | LINFO(curlun, "invalid file type: %s\n", filename); | 659 | LINFO(curlun, "invalid file type: %s\n", filename); |
661 | goto out; | 660 | goto out; |
662 | } | 661 | } |
@@ -665,7 +664,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) | |||
665 | * If we can't read the file, it's no good. | 664 | * If we can't read the file, it's no good. |
666 | * If we can't write the file, use it read-only. | 665 | * If we can't write the file, use it read-only. |
667 | */ | 666 | */ |
668 | if (!filp->f_op || !(filp->f_op->read || filp->f_op->aio_read)) { | 667 | if (!(filp->f_op->read || filp->f_op->aio_read)) { |
669 | LINFO(curlun, "file not readable: %s\n", filename); | 668 | LINFO(curlun, "file not readable: %s\n", filename); |
670 | goto out; | 669 | goto out; |
671 | } | 670 | } |
@@ -707,16 +706,15 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) | |||
707 | goto out; | 706 | goto out; |
708 | } | 707 | } |
709 | 708 | ||
710 | get_file(filp); | ||
711 | curlun->ro = ro; | 709 | curlun->ro = ro; |
712 | curlun->filp = filp; | 710 | curlun->filp = filp; |
713 | curlun->file_length = size; | 711 | curlun->file_length = size; |
714 | curlun->num_sectors = num_sectors; | 712 | curlun->num_sectors = num_sectors; |
715 | LDBG(curlun, "open backing file: %s\n", filename); | 713 | LDBG(curlun, "open backing file: %s\n", filename); |
716 | rc = 0; | 714 | return 0; |
717 | 715 | ||
718 | out: | 716 | out: |
719 | filp_close(filp, current->files); | 717 | fput(filp); |
720 | return rc; | 718 | return rc; |
721 | } | 719 | } |
722 | 720 | ||
diff --git a/drivers/usb/gadget/u_uac1.c b/drivers/usb/gadget/u_uac1.c index af9898982059..e0c5e88e03ed 100644 --- a/drivers/usb/gadget/u_uac1.c +++ b/drivers/usb/gadget/u_uac1.c | |||
@@ -275,17 +275,17 @@ static int gaudio_close_snd_dev(struct gaudio *gau) | |||
275 | /* Close control device */ | 275 | /* Close control device */ |
276 | snd = &gau->control; | 276 | snd = &gau->control; |
277 | if (snd->filp) | 277 | if (snd->filp) |
278 | filp_close(snd->filp, current->files); | 278 | filp_close(snd->filp, NULL); |
279 | 279 | ||
280 | /* Close PCM playback device and setup substream */ | 280 | /* Close PCM playback device and setup substream */ |
281 | snd = &gau->playback; | 281 | snd = &gau->playback; |
282 | if (snd->filp) | 282 | if (snd->filp) |
283 | filp_close(snd->filp, current->files); | 283 | filp_close(snd->filp, NULL); |
284 | 284 | ||
285 | /* Close PCM capture device and setup substream */ | 285 | /* Close PCM capture device and setup substream */ |
286 | snd = &gau->capture; | 286 | snd = &gau->capture; |
287 | if (snd->filp) | 287 | if (snd->filp) |
288 | filp_close(snd->filp, current->files); | 288 | filp_close(snd->filp, NULL); |
289 | 289 | ||
290 | return 0; | 290 | return 0; |
291 | } | 291 | } |