]> git.baikalelectronics.ru Git - kernel.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)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Jan 2022 13:51:05 +0000 (13:51 +0000)
commitc1e64d45d5e34d2d22f9203a4b9a551597d9b2ff
treefa88f40d1b198efad5308451ca00a29909c029a8
parent054e9dcd985d06ad2e2108a6d00df8e2ca04b5d6
fsl/fman: Check for null pointer after calling devm_ioremap

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: 64bd9b934c01 ("fsl/fman: Add FMan MAC driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/fman/mac.c