2010-11-13 17:44:32

by Will Newton

[permalink] [raw]
Subject: [PATCH 1/2] uml: Safely iterate list of winch handlers in line driver.

unregister_winch should use list_for_each_safe, as it can
potentially delete from the list.

Signed-off-by: Will Newton <[email protected]>
---
arch/um/drivers/line.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 7f7338c..5f12fef 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -820,12 +820,12 @@ void register_winch_irq(int fd, int tty_fd, int
pid, struct tty_struct *tty,

static void unregister_winch(struct tty_struct *tty)
{
- struct list_head *ele;
+ struct list_head *ele, *next;
struct winch *winch;

spin_lock(&winch_handler_lock);

- list_for_each(ele, &winch_handlers) {
+ list_for_each_safe(ele, next, &winch_handlers) {
winch = list_entry(ele, struct winch, list);
if (winch->tty == tty) {
free_winch(winch, 1);
--
1.7.0.4


Attachments:
0001-uml-Safely-iterate-list-of-winch-handlers-in-line-dr.patch (1.07 kB)

2010-11-18 12:18:31

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH 1/2] uml: Safely iterate list of winch handlers in line driver.

On Sat, Nov 13, 2010 at 6:44 PM, Will Newton <[email protected]> wrote:
> unregister_winch should use list_for_each_safe, as it can
> potentially delete from the list.
>
> Signed-off-by: Will Newton <[email protected]>
> ---
> ?arch/um/drivers/line.c | ? ?4 ++--
> ?1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
> index 7f7338c..5f12fef 100644
> --- a/arch/um/drivers/line.c
> +++ b/arch/um/drivers/line.c
> @@ -820,12 +820,12 @@ void register_winch_irq(int fd, int tty_fd, int
> pid, struct tty_struct *tty,
>
> ?static void unregister_winch(struct tty_struct *tty)
> ?{
> - ? ? ? struct list_head *ele;
> + ? ? ? struct list_head *ele, *next;
> ? ? ? ?struct winch *winch;
>
> ? ? ? ?spin_lock(&winch_handler_lock);
>
> - ? ? ? list_for_each(ele, &winch_handlers) {
> + ? ? ? list_for_each_safe(ele, next, &winch_handlers) {
> ? ? ? ? ? ? ? ?winch = list_entry(ele, struct winch, list);
> ? ? ? ? ? ? ? ?if (winch->tty == tty) {
> ? ? ? ? ? ? ? ? ? ? ? ?free_winch(winch, 1);
> --
> 1.7.0.4
>

Please send your patches to akpm.

--
Thanks,
//richard

2010-11-18 13:40:27

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH 1/2] uml: Safely iterate list of winch handlers in line driver.

On Sat, Nov 13, 2010 at 05:44:28PM +0000, Will Newton wrote:
>unregister_winch should use list_for_each_safe, as it can
>potentially delete from the list.
>
>Signed-off-by: Will Newton <[email protected]>

Acked-by: WANG Cong <[email protected]>
Cc: Andrew Morton

Thanks.