diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 58dfa82..731f0a8 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1188,10 +1188,15 @@ static inline int xfrm_aevent_is_on(void) return ret; } +static inline int alg_len(struct xfrm_algo *alg) +{ + return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); +} + #ifdef CONFIG_XFRM_MIGRATE static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) { - return (struct xfrm_algo *)kmemdup(orig, sizeof(*orig) + orig->alg_key_len, GFP_KERNEL); + return kmemdup(orig, alg_len(orig), GFP_KERNEL); } static inline void xfrm_states_put(struct xfrm_state **states, int n) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index e75dbdc..aa667a4 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -31,11 +31,6 @@ #include #endif -static inline int alg_len(struct xfrm_algo *alg) -{ - return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); -} - static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type) { struct nlattr *rt = attrs[type];