Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: dst: correct error-handling code

dst_state_alloc returns an ERR_PTR value in an error case instead of NULL.

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 = dst_state_alloc(...)
... when != x = E
(
* if (x == NULL || ...) S1 else S2
|
* if (x == NULL && ...) S1 else S2
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Julia Lawall and committed by
Greg Kroah-Hartman
d0e0507a b6ac1613

+1 -1
+1 -1
drivers/staging/dst/export.c
··· 159 159 goto err_out_exit; 160 160 161 161 new = dst_state_alloc(st->node); 162 - if (!new) { 162 + if (IS_ERR(new)) { 163 163 err = -ENOMEM; 164 164 goto err_out_release; 165 165 }