diff mbox series

llc2: Reverse the true/false statements of the condition operator in llc_stat_ev_rx_null_dsap_xid_c and llc_stat_ev_rx_null_dsap_test_c.

Message ID 1576340820-4929-1-git-send-email-alexchan@task.com.hk
State Changes Requested
Delegated to: David Miller
Headers show
Series llc2: Reverse the true/false statements of the condition operator in llc_stat_ev_rx_null_dsap_xid_c and llc_stat_ev_rx_null_dsap_test_c. | expand

Commit Message

Chan Shu Tak, Alex Dec. 14, 2019, 4:26 p.m. UTC
From: "Chan Shu Tak, Alex" <alexchan@task.com.hk>

When a frame with NULL DSAP is received, llc_station_rcv is called.
In turn, llc_stat_ev_rx_null_dsap_xid_c is called to check if it is
a NULL XID frame. The original true statement returns 0 while the
false statement returns 1. As a result, an incoming NULL TEST frame
would trigger an XID response instead.

The same error is found in llc_stat_ev_rx_null_dsap_test_c and fixed.

Signed-off-by: Chan Shu Tak, Alex <alexchan@task.com.hk>
---
 net/llc/llc_station.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller Dec. 17, 2019, 12:26 a.m. UTC | #1
From: "Chan Shu Tak, Alex" <alexchan@task.com.hk>
Date: Sun, 15 Dec 2019 00:26:58 +0800

> @@ -32,7 +32,7 @@ static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff *skb)
>  	return LLC_PDU_IS_CMD(pdu) &&			/* command PDU */
>  	       LLC_PDU_TYPE_IS_U(pdu) &&		/* U type PDU */
>  	       LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID &&
> -	       !pdu->dsap ? 0 : 1;			/* NULL DSAP value */
> +	       !pdu->dsap ? 1 : 0;			/* NULL DSAP value */
>  }
>  
>  static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb)
> @@ -42,7 +42,7 @@ static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb)
>  	return LLC_PDU_IS_CMD(pdu) &&			/* command PDU */
>  	       LLC_PDU_TYPE_IS_U(pdu) &&		/* U type PDU */
>  	       LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST &&
> -	       !pdu->dsap ? 0 : 1;			/* NULL DSAP */
> +	       !pdu->dsap ? 1 : 0;			/* NULL DSAP */
>  }
>  

These are both plain booleans now then.  Just plain "!pdu->dsap" is
therefore, sufficient.
diff mbox series

Patch

diff --git a/net/llc/llc_station.c b/net/llc/llc_station.c
index 204a835..90955d7 100644
--- a/net/llc/llc_station.c
+++ b/net/llc/llc_station.c
@@ -32,7 +32,7 @@  static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff *skb)
 	return LLC_PDU_IS_CMD(pdu) &&			/* command PDU */
 	       LLC_PDU_TYPE_IS_U(pdu) &&		/* U type PDU */
 	       LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID &&
-	       !pdu->dsap ? 0 : 1;			/* NULL DSAP value */
+	       !pdu->dsap ? 1 : 0;			/* NULL DSAP value */
 }
 
 static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb)
@@ -42,7 +42,7 @@  static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb)
 	return LLC_PDU_IS_CMD(pdu) &&			/* command PDU */
 	       LLC_PDU_TYPE_IS_U(pdu) &&		/* U type PDU */
 	       LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST &&
-	       !pdu->dsap ? 0 : 1;			/* NULL DSAP */
+	       !pdu->dsap ? 1 : 0;			/* NULL DSAP */
 }
 
 static int llc_station_ac_send_xid_r(struct sk_buff *skb)