From 26cb6f347f48eea1286c3d7ce0ce639ab223d06e Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Tue, 29 Mar 2022 05:23:01 +0200
Subject: [PATCH 036/463] 8723cs: Port to 5.18

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 drivers/staging/rtl8723cs/core/rtw_br_ext.c | 6 ++++--
 drivers/staging/rtl8723cs/core/rtw_mi.c     | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723cs/core/rtw_br_ext.c b/drivers/staging/rtl8723cs/core/rtw_br_ext.c
index 4251b825c8aeb..7b5934d384467 100644
--- a/drivers/staging/rtl8723cs/core/rtw_br_ext.c
+++ b/drivers/staging/rtl8723cs/core/rtw_br_ext.c
@@ -97,6 +97,7 @@ static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_ta
 {
 	struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
 	int data_len;
+	int ph_len = ntohs(ph->length);
 
 	data_len = tag->tag_len + TAG_HDR_LEN;
 	if (skb_tailroom(skb) < data_len) {
@@ -105,9 +106,10 @@ static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_ta
 	}
 
 	skb_put(skb, data_len);
+
 	/* have a room for new tag */
-	memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
-	ph->length = htons(ntohs(ph->length) + data_len);
+	memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ph_len);
+	ph->length = htons(ph_len + data_len);
 	memcpy((unsigned char *)ph->tag, tag, data_len);
 	return data_len;
 }
diff --git a/drivers/staging/rtl8723cs/core/rtw_mi.c b/drivers/staging/rtl8723cs/core/rtw_mi.c
index 099cd368b3307..f125225b7dbe8 100644
--- a/drivers/staging/rtl8723cs/core/rtw_mi.c
+++ b/drivers/staging/rtl8723cs/core/rtw_mi.c
@@ -1226,7 +1226,7 @@ u8 rtw_mi_buddy_set_tx_beacon_cmd(_adapter *padapter)
 static u8 _rtw_mi_p2p_chk_state(_adapter *adapter, void *data)
 {
 	struct wifidirect_info *pwdinfo = &(adapter->wdinfo);
-	enum P2P_STATE state = *(enum P2P_STATE *)data;
+	enum P2P_STATE state = *(u8*)data;
 
 	return rtw_p2p_chk_state(pwdinfo, state);
 }
-- 
2.46.0

