Messages in this thread Patch in this message | | | From | Zhouyang Jia <> | Subject | [PATCH] fs/coda: add error handling for fget | Date | Tue, 12 Jun 2018 12:34:12 +0800 |
| |
When fget fails, the lack of error-handling code may cause unexpected results.
This patch adds error-handling code after calling fget.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com> --- fs/coda/psdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index c5234c2..55824cb 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); -- 2.7.4
| |