Skip to content

Commit

Permalink
xfrm: Cleanup error handling of xfrm_state_clone
Browse files Browse the repository at this point in the history
The error pointer passed to xfrm_state_clone() is unchecked,
so remove it and indicate an error by returning a null pointer.

Signed-off-by: Steffen Klassert <[email protected]>
  • Loading branch information
klassert committed Feb 21, 2014
1 parent d2c5f65 commit cc9ab60
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,10 +1148,9 @@ int xfrm_state_add(struct xfrm_state *x)
EXPORT_SYMBOL(xfrm_state_add);

#ifdef CONFIG_XFRM_MIGRATE
static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig)
{
struct net *net = xs_net(orig);
int err = -ENOMEM;
struct xfrm_state *x = xfrm_state_alloc(net);
if (!x)
goto out;
Expand Down Expand Up @@ -1200,15 +1199,13 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
}

if (orig->replay_esn) {
err = xfrm_replay_clone(x, orig);
if (err)
if (xfrm_replay_clone(x, orig))
goto error;
}

memcpy(&x->mark, &orig->mark, sizeof(x->mark));

err = xfrm_init_state(x);
if (err)
if (xfrm_init_state(x) < 0)
goto error;

x->props.flags = orig->props.flags;
Expand All @@ -1223,8 +1220,6 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
error:
xfrm_state_put(x);
out:
if (errp)
*errp = err;
return NULL;
}

Expand Down Expand Up @@ -1276,9 +1271,8 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
struct xfrm_migrate *m)
{
struct xfrm_state *xc;
int err;

xc = xfrm_state_clone(x, &err);
xc = xfrm_state_clone(x);
if (!xc)
return NULL;

Expand All @@ -1291,7 +1285,7 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
state is to be updated as it is a part of triplet */
xfrm_state_insert(xc);
} else {
if ((err = xfrm_state_add(xc)) < 0)
if (xfrm_state_add(xc) < 0)
goto error;
}

Expand Down

0 comments on commit cc9ab60

Please sign in to comment.