]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fsl/fman: Check for null pointer after calling devm_ioremap
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 6 Jan 2022 10:04:10 +0000 (18:04 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 08:04:20 +0000 (09:04 +0100)
commit97ffb72a34435120f922fe1d86ed66ff8ec4f423
tree81eef476bfe1dd6129d65e294637090e68a32afc
parent957fac9a9cbb78ccdf4009c784c0cdc435eb20d4
fsl/fman: Check for null pointer after calling devm_ioremap

[ Upstream commit d5a73ec96cc57cf67e51b12820fc2354e7ca46f8 ]

As the possible failure of the allocation, the devm_ioremap() may return
NULL pointer.
Take tgec_initialization() as an example.
If allocation fails, the params->base_addr will be NULL pointer and will
be assigned to tgec->regs in tgec_config().
Then it will cause the dereference of NULL pointer in set_mac_address(),
which is called by tgec_init().
Therefore, it should be better to add the sanity check after the calling
of the devm_ioremap().

Fixes: 3933961682a3 ("fsl/fman: Add FMan MAC driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/freescale/fman/mac.c