[PATCH ovpn net-next] ovpn: drop useless NULL checks in ovpn_decrypt/encrypt_post()

Antonio Quartulli <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <[email protected]>
From: Antonio Quartulli <[email protected]>

`peer` and `ks` are assumed to be non-NULL throughtout the whole
ovpn_decrypt/encrypt_post(), therefore it doesn't make sense
to perform a NULL check before dropping their reference.

Remove the checks and simplify the code.

Caught by Smatch-CI.

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Antonio Quartulli <[email protected]>
---
 drivers/net/ovpn/io.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ovpn/io.c b/drivers/net/ovpn/io.c
index 3e6c06b9a5ae..762a8f31acfa 100644
--- a/drivers/net/ovpn/io.c
+++ b/drivers/net/ovpn/io.c
@@ -198,10 +198,8 @@ void ovpn_decrypt_post(void *data, int ret)
 		dev_dstats_rx_dropped(peer->ovpn->dev);
 	kfree_skb(skb);
 drop_nocount:
-	if (likely(peer))
-		ovpn_peer_put(peer);
-	if (likely(ks))
-		ovpn_crypto_key_slot_put(ks);
+	ovpn_peer_put(peer);
+	ovpn_crypto_key_slot_put(ks);
 }
 
 /* RX path entry point: decrypt packet and forward it to the device */
@@ -296,10 +294,8 @@ void ovpn_encrypt_post(void *data, int ret)
 err:
 	if (unlikely(skb))
 		dev_dstats_tx_dropped(peer->ovpn->dev);
-	if (likely(peer))
-		ovpn_peer_put(peer);
-	if (likely(ks))
-		ovpn_crypto_key_slot_put(ks);
+	ovpn_peer_put(peer);
+	ovpn_crypto_key_slot_put(ks);
 	kfree_skb(skb);
 }
 
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.