diff mbox series

[5.10,130/135] net: qede: Fix end of loop tests for list_for_each_entry

Message ID 20210810173000.220428504@linuxfoundation.org
State New
Headers show
Series None | expand

Commit Message

Greg Kroah-Hartman Aug. 10, 2021, 5:31 p.m. UTC
From: Harshvardhan Jha <harshvardhan.jha@oracle.com>

[ Upstream commit 795e3d2ea68e489ee7039ac29e98bfea0e34a96c ]

The list_for_each_entry() iterator, "vlan" in this code, can never be
NULL so the warning will never be printed.

Signed-off-by: Harshvardhan Jha <harshvardhan.jha@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/qlogic/qede/qede_filter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Pavel Machek Aug. 11, 2021, 7:11 a.m. UTC | #1
Hi!

> [ Upstream commit 795e3d2ea68e489ee7039ac29e98bfea0e34a96c ]
> 
> The list_for_each_entry() iterator, "vlan" in this code, can never be
> NULL so the warning will never be printed.

Could someone double-check this? Because changelog is not accurate;
condition is using logical or, so warning can be printed. I don't
really see a bug with the old code.

New code is quite confusing, and if the vlan with required vic is the
"head" one, it will do the wrong thing, no?

Best regards,
								Pavel

> +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
> @@ -842,7 +842,7 @@ int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
>  		if (vlan->vid == vid)
>  			break;
>  
> -	if (!vlan || (vlan->vid != vid)) {
> +	if (list_entry_is_head(vlan, &edev->vlan_list, list)) {
>  		DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
>  			   "Vlan isn't configured\n");
>  		goto out;
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index c59b72c90293..a2e4dfb5cb44 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -831,7 +831,7 @@  int qede_configure_vlan_filters(struct qede_dev *edev)
 int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
 {
 	struct qede_dev *edev = netdev_priv(dev);
-	struct qede_vlan *vlan = NULL;
+	struct qede_vlan *vlan;
 	int rc = 0;
 
 	DP_VERBOSE(edev, NETIF_MSG_IFDOWN, "Removing vlan 0x%04x\n", vid);
@@ -842,7 +842,7 @@  int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
 		if (vlan->vid == vid)
 			break;
 
-	if (!vlan || (vlan->vid != vid)) {
+	if (list_entry_is_head(vlan, &edev->vlan_list, list)) {
 		DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
 			   "Vlan isn't configured\n");
 		goto out;