* [PATCH 3/9] virt/kvm: correct error-handling code
@ 2009-07-28 15:53 Julia Lawall
2009-09-09 14:42 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2009-07-28 15:53 UTC (permalink / raw)
To: avi, kvm, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
This code is not executed before file has been initialized to the result of
calling eventfd_fget. This function returns an ERR_PTR value in an error
case instead of NULL. Thus the test that file is not NULL is always true.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@match exists@
expression x, E;
statement S1, S2;
@@
x = eventfd_fget(...)
... when != x = E
(
* if (x = NULL || ...) S1 else S2
|
* if (x = NULL && ...) S1 else S2
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
virt/kvm/eventfd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 99017e8..bb4ebd8 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -230,7 +230,7 @@ fail:
if (eventfd && !IS_ERR(eventfd))
eventfd_ctx_put(eventfd);
- if (file && !IS_ERR(file))
+ if (!IS_ERR(file))
fput(file);
kfree(irqfd);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/9] virt/kvm: correct error-handling code
2009-07-28 15:53 [PATCH 3/9] virt/kvm: correct error-handling code Julia Lawall
@ 2009-09-09 14:42 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2009-09-09 14:42 UTC (permalink / raw)
To: Julia Lawall; +Cc: kvm, linux-kernel, kernel-janitors
On 07/28/2009 06:53 PM, Julia Lawall wrote:
> From: Julia Lawall<julia@diku.dk>
>
> This code is not executed before file has been initialized to the result of
> calling eventfd_fget. This function returns an ERR_PTR value in an error
> case instead of NULL. Thus the test that file is not NULL is always true.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
>
> //<smpl>
> @match exists@
> expression x, E;
> statement S1, S2;
> @@
>
> x = eventfd_fget(...)
> ... when != x = E
> (
> * if (x = NULL || ...) S1 else S2
> |
> * if (x = NULL&& ...) S1 else S2
> )
> //</smpl>
>
>
Applied, thanks (yes, old patch, missed it).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-09 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 15:53 [PATCH 3/9] virt/kvm: correct error-handling code Julia Lawall
2009-09-09 14:42 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).