Commit ba42212a authored by Jia-Ju Bai's avatar Jia-Ju Bai Committed by Greg Kroah-Hartman

mac80211_hwsim: Fix possible null-pointer dereferences in hwsim_dump_radio_nl()

[ Upstream commit b55f3b84 ]

In hwsim_dump_radio_nl(), when genlmsg_put() on line 3617 fails, hdr is
assigned to NULL. Then hdr is used on lines 3622 and 3623:
    genl_dump_check_consistent(cb, hdr);
    genlmsg_end(skb, hdr);

Thus, possible null-pointer dereferences may occur.

To fix these bugs, hdr is used here when it is not NULL.

This bug is found by a static analysis tool STCheck written by us.
Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Link: https://lore.kernel.org/r/20190729082332.28895-1-baijiaju1990@gmail.com
[put braces on all branches]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 32cbe035
......@@ -3502,10 +3502,12 @@ static int hwsim_dump_radio_nl(struct sk_buff *skb,
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, &hwsim_genl_family,
NLM_F_MULTI, HWSIM_CMD_GET_RADIO);
if (!hdr)
if (hdr) {
genl_dump_check_consistent(cb, hdr);
genlmsg_end(skb, hdr);
} else {
res = -EMSGSIZE;
genl_dump_check_consistent(cb, hdr);
genlmsg_end(skb, hdr);
}
}
done:
......
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