summaryrefslogtreecommitdiffstats
path: root/fs/coda/psdev.c
diff options
context:
space:
mode:
authorZhouyang Jia <jiazhouyang09@gmail.com>2019-07-16 16:28:13 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-06 18:29:38 +0200
commitca62806b39552cfcf62db15bdc7247d464fe0023 (patch)
tree00fa9ea8a1c097cc7182d3cca1d444e3f4c3f18d /fs/coda/psdev.c
parentad2041109001a00175ad19fa0b1f8f9b4aebaeb4 (diff)
downloadlinux-stable-ca62806b39552cfcf62db15bdc7247d464fe0023.tar.gz
linux-stable-ca62806b39552cfcf62db15bdc7247d464fe0023.tar.bz2
linux-stable-ca62806b39552cfcf62db15bdc7247d464fe0023.zip
coda: add error handling for fget
[ Upstream commit 02551c23bcd85f0c68a8259c7b953d49d44f86af ] When fget fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling fget. Link: http://lkml.kernel.org/r/2514ec03df9c33b86e56748513267a80dd8004d9.1558117389.git.jaharkes@cs.cmu.edu Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com> Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Colin Ian King <colin.king@canonical.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: David Howells <dhowells@redhat.com> Cc: Fabian Frederick <fabf@skynet.be> Cc: Mikko Rapeli <mikko.rapeli@iki.fi> Cc: Sam Protsenko <semen.protsenko@linaro.org> Cc: Yann Droneaud <ydroneaud@opteya.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/coda/psdev.c')
-rw-r--r--fs/coda/psdev.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 822629126e89..ff9b5cf8ff01 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -187,8 +187,11 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
if (req->uc_opcode == CODA_OPEN_BY_FD) {
struct coda_open_by_fd_out *outp =
(struct coda_open_by_fd_out *)req->uc_data;
- if (!outp->oh.result)
+ if (!outp->oh.result) {
outp->fh = fget(outp->fd);
+ if (!outp->fh)
+ return -EBADF;
+ }
}
wake_up(&req->uc_sleep);