Skip to content

Commit

Permalink
net/xfrm/xfrm_state.c: fix error return code
Browse files Browse the repository at this point in the history
Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
JuliaLawall authored and davem330 committed Aug 31, 2012
1 parent 48f125c commit 599901c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,8 +1994,10 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay)
goto error;

x->outer_mode = xfrm_get_mode(x->props.mode, family);
if (x->outer_mode == NULL)
if (x->outer_mode == NULL) {
err = -EPROTONOSUPPORT;
goto error;
}

if (init_replay) {
err = xfrm_init_replay(x);
Expand Down

0 comments on commit 599901c

Please sign in to comment.