Skip to content

Commit

Permalink
autofs4: Do not potentially dereference NULL pointer returned by fget…
Browse files Browse the repository at this point in the history
…() in autofs_dev_ioctl_setpipefd()

In fs/autofs4/dev-ioctl.c::autofs_dev_ioctl_setpipefd() we call fget(),
which may return NULL, but we do not explicitly test for that NULL return
so we may end up dereferencing a NULL pointer - bad.

When I originally submitted this patch I had chosen EBUSY as the return
value to use if this happens. Ian Kent was kind enough to explain why that
would most likely be wrong and why EBADF should most likely be used
instead. This version of the patch uses EBADF.

Signed-off-by: Jesper Juhl <[email protected]>
Signed-off-by: Ian Kent <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
jjuhl authored and Al Viro committed Mar 24, 2011
1 parent e785472 commit 3dc8fe4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/autofs4/dev-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
return -EBUSY;
} else {
struct file *pipe = fget(pipefd);
if (!pipe) {
err = -EBADF;
goto out;
}
if (!pipe->f_op || !pipe->f_op->write) {
err = -EPIPE;
fput(pipe);
Expand Down

0 comments on commit 3dc8fe4

Please sign in to comment.