From julia@diku.dk Tue Jul 28 10:06:49 2009 From: Julia Lawall Date: Tue, 28 Jul 2009 17:52:56 +0200 (CEST) Subject: Staging: dst: correct error-handling code To: gregkh@suse.de, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Message-ID: From: Julia Lawall 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/) // @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 ) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dst/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/dst/export.c +++ b/drivers/staging/dst/export.c @@ -159,7 +159,7 @@ static struct dst_state *dst_accept_clie goto err_out_exit; new = dst_state_alloc(st->node); - if (!new) { + if (IS_ERR(new)) { err = -ENOMEM; goto err_out_release; }