[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210601100320.48d067d87f3e.I53608f5de5828db7066d29e5774bcf8a19e0f642@changeid>
Date: Tue, 1 Jun 2021 10:05:35 +0200
From: Johannes Berg <johannes@...solutions.net>
To: linux-wireless@...r.kernel.org, netdev@...r.kernel.org
Cc: m.chetan.kumar@...el.com, loic.poulain@...aro.org,
Johannes Berg <johannes.berg@...el.com>
Subject: [RFC 1/4] iosm: fix stats and RCU bugs in RX
From: Johannes Berg <johannes.berg@...el.com>
Signed-off-by: Johannes Berg <johannes.berg@...el.com>
---
drivers/net/wwan/iosm/iosm_ipc_wwan.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_wwan.c b/drivers/net/wwan/iosm/iosm_ipc_wwan.c
index 02c35bc86674..719c88d9b2e9 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_wwan.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_wwan.c
@@ -312,7 +312,8 @@ int ipc_wwan_receive(struct iosm_wwan *ipc_wwan, struct sk_buff *skb_arg,
bool dss, int if_id)
{
struct sk_buff *skb = skb_arg;
- struct net_device_stats stats;
+ struct net_device_stats *stats;
+ struct iosm_net_link *priv;
int ret;
if ((skb->data[0] & IOSM_IP_TYPE_MASK) == IOSM_IP_TYPE_IPV4)
@@ -325,19 +326,27 @@ int ipc_wwan_receive(struct iosm_wwan *ipc_wwan, struct sk_buff *skb_arg,
if (if_id < (IP_MUX_SESSION_START - 1) ||
if_id > (IP_MUX_SESSION_END - 1)) {
- dev_kfree_skb(skb);
- return -EINVAL;
+ ret = -EINVAL;
+ goto free;
}
rcu_read_lock();
- skb->dev = rcu_dereference(ipc_wwan->sub_netlist[if_id])->netdev;
- stats = rcu_dereference(ipc_wwan->sub_netlist[if_id])->netdev->stats;
- stats.rx_packets++;
- stats.rx_bytes += skb->len;
+ priv = rcu_dereference(ipc_wwan->sub_netlist[if_id]);
+ if (!priv) {
+ ret = -EINVAL;
+ goto unlock;
+ }
+ skb->dev = priv->netdev;
+ stats = &priv->netdev->stats;
+ stats->rx_packets++;
+ stats->rx_bytes += skb->len;
ret = netif_rx(skb);
+ skb = NULL;
+unlock:
rcu_read_unlock();
-
+free:
+ dev_kfree_skb(skb);
return ret;
}
--
2.31.1
Powered by blists - more mailing lists