net/bnxt: fix null pointer dereference in bnxt_hwrm_port_led_cfg()
PATCH 1/1 net/bnxt: fix null pointer dereference in bnxt_hwrm_port_led_cfg()
From: maoyingming <[email protected]>
VFs's "bp->leds" is allways null, check bp->leds is not null before use bp->leds->num_leds.
segfault backtrace in trex program when use VF:
11: bnxt_hwrm_port_led_cfg (bp=0x23ffb2140, led_on=true) 10: bnxt_dev_led_on_op (dev=0x22d7780 <rte_eth_devices>)
9: rte_eth_led_on (port_id=0)
8: DpdkTRexPortAttr::set_led (this=0x23b6ce0, on=true) 7: DpdkTRexPortAttr::DpdkTRexPortAttr
6: CTRexExtendedDriverBnxt::create_port_attr 5: CPhyEthIF::Create
4: CGlobalTRex::device_start
3: CGlobalTRex::Create
2: main_test
1: main
--- drivers/net/bnxt/bnxt_hwrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_hwrm.c +1 -1
@@ -4535,7 +4535,7 @@ int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on)uint16_t duration =0 ;int rc, i; -if (!bp->leds->num_leds ||BNXT_VF (bp)) +if (BNXT_VF (bp) || (!bp->leds) || (!bp->leds->num_leds))return -EOPNOTSUPP ;HWRM_PREP (&req,HWRM_PORT_LED_CFG ,BNXT_USE_CHIMP_MB );
Signature · 1 line
1.8.3.1
Quoted 1 line · Mao YingMing
Thanks for the patch
Quoted 4 lines
From: maoyingming <[email protected]>
VFs's "
bp->leds" is allways null, checkbp->ledsis not null before usebp->leds->num_leds.
Typo in 'always'
You can just say ' For VFs , bp->leds is uninitialized'
Quoted 38 lines
segfault backtrace in trex program when use VF:
11:bnxt_hwrm_port_led_cfg(bp=0x23ffb2140, led_on=true) 10:bnxt_dev_led_on_op(dev=0x22d7780 <rte_eth_devices>)
9:rte_eth_led_on(port_id=0)
8:DpdkTRexPortAttr::set_led(this=0x23b6ce0, on=true) 7:DpdkTRexPortAttr::DpdkTRexPortAttr
6:CTRexExtendedDriverBnxt::create_port_attr5:CPhyEthIF::Create
4:CGlobalTRex::device_start
3:CGlobalTRex::Create
2:main_test
1: mainFixes d4d5a04 ("net/bnxt: fix unnecessary memory allocation")Signed-off-by Mao YingMing <[email protected]>--- drivers/net/bnxt/bnxt_hwrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/bnxt/bnxt_hwrm.c +1
-2@@ -4535,7 +4535,7 @@ int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on)uint16_t duration =0 ;int rc, i; -if (!bp->leds->num_leds ||BNXT_VF (bp)) +if (BNXT_VF (bp) || (!bp->leds) || (!bp->leds->num_leds))return -EOPNOTSUPP ;HWRM_PREP (&req,HWRM_PORT_LED_CFG ,BNXT_USE_CHIMP_MB ); --1.8.3.1