Skip to content

Commit

Permalink
lguest: dereferencing freed mem in add_eventfd()
Browse files Browse the repository at this point in the history
"new" was freed and then dereferenced.  Also the return value wasn't being
used so I modified the caller as well.

Compile tested only.  Found by smatch (http://repo.or.cz/w/smatch.git).

regards,
dan carpenter

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
error27 authored and rustyrussell committed Jul 30, 2009
1 parent 658874f commit f294526
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/lguest/lguest_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ static int add_eventfd(struct lguest *lg, unsigned long addr, int fd)
new->map[new->num].addr = addr;
new->map[new->num].event = eventfd_ctx_fdget(fd);
if (IS_ERR(new->map[new->num].event)) {
int err = PTR_ERR(new->map[new->num].event);
kfree(new);
return PTR_ERR(new->map[new->num].event);
return err;
}
new->num++;

Expand Down Expand Up @@ -83,7 +84,7 @@ static int attach_eventfd(struct lguest *lg, const unsigned long __user *input)
err = add_eventfd(lg, addr, fd);
mutex_unlock(&lguest_lock);

return 0;
return err;
}

/*L:050 Sending an interrupt is done by writing LHREQ_IRQ and an interrupt
Expand Down

0 comments on commit f294526

Please sign in to comment.