linux-stable/drivers/net/ethernet/qlogic/qlcnic
Zhou Qingyang e2dabc4f7e net: qlogic: qlcnic: Fix a NULL pointer dereference in qlcnic_83xx_add_rings()
In qlcnic_83xx_add_rings(), the indirect function of
ahw->hw_ops->alloc_mbx_args will be called to allocate memory for
cmd.req.arg, and there is a dereference of it in qlcnic_83xx_add_rings(),
which could lead to a NULL pointer dereference on failure of the
indirect function like qlcnic_83xx_alloc_mbx_args().

Fix this bug by adding a check of alloc_mbx_args(), this patch
imitates the logic of mbx_cmd()'s failure handling.

This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.

Builds with CONFIG_QLCNIC=m show no new warnings, and our
static analyzer no longer warns about this code.

Fixes: 7f9664525f ("qlcnic: 83xx memory map and HW access routine")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Link: https://lore.kernel.org/r/20211130110848.109026-1-zhou1615@umn.edu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-12-01 18:51:36 -08:00
..
Makefile
qlcnic.h net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_83xx_hw.c net: qlogic: qlcnic: Fix a NULL pointer dereference in qlcnic_83xx_add_rings() 2021-12-01 18:51:36 -08:00
qlcnic_83xx_hw.h net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_83xx_init.c qlcnic: Remove redundant initialization of variable ret 2021-09-10 14:42:31 +01:00
qlcnic_83xx_vnic.c net: calxeda: Fix wrong function name in comments 2021-05-17 14:12:39 -07:00
qlcnic_ctx.c net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_dcb.c net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_dcb.h net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_ethtool.c ethtool: extend coalesce setting uAPI with CQE mode 2021-08-24 07:38:29 -07:00
qlcnic_hdr.h net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_hw.c ethernet/qlogic: Use list_for_each_entry() to simplify code in qlcnic_hw.c 2021-06-08 16:31:25 -07:00
qlcnic_hw.h qlcnic: Remove the repeated declaration 2021-06-01 15:25:46 -07:00
qlcnic_init.c qlcnic: Remove redundant unlock in qlcnic_pinit_from_rom 2021-09-04 10:50:59 +01:00
qlcnic_io.c qlcnic: switch from 'pci_' to 'dma_' API 2021-08-23 12:02:29 +01:00
qlcnic_main.c ethernet: use eth_hw_addr_set() for dev->addr_len cases 2021-10-05 13:16:48 +01:00
qlcnic_minidump.c net/qlcnic: Fix a use after free in qlcnic_83xx_get_minidump_template 2021-03-11 18:08:14 -08:00
qlcnic_sriov.h net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_sriov_common.c drivers: net: qlcnic: simplify the return expression of qlcnic_sriov_vf_shutdown() 2020-12-08 16:22:54 -08:00
qlcnic_sriov_pf.c net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00
qlcnic_sysfs.c net/qlcnic: Convert to SPDX license identifiers 2020-09-16 14:32:10 +02:00