target: fix return code in target_core_init_configfs error path
authorPeter Senna Tschudin <peter.senna@gmail.com>
Mon, 17 Sep 2012 18:05:33 +0000 (20:05 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 17 Oct 2012 02:48:31 +0000 (03:48 +0100)
commit3f9797d12e427691217ca7203790d7256731bc06
tree59565e16110d8976f7f797e86b56693bc1ee1e2d
parent20ce58f23298e3184eb85838d00c08aa62d835d6
target: fix return code in target_core_init_configfs error path

commit 37bb7899ca366dc212b71b150e78566d04808cc0 upstream.

This patch fixes error cases within target_core_init_configfs() to
properly set ret = -ENOMEM before jumping to the out_global exception
path.

This was originally discovered with the following Coccinelle semantic
match information:

Convert a nonnegative error return code to a negative one, as returned
elsewhere in the function.  A simplified version of the semantic match
that finds this problem is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}
// </smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/target/target_core_configfs.c