Catégorie : Linux

drivers/net: Move a dereference below a NULL test

Author: Julia Lawall <julia@diku.dk> If the NULL test is necessary, then the dereference should be moved below the NULL test. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ type T; expression E,E1; identifier i,fld; statement S; @@ – T i = E->fld; + T i; … when != E=E1 when …

Lire la suite

ALSA: sound/isa: convert nested spin_lock_irqsave to spin_lock

Author: Julia Lawall <julia@diku.dk> If spin_lock_irqsave is called twice in a row with the same second argument, the interrupt state at the point of the second call overwrites the value saved by the first call. Indeed, the second call does not need to save the interrupt state, so it is changed to a simple spin_lock. …

Lire la suite

Staging: meilhaus: convert nested spin_lock_irqsave to spin_lock

Author: Julia Lawall <julia@diku.dk> If spin_lock_irqsave is called twice in a row with the same second argument, the interrupt state at the point of the second call overwrites the value saved by the first call. Indeed, the second call does not need to save the interrupt state, so it is changed to a simple spin_lock. …

Lire la suite

arch/blackfin: Add kmalloc NULL tests

Author: Julia Lawall <julia@diku.dk> Check that the result of kmalloc is not NULL before passing it to other functions. In the first two cases, the new code returns -ENOMEM, which seems compatible with what is done for similar functions for other architectures. In the last two cases, the new code fails silently, ie just returns, …

Lire la suite

ataflop: adjust NULL test

Author: Julia Lawall <julia@diku.dk> dtp is derefenced on the lines above the test !dtp, and so it cannot be NULL at this point. A simplified version of the semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r@ expression x,E,E1; identifier f,l; position p1,p2; @@ *x@p1->f = E1; … when != x = …

Lire la suite

drivers/net: Drop unnecessary NULL test

Author: Julia Lawall <julia@diku.dk> The result of container_of should not be NULL. In particular, in this case the argument to the enclosing function has passed though INIT_WORK, which dereferences it, implying that its container cannot be NULL. A simplified version of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ identifier …

Lire la suite

drivers/isdn: Drop unnecessary NULL test

Author: Julia Lawall <julia@diku.dk> The result of container_of should not be NULL. In particular, in this case the argument to the enclosing function has passed though INIT_WORK, which dereferences it, implying that its container cannot be NULL. A simplified version of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ identifier …

Lire la suite

hvc_console: Drop unnecessary NULL test

Author: Julia Lawall <julia@diku.dk> The result of container_of should not be NULL. In particular, in this case the argument to the enclosing function has passed though INIT_WORK, which dereferences it, implying that its container cannot be NULL. A simplified version of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ identifier …

Lire la suite

USB: gadget: Drop NULL test on list_entry result

Author: Julia Lawall <julia@diku.dk> list_entry, which is an alias for container_of, cannot return NULL, as there is no way to add a NULL value to a doubly linked list. A simplified version of the semantic match that findds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r@ expression x,E; statement S1,S2; position p,p1; @@ *x = …

Lire la suite

Staging: b3dfg: Drop NULL test on list_entry result

Author: Julia Lawall <julia@diku.dk> list_entry, which is an alias for container_of, cannot return NULL, as there is no way to add a NULL value to a doubly linked list. A simplified version of the semantic match that findds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r@ expression x,E; statement S1,S2; position p,p1; @@ *x = …

Lire la suite