]> www.infradead.org Git - users/dwmw2/linux.git/commit
mac80211_hwsim: Fix possible null-pointer dereferences in hwsim_dump_radio_nl()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Mon, 29 Jul 2019 08:23:32 +0000 (16:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2019 06:30:08 +0000 (08:30 +0200)
commit79ea14eea8cde6ca9405bed9e4ddac6a1cdaf539
tree1cde694548bf43f9221a15ecb79f0263234c5c08
parent813f42fc5695f164738013b806fcb36a0eae363f
mac80211_hwsim: Fix possible null-pointer dereferences in hwsim_dump_radio_nl()

[ Upstream commit b55f3b841099e641bdb2701d361a4c304e2dbd6f ]

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: Jia-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: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mac80211_hwsim.c