Commit f9b282b3 authored by Yajun Deng's avatar Yajun Deng Committed by David S. Miller

net: netlink: add the case when nlh is NULL

Add the case when nlh is NULL in nlmsg_report(),
so that the caller doesn't need to deal with this case.
Signed-off-by: default avatarYajun Deng <yajun.deng@linux.dev>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b0e81817
...@@ -885,7 +885,7 @@ static inline int nlmsg_validate_deprecated(const struct nlmsghdr *nlh, ...@@ -885,7 +885,7 @@ static inline int nlmsg_validate_deprecated(const struct nlmsghdr *nlh,
*/ */
static inline int nlmsg_report(const struct nlmsghdr *nlh) static inline int nlmsg_report(const struct nlmsghdr *nlh)
{ {
return !!(nlh->nlmsg_flags & NLM_F_ECHO); return nlh ? !!(nlh->nlmsg_flags & NLM_F_ECHO) : 0;
} }
/** /**
......
...@@ -726,12 +726,8 @@ void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, ...@@ -726,12 +726,8 @@ void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group,
struct nlmsghdr *nlh, gfp_t flags) struct nlmsghdr *nlh, gfp_t flags)
{ {
struct sock *rtnl = net->rtnl; struct sock *rtnl = net->rtnl;
int report = 0;
if (nlh) nlmsg_notify(rtnl, skb, pid, group, nlmsg_report(nlh), flags);
report = nlmsg_report(nlh);
nlmsg_notify(rtnl, skb, pid, group, report, flags);
} }
EXPORT_SYMBOL(rtnl_notify); EXPORT_SYMBOL(rtnl_notify);
......
...@@ -1485,6 +1485,7 @@ int genlmsg_multicast_allns(const struct genl_family *family, ...@@ -1485,6 +1485,7 @@ int genlmsg_multicast_allns(const struct genl_family *family,
{ {
if (WARN_ON_ONCE(group >= family->n_mcgrps)) if (WARN_ON_ONCE(group >= family->n_mcgrps))
return -EINVAL; return -EINVAL;
group = family->mcgrp_offset + group; group = family->mcgrp_offset + group;
return genlmsg_mcast(skb, portid, group, flags); return genlmsg_mcast(skb, portid, group, flags);
} }
...@@ -1495,14 +1496,12 @@ void genl_notify(const struct genl_family *family, struct sk_buff *skb, ...@@ -1495,14 +1496,12 @@ void genl_notify(const struct genl_family *family, struct sk_buff *skb,
{ {
struct net *net = genl_info_net(info); struct net *net = genl_info_net(info);
struct sock *sk = net->genl_sock; struct sock *sk = net->genl_sock;
int report = 0;
if (info->nlhdr)
report = nlmsg_report(info->nlhdr);
if (WARN_ON_ONCE(group >= family->n_mcgrps)) if (WARN_ON_ONCE(group >= family->n_mcgrps))
return; return;
group = family->mcgrp_offset + group; group = family->mcgrp_offset + group;
nlmsg_notify(sk, skb, info->snd_portid, group, report, flags); nlmsg_notify(sk, skb, info->snd_portid, group,
nlmsg_report(info->nlhdr), flags);
} }
EXPORT_SYMBOL(genl_notify); EXPORT_SYMBOL(genl_notify);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment