diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2018-10-08 09:02:40 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2019-09-04 13:29:15 +0200 |
commit | bdfb5765e45b86b599caf377a99826409f8403cb (patch) | |
tree | 21f259a9bcfbaceafccc68be9d8575e939e7db5f /net/can | |
parent | 8df9ffb888c021fa68f9075d545f2ec5eca37200 (diff) | |
download | linux-bdfb5765e45b86b599caf377a99826409f8403cb.tar.bz2 |
can: af_can: remove NULL-ptr checks from users of can_dev_rcv_lists_find()
Since using the "struct can_ml_priv" for the per device "struct
dev_rcv_lists" the call can_dev_rcv_lists_find() cannot fail anymore.
This patch simplifies af_can by removing the NULL pointer checks from
the dev_rcv_lists returned by can_dev_rcv_lists_find().
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'net/can')
-rw-r--r-- | net/can/af_can.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/net/can/af_can.c b/net/can/af_can.c index 6ed85e2f72f0..25f0d510e1bf 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c @@ -462,28 +462,22 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id, spin_lock(&net->can.rcvlists_lock); dev_rcv_lists = can_dev_rcv_lists_find(net, dev); - if (dev_rcv_lists) { - rcv_list = can_rcv_list_find(&can_id, &mask, dev_rcv_lists); - - rcv->can_id = can_id; - rcv->mask = mask; - rcv->matches = 0; - rcv->func = func; - rcv->data = data; - rcv->ident = ident; - rcv->sk = sk; - - hlist_add_head_rcu(&rcv->list, rcv_list); - dev_rcv_lists->entries++; - - rcv_lists_stats->rcv_entries++; - rcv_lists_stats->rcv_entries_max = max(rcv_lists_stats->rcv_entries_max, - rcv_lists_stats->rcv_entries); - } else { - kmem_cache_free(rcv_cache, rcv); - err = -ENODEV; - } + rcv_list = can_rcv_list_find(&can_id, &mask, dev_rcv_lists); + + rcv->can_id = can_id; + rcv->mask = mask; + rcv->matches = 0; + rcv->func = func; + rcv->data = data; + rcv->ident = ident; + rcv->sk = sk; + hlist_add_head_rcu(&rcv->list, rcv_list); + dev_rcv_lists->entries++; + + rcv_lists_stats->rcv_entries++; + rcv_lists_stats->rcv_entries_max = max(rcv_lists_stats->rcv_entries_max, + rcv_lists_stats->rcv_entries); spin_unlock(&net->can.rcvlists_lock); return err; @@ -530,12 +524,6 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, spin_lock(&net->can.rcvlists_lock); dev_rcv_lists = can_dev_rcv_lists_find(net, dev); - if (!dev_rcv_lists) { - pr_err("BUG: receive list not found for dev %s, id %03X, mask %03X\n", - DNAME(dev), can_id, mask); - goto out; - } - rcv_list = can_rcv_list_find(&can_id, &mask, dev_rcv_lists); /* Search the receiver list for the item to delete. This should @@ -668,8 +656,7 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev) /* find receive list for this device */ dev_rcv_lists = can_dev_rcv_lists_find(net, dev); - if (dev_rcv_lists) - matches += can_rcv_filter(dev_rcv_lists, skb); + matches += can_rcv_filter(dev_rcv_lists, skb); rcu_read_unlock(); |