mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
genetlink: load policy based on validation flags
Set the policy and maxattr pointers based on validation flags. genl_family_rcv_msg_attrs_parse() will do nothing and return NULL if maxattrs is zero, so no behavior change is expected. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
20b0b53aca
commit
7747eb75f6
@@ -204,8 +204,14 @@ genl_cmd_full_to_split(struct genl_split_ops *op,
|
|||||||
op->post_doit = family->post_doit;
|
op->post_doit = family->post_doit;
|
||||||
}
|
}
|
||||||
|
|
||||||
op->policy = full->policy;
|
if (flags & GENL_CMD_CAP_DUMP &&
|
||||||
op->maxattr = full->maxattr;
|
full->validate & GENL_DONT_VALIDATE_DUMP) {
|
||||||
|
op->policy = NULL;
|
||||||
|
op->maxattr = 0;
|
||||||
|
} else {
|
||||||
|
op->policy = full->policy;
|
||||||
|
op->maxattr = full->maxattr;
|
||||||
|
}
|
||||||
|
|
||||||
op->cmd = full->cmd;
|
op->cmd = full->cmd;
|
||||||
op->internal_flags = full->internal_flags;
|
op->internal_flags = full->internal_flags;
|
||||||
@@ -638,10 +644,8 @@ static int genl_start(struct netlink_callback *cb)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
ops = ctx->ops;
|
ops = ctx->ops;
|
||||||
if (ops->validate & GENL_DONT_VALIDATE_DUMP)
|
if (!(ops->validate & GENL_DONT_VALIDATE_DUMP) &&
|
||||||
goto no_attrs;
|
ctx->nlh->nlmsg_len < nlmsg_msg_size(ctx->hdrlen))
|
||||||
|
|
||||||
if (ctx->nlh->nlmsg_len < nlmsg_msg_size(ctx->hdrlen))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
attrs = genl_family_rcv_msg_attrs_parse(ctx->family, ctx->nlh, ctx->extack,
|
attrs = genl_family_rcv_msg_attrs_parse(ctx->family, ctx->nlh, ctx->extack,
|
||||||
@@ -650,7 +654,6 @@ static int genl_start(struct netlink_callback *cb)
|
|||||||
if (IS_ERR(attrs))
|
if (IS_ERR(attrs))
|
||||||
return PTR_ERR(attrs);
|
return PTR_ERR(attrs);
|
||||||
|
|
||||||
no_attrs:
|
|
||||||
info = genl_dumpit_info_alloc();
|
info = genl_dumpit_info_alloc();
|
||||||
if (!info) {
|
if (!info) {
|
||||||
genl_family_rcv_msg_attrs_free(attrs);
|
genl_family_rcv_msg_attrs_free(attrs);
|
||||||
|
Reference in New Issue
Block a user