diff options
author | Steffen Klassert <steffen.klassert@secunet.com> | 2014-02-19 07:33:24 -0500 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2014-02-21 01:53:28 -0500 |
commit | cc9ab60e57964d463ff31b9621c8d7e786aee042 (patch) | |
tree | 91f84ed6ae8c3b24e043eb8e2c3983daa2cbd3ee | |
parent | d2c5f6582515362328b33b2a331a17e141ef0d40 (diff) |
xfrm: Cleanup error handling of xfrm_state_clone
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 <steffen.klassert@secunet.com>
-rw-r--r-- | net/xfrm/xfrm_state.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index a750901ac3db..5339c26bb0cf 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -1148,10 +1148,9 @@ out: | |||
1148 | EXPORT_SYMBOL(xfrm_state_add); | 1148 | EXPORT_SYMBOL(xfrm_state_add); |
1149 | 1149 | ||
1150 | #ifdef CONFIG_XFRM_MIGRATE | 1150 | #ifdef CONFIG_XFRM_MIGRATE |
1151 | static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) | 1151 | static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig) |
1152 | { | 1152 | { |
1153 | struct net *net = xs_net(orig); | 1153 | struct net *net = xs_net(orig); |
1154 | int err = -ENOMEM; | ||
1155 | struct xfrm_state *x = xfrm_state_alloc(net); | 1154 | struct xfrm_state *x = xfrm_state_alloc(net); |
1156 | if (!x) | 1155 | if (!x) |
1157 | goto out; | 1156 | goto out; |
@@ -1200,15 +1199,13 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) | |||
1200 | } | 1199 | } |
1201 | 1200 | ||
1202 | if (orig->replay_esn) { | 1201 | if (orig->replay_esn) { |
1203 | err = xfrm_replay_clone(x, orig); | 1202 | if (xfrm_replay_clone(x, orig)) |
1204 | if (err) | ||
1205 | goto error; | 1203 | goto error; |
1206 | } | 1204 | } |
1207 | 1205 | ||
1208 | memcpy(&x->mark, &orig->mark, sizeof(x->mark)); | 1206 | memcpy(&x->mark, &orig->mark, sizeof(x->mark)); |
1209 | 1207 | ||
1210 | err = xfrm_init_state(x); | 1208 | if (xfrm_init_state(x) < 0) |
1211 | if (err) | ||
1212 | goto error; | 1209 | goto error; |
1213 | 1210 | ||
1214 | x->props.flags = orig->props.flags; | 1211 | x->props.flags = orig->props.flags; |
@@ -1223,8 +1220,6 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) | |||
1223 | error: | 1220 | error: |
1224 | xfrm_state_put(x); | 1221 | xfrm_state_put(x); |
1225 | out: | 1222 | out: |
1226 | if (errp) | ||
1227 | *errp = err; | ||
1228 | return NULL; | 1223 | return NULL; |
1229 | } | 1224 | } |
1230 | 1225 | ||
@@ -1276,9 +1271,8 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x, | |||
1276 | struct xfrm_migrate *m) | 1271 | struct xfrm_migrate *m) |
1277 | { | 1272 | { |
1278 | struct xfrm_state *xc; | 1273 | struct xfrm_state *xc; |
1279 | int err; | ||
1280 | 1274 | ||
1281 | xc = xfrm_state_clone(x, &err); | 1275 | xc = xfrm_state_clone(x); |
1282 | if (!xc) | 1276 | if (!xc) |
1283 | return NULL; | 1277 | return NULL; |
1284 | 1278 | ||
@@ -1291,7 +1285,7 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x, | |||
1291 | state is to be updated as it is a part of triplet */ | 1285 | state is to be updated as it is a part of triplet */ |
1292 | xfrm_state_insert(xc); | 1286 | xfrm_state_insert(xc); |
1293 | } else { | 1287 | } else { |
1294 | if ((err = xfrm_state_add(xc)) < 0) | 1288 | if (xfrm_state_add(xc) < 0) |
1295 | goto error; | 1289 | goto error; |
1296 | } | 1290 | } |
1297 | 1291 | ||