void nla_get_range_signed(const struct nla_policy *pt,
                          struct netlink_range_validation_signed *range);
 
+struct netlink_policy_dump_state;
+
 int netlink_policy_dump_start(const struct nla_policy *policy,
                              unsigned int maxtype,
-                             unsigned long *state);
-bool netlink_policy_dump_loop(unsigned long state);
-int netlink_policy_dump_write(struct sk_buff *skb, unsigned long state);
-void netlink_policy_dump_free(unsigned long state);
+                             struct netlink_policy_dump_state **state);
+bool netlink_policy_dump_loop(struct netlink_policy_dump_state *state);
+int netlink_policy_dump_write(struct sk_buff *skb,
+                             struct netlink_policy_dump_state *state);
+void netlink_policy_dump_free(struct netlink_policy_dump_state *state);
 
 #endif
 
        return 0;
 }
 
+struct ctrl_dump_policy_ctx {
+       struct netlink_policy_dump_state *state;
+       u16 fam_id;
+};
+
 static int ctrl_dumppolicy(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct ctrl_dump_policy_ctx *ctx = (void *)cb->ctx;
        const struct genl_family *rt;
-       unsigned int fam_id = cb->args[0];
        int err;
 
-       if (!fam_id) {
+       BUILD_BUG_ON(sizeof(*ctx) > sizeof(cb->ctx));
+
+       if (!ctx->fam_id) {
                struct nlattr *tb[CTRL_ATTR_MAX + 1];
 
                err = genlmsg_parse(cb->nlh, &genl_ctrl, tb,
                        return -EINVAL;
 
                if (tb[CTRL_ATTR_FAMILY_ID]) {
-                       fam_id = nla_get_u16(tb[CTRL_ATTR_FAMILY_ID]);
+                       ctx->fam_id = nla_get_u16(tb[CTRL_ATTR_FAMILY_ID]);
                } else {
                        rt = genl_family_find_byname(
                                nla_data(tb[CTRL_ATTR_FAMILY_NAME]));
                        if (!rt)
                                return -ENOENT;
-                       fam_id = rt->id;
+                       ctx->fam_id = rt->id;
                }
        }
 
-       rt = genl_family_find_byid(fam_id);
+       rt = genl_family_find_byid(ctx->fam_id);
        if (!rt)
                return -ENOENT;
 
        if (!rt->policy)
                return -ENODATA;
 
-       err = netlink_policy_dump_start(rt->policy, rt->maxattr, &cb->args[1]);
+       err = netlink_policy_dump_start(rt->policy, rt->maxattr, &ctx->state);
        if (err)
                return err;
 
-       while (netlink_policy_dump_loop(cb->args[1])) {
+       while (netlink_policy_dump_loop(ctx->state)) {
                void *hdr;
                struct nlattr *nest;
 
                if (!nest)
                        goto nla_put_failure;
 
-               if (netlink_policy_dump_write(skb, cb->args[1]))
+               if (netlink_policy_dump_write(skb, ctx->state))
                        goto nla_put_failure;
 
                nla_nest_end(skb, nest);
                break;
        }
 
-       cb->args[0] = fam_id;
        return skb->len;
 }
 
 static int ctrl_dumppolicy_done(struct netlink_callback *cb)
 {
-       netlink_policy_dump_free(cb->args[1]);
+       struct ctrl_dump_policy_ctx *ctx = (void *)cb->ctx;
+
+       netlink_policy_dump_free(ctx->state);
        return 0;
 }
 
 
 
 #define INITIAL_POLICIES_ALLOC 10
 
-struct nl_policy_dump {
+struct netlink_policy_dump_state {
        unsigned int policy_idx;
        unsigned int attr_idx;
        unsigned int n_alloc;
        } policies[];
 };
 
-static int add_policy(struct nl_policy_dump **statep,
+static int add_policy(struct netlink_policy_dump_state **statep,
                      const struct nla_policy *policy,
                      unsigned int maxtype)
 {
-       struct nl_policy_dump *state = *statep;
+       struct netlink_policy_dump_state *state = *statep;
        unsigned int n_alloc, i;
 
        if (!policy || !maxtype)
        return 0;
 }
 
-static unsigned int get_policy_idx(struct nl_policy_dump *state,
+static unsigned int get_policy_idx(struct netlink_policy_dump_state *state,
                                   const struct nla_policy *policy)
 {
        unsigned int i;
 
 int netlink_policy_dump_start(const struct nla_policy *policy,
                              unsigned int maxtype,
-                              unsigned long *_state)
+                             struct netlink_policy_dump_state **statep)
 {
-       struct nl_policy_dump *state;
+       struct netlink_policy_dump_state *state;
        unsigned int policy_idx;
        int err;
 
-       if (*_state)
+       if (*statep)
                return 0;
 
        /*
                }
        }
 
-       *_state = (unsigned long)state;
+       *statep = state;
 
        return 0;
 }
 
-static bool netlink_policy_dump_finished(struct nl_policy_dump *state)
+static bool
+netlink_policy_dump_finished(struct netlink_policy_dump_state *state)
 {
        return state->policy_idx >= state->n_alloc ||
               !state->policies[state->policy_idx].policy;
 }
 
-bool netlink_policy_dump_loop(unsigned long _state)
+bool netlink_policy_dump_loop(struct netlink_policy_dump_state *state)
 {
-       struct nl_policy_dump *state = (void *)_state;
-
        return !netlink_policy_dump_finished(state);
 }
 
-int netlink_policy_dump_write(struct sk_buff *skb, unsigned long _state)
+int netlink_policy_dump_write(struct sk_buff *skb,
+                             struct netlink_policy_dump_state *state)
 {
-       struct nl_policy_dump *state = (void *)_state;
        const struct nla_policy *pt;
        struct nlattr *policy, *attr;
        enum netlink_attribute_type type;
        return -ENOBUFS;
 }
 
-void netlink_policy_dump_free(unsigned long _state)
+void netlink_policy_dump_free(struct netlink_policy_dump_state *state)
 {
-       struct nl_policy_dump *state = (void *)_state;
-
        kfree(state);
 }