diff options
author | Julia Lawall <julia@diku.dk> | 2011-05-13 09:52:10 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-05-16 14:10:42 -0400 |
commit | bd2281b85d929af0bd192f05135f70dd05f4fd85 (patch) | |
tree | ad4022b4c9f7ec4125b9d6716cd9865c3165c874 /net/rfkill | |
parent | 40b275b69ee660274b77fb612b0db31fd282fc3f (diff) |
net/rfkill/core.c: Avoid leaving freed data in a list
The list_for_each_entry loop can fail, in which case the list element is
not removed from the list rfkill_fds. Since this list is not accessed by
the loop, the addition of &data->list into the list is just moved after the
loop.
The sematic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression E,E1,E2;
identifier l;
@@
*list_add(&E->l,E1);
... when != E1
when != list_del(&E->l)
when != list_del_init(&E->l)
when != E = E2
*kfree(E);// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 0198191b756d..be90640a2774 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
@@ -1024,7 +1024,6 @@ static int rfkill_fop_open(struct inode *inode, struct file *file) | |||
1024 | * start getting events from elsewhere but hold mtx to get | 1024 | * start getting events from elsewhere but hold mtx to get |
1025 | * startup events added first | 1025 | * startup events added first |
1026 | */ | 1026 | */ |
1027 | list_add(&data->list, &rfkill_fds); | ||
1028 | 1027 | ||
1029 | list_for_each_entry(rfkill, &rfkill_list, node) { | 1028 | list_for_each_entry(rfkill, &rfkill_list, node) { |
1030 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); | 1029 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
@@ -1033,6 +1032,7 @@ static int rfkill_fop_open(struct inode *inode, struct file *file) | |||
1033 | rfkill_fill_event(&ev->ev, rfkill, RFKILL_OP_ADD); | 1032 | rfkill_fill_event(&ev->ev, rfkill, RFKILL_OP_ADD); |
1034 | list_add_tail(&ev->list, &data->events); | 1033 | list_add_tail(&ev->list, &data->events); |
1035 | } | 1034 | } |
1035 | list_add(&data->list, &rfkill_fds); | ||
1036 | mutex_unlock(&data->mtx); | 1036 | mutex_unlock(&data->mtx); |
1037 | mutex_unlock(&rfkill_global_mutex); | 1037 | mutex_unlock(&rfkill_global_mutex); |
1038 | 1038 | ||