Re: Subject: [PATCH] net/ipv6: Use GFP_ATOMIC when a lock is held

Julia Lawall
2010-05-30T21:09:48Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1286 bytes --]

On Sun, 30 May 2010, Eric Dumazet wrote:

> Le dimanche 30 mai 2010 à 22:50 +0200, Julia Lawall a écrit :
>
> > I think the proposed patch does not work, because the for loop overwrites
> > p. That use of p looks like it is completely local to the for loop, so
> > perhaps a new variable p1 could be added to be used there?
>
> Please do so.
>
> I just wanted to tell you changing GFP_KERNEL to GFP_ATOMIC is not an
> appropriate way to solve this kind of problems. My patch was to get an
> idea, not a full and tested patch :)

Looking at it again, there is still a problem, because in the original
code, the loop:

for (p = t->prl; p; p = p->next) {
if (p->addr == a->addr) {
if (chg) {
p->flags = a->flags;
goto out;
}
err = -EEXIST;
goto out;
}
}

could exit with success without the kzalloc ever being called. If the
kzalloc is moved up, it could fail and then it returns immediately without
executing the loop. A solution could be to leave the NULL test on p where
it is, and only move up the kzalloc. Or perhaps the change in behavior
doesn't matter?

julia