Skip to contentSkip to conversation

qlcnic_dcb.c : possible division by zero.

PATCH In review Ameen Ali 1 participant 1 message Feb 25, 2015

Subsystems (3)
lore
Share & tools
lore

Ameen Ali

author
#0 lore raw

PATCH 6/6 qlcnic_dcb.c : possible division by zero.

Whenever there is a division it is usually worthwhile to add some belt'n'braces code to ensure that cnt != 0, otherwise a machine signal can occur.

---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c +1 -1
index a72bcdd..c1d5e48 100644
@@ -822,7 +822,7 @@ qlcnic_dcb_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, u8 *prio,
 		if (temp->valid && (pg == temp->pgid))
 			cnt++;
 	}
-
+	if (cnt != 0)
 	    tc_cfg->bwg_percent = (100 / cnt);
 	*bw_per = tc_cfg->bwg_percent;
 }
Signature · 1 line
2.1.0