Commit 489c1ffa authored by Zhouyang Jia's avatar Zhouyang Jia Committed by Stefan Bader

coda: add error handling for fget

BugLink: https://bugs.launchpad.net/bugs/1840289

[ Upstream commit 02551c23 ]

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.eduSigned-off-by: default avatarZhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: default avatarJan 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 4394743f
...@@ -187,8 +187,11 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, ...@@ -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) { if (req->uc_opcode == CODA_OPEN_BY_FD) {
struct coda_open_by_fd_out *outp = struct coda_open_by_fd_out *outp =
(struct coda_open_by_fd_out *)req->uc_data; (struct coda_open_by_fd_out *)req->uc_data;
if (!outp->oh.result) if (!outp->oh.result) {
outp->fh = fget(outp->fd); outp->fh = fget(outp->fd);
if (!outp->fh)
return -EBADF;
}
} }
wake_up(&req->uc_sleep); wake_up(&req->uc_sleep);
......
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