]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: Remove redundant if statements
authorYajun Deng <yajun.deng@linux.dev>
Thu, 5 Aug 2021 11:55:27 +0000 (19:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Aug 2021 12:27:50 +0000 (13:27 +0100)
The 'if (dev)' statement already move into dev_{put , hold}, so remove
redundant if statements.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Signed-off-by: David S. Miller <davem@davemloft.net>
39 files changed:
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/distributed-arp-table.c
net/batman-adv/gateway_client.c
net/batman-adv/multicast.c
net/batman-adv/originator.c
net/batman-adv/translation-table.c
net/can/raw.c
net/core/dev.c
net/core/drop_monitor.c
net/core/dst.c
net/core/neighbour.c
net/decnet/dn_dev.c
net/decnet/dn_fib.c
net/decnet/dn_route.c
net/ethtool/netlink.c
net/ieee802154/nl-phy.c
net/ieee802154/nl802154.c
net/ieee802154/socket.c
net/ipv4/fib_semantics.c
net/ipv4/icmp.c
net/ipv4/route.c
net/ipv6/addrconf.c
net/ipv6/ip6mr.c
net/ipv6/route.c
net/llc/af_llc.c
net/netfilter/nf_flow_table_offload.c
net/netfilter/nf_queue.c
net/netlabel/netlabel_unlabeled.c
net/netrom/nr_loopback.c
net/netrom/nr_route.c
net/packet/af_packet.c
net/phonet/af_phonet.c
net/phonet/pn_dev.c
net/phonet/socket.c
net/sched/act_mirred.c
net/smc/smc_ib.c
net/smc/smc_pnet.c
net/wireless/nl80211.c
net/wireless/scan.c

index 63d42dcc9324a9d0da055cf504bb56c2d2434cc4..2b639c8b0ded579115b9397b02b5709bd5f6086e 100644 (file)
@@ -2274,8 +2274,7 @@ out:
        if (primary_if)
                batadv_hardif_put(primary_if);
 
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        return ret;
 }
@@ -2446,8 +2445,7 @@ out:
        if (primary_if)
                batadv_hardif_put(primary_if);
 
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        return ret;
 }
index 8c95a11a830acc7ffe160da7ec4fdd45560756fe..7976a0435662f4ae78d780ca493b9819682e6c18 100644 (file)
@@ -984,8 +984,7 @@ out:
        if (primary_if)
                batadv_hardif_put(primary_if);
 
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        return ret;
 }
index 007f2827935d5409e3a1932134d35d6c2ac5a203..36a98d3cefe0d510efcb23a087a07bcae759e1da 100644 (file)
@@ -557,8 +557,7 @@ int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb)
 out:
        if (primary_if)
                batadv_hardif_put(primary_if);
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        return ret;
 }
index 923e2197c2db008ba1cd9b80422ec8481c6a8185..0158f267c403befd4f20bbfd9bc1df41bdc5cd24 100644 (file)
@@ -91,8 +91,7 @@ static struct net_device *batadv_mcast_get_bridge(struct net_device *soft_iface)
                upper = netdev_master_upper_dev_get_rcu(upper);
        } while (upper && !(upper->priv_flags & IFF_EBRIDGE));
 
-       if (upper)
-               dev_hold(upper);
+       dev_hold(upper);
        rcu_read_unlock();
 
        return upper;
@@ -509,8 +508,7 @@ batadv_mcast_mla_softif_get(struct net_device *dev,
        }
 
 out:
-       if (bridge)
-               dev_put(bridge);
+       dev_put(bridge);
 
        return ret4 + ret6;
 }
@@ -2239,8 +2237,7 @@ batadv_mcast_netlink_get_primary(struct netlink_callback *cb,
        }
 
 out:
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        if (!ret && primary_if)
                *primary_if = hard_iface;
index da7249448474794de8835f069cbb7ecd15c4560b..6a4d3f437e00346b21f6846413de2161125bff04 100644 (file)
@@ -799,12 +799,10 @@ int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb)
  out:
        if (hardif)
                batadv_hardif_put(hardif);
-       if (hard_iface)
-               dev_put(hard_iface);
+       dev_put(hard_iface);
        if (primary_if)
                batadv_hardif_put(primary_if);
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        return ret;
 }
@@ -1412,12 +1410,10 @@ int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb)
  out:
        if (hardif)
                batadv_hardif_put(hardif);
-       if (hard_iface)
-               dev_put(hard_iface);
+       dev_put(hard_iface);
        if (primary_if)
                batadv_hardif_put(primary_if);
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        return ret;
 }
index 434b4f0429092c80a9426d557adf5e00434de4ea..711fe5a2cec47cb49993559192db261f1f588b09 100644 (file)
@@ -820,8 +820,7 @@ check_roaming:
 out:
        if (in_hardif)
                batadv_hardif_put(in_hardif);
-       if (in_dev)
-               dev_put(in_dev);
+       dev_put(in_dev);
        if (tt_local)
                batadv_tt_local_entry_put(tt_local);
        if (tt_global)
@@ -1217,8 +1216,7 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
  out:
        if (primary_if)
                batadv_hardif_put(primary_if);
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        cb->args[0] = bucket;
        cb->args[1] = idx;
@@ -2005,8 +2003,7 @@ int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb)
  out:
        if (primary_if)
                batadv_hardif_put(primary_if);
-       if (soft_iface)
-               dev_put(soft_iface);
+       dev_put(soft_iface);
 
        cb->args[0] = bucket;
        cb->args[1] = idx;
index cd5a4938011620cd97aecc2a677615e6a07679ab..7105fa4824e4b4f48b30186828126c59fd5f2938 100644 (file)
@@ -592,9 +592,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
                ro->count  = count;
 
  out_fil:
-               if (dev)
-                       dev_put(dev);
-
+               dev_put(dev);
                release_sock(sk);
                rtnl_unlock();
 
@@ -638,9 +636,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
                ro->err_mask = err_mask;
 
  out_err:
-               if (dev)
-                       dev_put(dev);
-
+               dev_put(dev);
                release_sock(sk);
                rtnl_unlock();
 
index 5af0ba1ed473265ab3a084210e844721d421eafc..eaaeff404ce99e6ebc0f8d98bc8fb98bbdb95c34 100644 (file)
@@ -831,8 +831,7 @@ struct net_device *dev_get_by_name(struct net *net, const char *name)
 
        rcu_read_lock();
        dev = dev_get_by_name_rcu(net, name);
-       if (dev)
-               dev_hold(dev);
+       dev_hold(dev);
        rcu_read_unlock();
        return dev;
 }
@@ -905,8 +904,7 @@ struct net_device *dev_get_by_index(struct net *net, int ifindex)
 
        rcu_read_lock();
        dev = dev_get_by_index_rcu(net, ifindex);
-       if (dev)
-               dev_hold(dev);
+       dev_hold(dev);
        rcu_read_unlock();
        return dev;
 }
index ead2a8aa57b478de1b96dd9907a7685af70b1d39..49442cae6f69d5e9d93d00b53ab8f5a0563c1d37 100644 (file)
@@ -850,8 +850,7 @@ net_dm_hw_metadata_copy(const struct devlink_trap_metadata *metadata)
        }
 
        hw_metadata->input_dev = metadata->input_dev;
-       if (hw_metadata->input_dev)
-               dev_hold(hw_metadata->input_dev);
+       dev_hold(hw_metadata->input_dev);
 
        return hw_metadata;
 
@@ -867,8 +866,7 @@ free_hw_metadata:
 static void
 net_dm_hw_metadata_free(const struct devlink_trap_metadata *hw_metadata)
 {
-       if (hw_metadata->input_dev)
-               dev_put(hw_metadata->input_dev);
+       dev_put(hw_metadata->input_dev);
        kfree(hw_metadata->fa_cookie);
        kfree(hw_metadata->trap_name);
        kfree(hw_metadata->trap_group_name);
index fb3bcba87744d3f48fcfbdd229f3313c7520f196..497ef9b3fc6abb5fd9c74e5730c3aedc3277f850 100644 (file)
@@ -49,8 +49,7 @@ void dst_init(struct dst_entry *dst, struct dst_ops *ops,
              unsigned short flags)
 {
        dst->dev = dev;
-       if (dev)
-               dev_hold(dev);
+       dev_hold(dev);
        dst->ops = ops;
        dst_init_metrics(dst, dst_default_metrics.metrics, true);
        dst->expires = 0UL;
@@ -118,8 +117,7 @@ struct dst_entry *dst_destroy(struct dst_entry * dst)
 
        if (dst->ops->destroy)
                dst->ops->destroy(dst);
-       if (dst->dev)
-               dev_put(dst->dev);
+       dev_put(dst->dev);
 
        lwtstate_put(dst->lwtstate);
 
index 5427c4b9c08760bd498db36ead3f2fef2e8372ef..b963d6b02c4f94f54df53eb09e7641d5e233f2f3 100644 (file)
@@ -741,12 +741,10 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
        write_pnet(&n->net, net);
        memcpy(n->key, pkey, key_len);
        n->dev = dev;
-       if (dev)
-               dev_hold(dev);
+       dev_hold(dev);
 
        if (tbl->pconstructor && tbl->pconstructor(n)) {
-               if (dev)
-                       dev_put(dev);
+               dev_put(dev);
                kfree(n);
                n = NULL;
                goto out;
@@ -778,8 +776,7 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey,
                        write_unlock_bh(&tbl->lock);
                        if (tbl->pdestructor)
                                tbl->pdestructor(n);
-                       if (n->dev)
-                               dev_put(n->dev);
+                       dev_put(n->dev);
                        kfree(n);
                        return 0;
                }
@@ -812,8 +809,7 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl,
                n->next = NULL;
                if (tbl->pdestructor)
                        tbl->pdestructor(n);
-               if (n->dev)
-                       dev_put(n->dev);
+               dev_put(n->dev);
                kfree(n);
        }
        return -ENOENT;
@@ -1662,8 +1658,7 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
        list_del(&parms->list);
        parms->dead = 1;
        write_unlock_bh(&tbl->lock);
-       if (parms->dev)
-               dev_put(parms->dev);
+       dev_put(parms->dev);
        call_rcu(&parms->rcu_head, neigh_rcu_free_parms);
 }
 EXPORT_SYMBOL(neigh_parms_release);
index d1c50a48614b584b9ee02aca2f0398b8c1f89182..0ee7d4c0c95545542d850cd2061cc3cddde38306 100644 (file)
@@ -521,8 +521,7 @@ int dn_dev_set_default(struct net_device *dev, int force)
        }
        spin_unlock(&dndev_lock);
 
-       if (old)
-               dev_put(old);
+       dev_put(old);
        return rv;
 }
 
@@ -536,8 +535,7 @@ static void dn_dev_check_default(struct net_device *dev)
        }
        spin_unlock(&dndev_lock);
 
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
 }
 
 /*
index 153a5fc1bdde13607572236588e36be2a7a8ea27..269c029ad74fce39af444df003b645605048045b 100644 (file)
@@ -92,8 +92,7 @@ void dn_fib_free_info(struct dn_fib_info *fi)
        }
 
        change_nexthops(fi) {
-               if (nh->nh_dev)
-                       dev_put(nh->nh_dev);
+               dev_put(nh->nh_dev);
                nh->nh_dev = NULL;
        } endfor_nexthops(fi);
        kfree(fi);
index 729d3de6020d1287e3755f2d47667aa88f2c8671..7e85f2a1ae2541b093d58e1a4f9c3b224ab5476d 100644 (file)
@@ -1026,8 +1026,7 @@ source_ok:
        if (!fld.daddr) {
                fld.daddr = fld.saddr;
 
-               if (dev_out)
-                       dev_put(dev_out);
+               dev_put(dev_out);
                err = -EINVAL;
                dev_out = init_net.loopback_dev;
                if (!dev_out->dn_ptr)
@@ -1084,8 +1083,7 @@ source_ok:
                                        neigh_release(neigh);
                                        neigh = NULL;
                                } else {
-                                       if (dev_out)
-                                               dev_put(dev_out);
+                                       dev_put(dev_out);
                                        if (dn_dev_islocal(neigh->dev, fld.daddr)) {
                                                dev_out = init_net.loopback_dev;
                                                res.type = RTN_LOCAL;
@@ -1144,8 +1142,7 @@ select_source:
        if (res.type == RTN_LOCAL) {
                if (!fld.saddr)
                        fld.saddr = fld.daddr;
-               if (dev_out)
-                       dev_put(dev_out);
+               dev_put(dev_out);
                dev_out = init_net.loopback_dev;
                dev_hold(dev_out);
                if (!dev_out->dn_ptr)
@@ -1168,8 +1165,7 @@ select_source:
        if (!fld.saddr)
                fld.saddr = DN_FIB_RES_PREFSRC(res);
 
-       if (dev_out)
-               dev_put(dev_out);
+       dev_put(dev_out);
        dev_out = DN_FIB_RES_DEV(res);
        dev_hold(dev_out);
        fld.flowidn_oif = dev_out->ifindex;
@@ -1222,8 +1218,7 @@ done:
                neigh_release(neigh);
        if (free_res)
                dn_fib_res_put(&res);
-       if (dev_out)
-               dev_put(dev_out);
+       dev_put(dev_out);
 out:
        return err;
 
@@ -1503,8 +1498,7 @@ done:
        if (free_res)
                dn_fib_res_put(&res);
        dev_put(in_dev);
-       if (out_dev)
-               dev_put(out_dev);
+       dev_put(out_dev);
 out:
        return err;
 
index 417aaf9ca219edc5cd2dc339d7e538cbe68ea3d3..f8bca08e727e618b014db615ff61381e9a5761f6 100644 (file)
@@ -398,8 +398,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
                ops->cleanup_data(reply_data);
 
        genlmsg_end(rskb, reply_payload);
-       if (req_info->dev)
-               dev_put(req_info->dev);
+       dev_put(req_info->dev);
        kfree(reply_data);
        kfree(req_info);
        return genlmsg_reply(rskb, info);
@@ -411,8 +410,7 @@ err_cleanup:
        if (ops->cleanup_data)
                ops->cleanup_data(reply_data);
 err_dev:
-       if (req_info->dev)
-               dev_put(req_info->dev);
+       dev_put(req_info->dev);
        kfree(reply_data);
        kfree(req_info);
        return ret;
index 88215b5c93aa429bc9421745de9fcfb09843aa18..dd5a45f8a78a07557e229ede483a7d1048e79b22 100644 (file)
@@ -340,8 +340,7 @@ nla_put_failure:
 out_dev:
        wpan_phy_put(phy);
 out:
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
 
        return rc;
 }
index 0cf2374c143bdd9f02fa076ddacb086f1a1510bf..277124f206e0639716f6bafe6e98bd1c49a14446 100644 (file)
@@ -2226,8 +2226,7 @@ static void nl802154_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
                if (ops->internal_flags & NL802154_FLAG_NEED_WPAN_DEV) {
                        struct wpan_dev *wpan_dev = info->user_ptr[1];
 
-                       if (wpan_dev->netdev)
-                               dev_put(wpan_dev->netdev);
+                       dev_put(wpan_dev->netdev);
                } else {
                        dev_put(info->user_ptr[1]);
                }
index f5077de3619e3ddbd5c3ac7695fdc7045c35a4ee..90233efa1f6bf290feef304e7d95ef53e44cf03a 100644 (file)
@@ -41,8 +41,7 @@ ieee802154_get_dev(struct net *net, const struct ieee802154_addr *addr)
                ieee802154_devaddr_to_raw(hwaddr, addr->extended_addr);
                rcu_read_lock();
                dev = dev_getbyhwaddr_rcu(net, ARPHRD_IEEE802154, hwaddr);
-               if (dev)
-                       dev_hold(dev);
+               dev_hold(dev);
                rcu_read_unlock();
                break;
        case IEEE802154_ADDR_SHORT:
index f29feb7772da32c215ea7f732a3f630e96721efb..b42c429cebbe805beabd41233b24203fb82fc0cf 100644 (file)
@@ -208,9 +208,7 @@ static void rt_fibinfo_free_cpus(struct rtable __rcu * __percpu *rtp)
 
 void fib_nh_common_release(struct fib_nh_common *nhc)
 {
-       if (nhc->nhc_dev)
-               dev_put(nhc->nhc_dev);
-
+       dev_put(nhc->nhc_dev);
        lwtstate_put(nhc->nhc_lwtstate);
        rt_fibinfo_free_cpus(nhc->nhc_pcpu_rth_output);
        rt_fibinfo_free(&nhc->nhc_rth_input);
index c695d294a5dfad1e1a2ebe2ccc837f2f3be15dd3..8b30cadff708f96f4acf4a459c8e9c0397f8d305 100644 (file)
@@ -1095,8 +1095,7 @@ bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr)
                                         sizeof(struct in6_addr))
                                goto send_mal_query;
                        dev = ipv6_stub->ipv6_dev_find(net, &iio->ident.addr.ip_addr.ipv6_addr, dev);
-                       if (dev)
-                               dev_hold(dev);
+                       dev_hold(dev);
                        break;
 #endif
                default:
index 44a96cfcfbdf96aef5f1a0c130e86905d6de8274..b181773d7ad38e7c4baae104bb8088daf531e7f4 100644 (file)
@@ -2813,8 +2813,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
                new->output = dst_discard_out;
 
                new->dev = net->loopback_dev;
-               if (new->dev)
-                       dev_hold(new->dev);
+               dev_hold(new->dev);
 
                rt->rt_is_input = ort->rt_is_input;
                rt->rt_iif = ort->rt_iif;
index 0b786fc7b7d455cb88e96ce66716994694d37b41..8381288a0d6ec4f2a8f77b958ff2ab03da9dff2a 100644 (file)
@@ -701,8 +701,7 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
 errout:
        if (in6_dev)
                in6_dev_put(in6_dev);
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
        return err;
 }
 
@@ -5417,8 +5416,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 errout_ifa:
        in6_ifa_put(ifa);
 errout:
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
        if (fillargs.netnsid >= 0)
                put_net(tgt_net);
 
index 06b0d2c329b94b25f2945b220347c5d9defdc72e..36ed9efb88254003720549da52f39b11e9bf911f 100644 (file)
@@ -559,8 +559,7 @@ static int pim6_rcv(struct sk_buff *skb)
        read_lock(&mrt_lock);
        if (reg_vif_num >= 0)
                reg_dev = mrt->vif_table[reg_vif_num].dev;
-       if (reg_dev)
-               dev_hold(reg_dev);
+       dev_hold(reg_dev);
        read_unlock(&mrt_lock);
 
        if (!reg_dev)
index 6b8051106aba7fb6fa0aed067dea90d87d61fe7a..6cf4bb89ca697f0aaa9035353e677367a1a0cb1c 100644 (file)
@@ -3626,8 +3626,7 @@ out:
        if (err) {
                lwtstate_put(fib6_nh->fib_nh_lws);
                fib6_nh->fib_nh_lws = NULL;
-               if (dev)
-                       dev_put(dev);
+               dev_put(dev);
        }
 
        return err;
index ac5cadd02cfa8f6ee937ee91252a71a750d447ee..3086f4a6ae683f1119d4813648bf9fd9ba215436 100644 (file)
@@ -224,8 +224,7 @@ static int llc_ui_release(struct socket *sock)
        } else {
                release_sock(sk);
        }
-       if (llc->dev)
-               dev_put(llc->dev);
+       dev_put(llc->dev);
        sock_put(sk);
        llc_sk_free(sk);
 out:
@@ -363,8 +362,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
        } else
                llc->dev = dev_getbyhwaddr_rcu(&init_net, addr->sllc_arphrd,
                                           addr->sllc_mac);
-       if (llc->dev)
-               dev_hold(llc->dev);
+       dev_hold(llc->dev);
        rcu_read_unlock();
        if (!llc->dev)
                goto out;
index f92006cec94c4e3d5cecb69884b8c2581aa166cc..2bfd9f1b8f11fc53b0997604f2f19ee6051013c9 100644 (file)
@@ -251,8 +251,7 @@ static int flow_offload_eth_src(struct net *net,
        flow_offload_mangle(entry1, FLOW_ACT_MANGLE_HDR_TYPE_ETH, 8,
                            &val, &mask);
 
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
 
        return 0;
 }
index bbd1209694b89bb1164c39ce581f54b24f61e8d4..7f2f69b609d87a2b193c49a4ea50613ac6609585 100644 (file)
@@ -51,18 +51,14 @@ static void nf_queue_entry_release_refs(struct nf_queue_entry *entry)
        struct nf_hook_state *state = &entry->state;
 
        /* Release those devices we held, or Alexey will kill me. */
-       if (state->in)
-               dev_put(state->in);
-       if (state->out)
-               dev_put(state->out);
+       dev_put(state->in);
+       dev_put(state->out);
        if (state->sk)
                sock_put(state->sk);
 
 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
-       if (entry->physin)
-               dev_put(entry->physin);
-       if (entry->physout)
-               dev_put(entry->physout);
+       dev_put(entry->physin);
+       dev_put(entry->physout);
 #endif
 }
 
@@ -95,18 +91,14 @@ void nf_queue_entry_get_refs(struct nf_queue_entry *entry)
 {
        struct nf_hook_state *state = &entry->state;
 
-       if (state->in)
-               dev_hold(state->in);
-       if (state->out)
-               dev_hold(state->out);
+       dev_hold(state->in);
+       dev_hold(state->out);
        if (state->sk)
                sock_hold(state->sk);
 
 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
-       if (entry->physin)
-               dev_hold(entry->physin);
-       if (entry->physout)
-               dev_hold(entry->physout);
+       dev_hold(entry->physin);
+       dev_hold(entry->physout);
 #endif
 }
 EXPORT_SYMBOL_GPL(nf_queue_entry_get_refs);
index 2483df0bbd7c799c3cbd5cf0a2ff910948478e1d..566ba4397ee4007e8ed170bb775253f4b15f9079 100644 (file)
@@ -492,8 +492,7 @@ static int netlbl_unlhsh_remove_addr4(struct net *net,
                netlbl_af4list_audit_addr(audit_buf, 1,
                                          (dev != NULL ? dev->name : NULL),
                                          addr->s_addr, mask->s_addr);
-               if (dev != NULL)
-                       dev_put(dev);
+               dev_put(dev);
                if (entry != NULL &&
                    security_secid_to_secctx(entry->secid,
                                             &secctx, &secctx_len) == 0) {
@@ -553,8 +552,7 @@ static int netlbl_unlhsh_remove_addr6(struct net *net,
                netlbl_af6list_audit_addr(audit_buf, 1,
                                          (dev != NULL ? dev->name : NULL),
                                          addr, mask);
-               if (dev != NULL)
-                       dev_put(dev);
+               dev_put(dev);
                if (entry != NULL &&
                    security_secid_to_secctx(entry->secid,
                                             &secctx, &secctx_len) == 0) {
index a880dd33e901c5291b762eee6d0b499c1145e216..511819fbfa679a0627c20a15ae785d7166dc066a 100644 (file)
@@ -59,8 +59,7 @@ static void nr_loopback_timer(struct timer_list *unused)
                if (dev == NULL || nr_rx_frame(skb, dev) == 0)
                        kfree_skb(skb);
 
-               if (dev != NULL)
-                       dev_put(dev);
+               dev_put(dev);
 
                if (!skb_queue_empty(&loopback_queue) && !nr_loopback_running())
                        mod_timer(&loopback_timer, jiffies + 10);
index de0456073dc0b0ddb85bfb7e888299c2a45384d6..ddd5cbd455e39221dbc79d99acc60485b379a2d0 100644 (file)
@@ -582,8 +582,7 @@ struct net_device *nr_dev_first(void)
                        if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
                                first = dev;
        }
-       if (first)
-               dev_hold(first);
+       dev_hold(first);
        rcu_read_unlock();
 
        return first;
index 57a1971f29e51f4d53990524117e708b4806c3ff..543365f58e9735338b16d5e8f4c824fbaec92c9d 100644 (file)
@@ -250,8 +250,7 @@ static struct net_device *packet_cached_dev_get(struct packet_sock *po)
 
        rcu_read_lock();
        dev = rcu_dereference(po->cached_dev);
-       if (likely(dev))
-               dev_hold(dev);
+       dev_hold(dev);
        rcu_read_unlock();
 
        return dev;
@@ -3024,8 +3023,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 out_free:
        kfree_skb(skb);
 out_unlock:
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
 out:
        return err;
 }
@@ -3158,8 +3156,7 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
                }
        }
 
-       if (dev)
-               dev_hold(dev);
+       dev_hold(dev);
 
        proto_curr = po->prot_hook.type;
        dev_curr = po->prot_hook.dev;
@@ -3196,8 +3193,7 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
                        packet_cached_dev_assign(po, dev);
                }
        }
-       if (dev_curr)
-               dev_put(dev_curr);
+       dev_put(dev_curr);
 
        if (proto == 0 || !need_rehook)
                goto out_unlock;
@@ -4109,8 +4105,7 @@ static int packet_notifier(struct notifier_block *this,
                                if (msg == NETDEV_UNREGISTER) {
                                        packet_cached_dev_reset(po);
                                        WRITE_ONCE(po->ifindex, -1);
-                                       if (po->prot_hook.dev)
-                                               dev_put(po->prot_hook.dev);
+                                       dev_put(po->prot_hook.dev);
                                        po->prot_hook.dev = NULL;
                                }
                                spin_unlock(&po->bind_lock);
index ca6ae4c59433fb6755270856512e657bebbfcf07..65218b7ce9f947a46efa68b89e0363a18e129a41 100644 (file)
@@ -275,8 +275,7 @@ int pn_skb_send(struct sock *sk, struct sk_buff *skb,
 
 drop:
        kfree_skb(skb);
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
        return err;
 }
 EXPORT_SYMBOL(pn_skb_send);
index 876d0ae5f9fdc4a4293753610addaeaf45ce3781..cde671d29d5dd36435e098930f209580d467f4fd 100644 (file)
@@ -122,8 +122,7 @@ struct net_device *phonet_device_get(struct net *net)
                        break;
                dev = NULL;
        }
-       if (dev)
-               dev_hold(dev);
+       dev_hold(dev);
        rcu_read_unlock();
        return dev;
 }
@@ -411,8 +410,7 @@ struct net_device *phonet_route_output(struct net *net, u8 daddr)
        daddr >>= 2;
        rcu_read_lock();
        dev = rcu_dereference(routes->table[daddr]);
-       if (dev)
-               dev_hold(dev);
+       dev_hold(dev);
        rcu_read_unlock();
 
        if (!dev)
index 2599235d592e0bab2c0201929d2090d3658aee3c..71e2caf6ab859cdd5c53ca562b35fe1a193c20c5 100644 (file)
@@ -379,8 +379,7 @@ static int pn_socket_ioctl(struct socket *sock, unsigned int cmd,
                        saddr = PN_NO_ADDR;
                release_sock(sk);
 
-               if (dev)
-                       dev_put(dev);
+               dev_put(dev);
                if (saddr == PN_NO_ADDR)
                        return -EHOSTUNREACH;
 
index 77ee80e3effca6e5173075054e168e735beb8514..37f51d778728958545b56cfd5bb30e410ad2aa4f 100644 (file)
@@ -78,8 +78,7 @@ static void tcf_mirred_release(struct tc_action *a)
 
        /* last reference to action, no need to lock */
        dev = rcu_dereference_protected(m->tcfm_dev, 1);
-       if (dev)
-               dev_put(dev);
+       dev_put(dev);
 }
 
 static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
@@ -180,8 +179,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
                mac_header_xmit = dev_is_mac_header_xmit(dev);
                dev = rcu_replace_pointer(m->tcfm_dev, dev,
                                          lockdep_is_held(&m->tcf_lock));
-               if (dev)
-                       dev_put(dev);
+               dev_put(dev);
                m->tcfm_mac_header_xmit = mac_header_xmit;
        }
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
index 7d7ba0320d5aefc539838c0bf13e365e181d43a7..a8845343d183e86ae7a23ed4dcd7dd9b023a68df 100644 (file)
@@ -753,8 +753,7 @@ void smc_ib_ndev_change(struct net_device *ndev, unsigned long event)
                        if (!libdev->ops.get_netdev)
                                continue;
                        lndev = libdev->ops.get_netdev(libdev, i + 1);
-                       if (lndev)
-                               dev_put(lndev);
+                       dev_put(lndev);
                        if (lndev != ndev)
                                continue;
                        if (event == NETDEV_REGISTER)
index 6f6d33edb13570742bbdbfda514281e4e2387185..4a964e9190b02a7479617828d0d40f8b19c832dd 100644 (file)
@@ -394,8 +394,7 @@ static int smc_pnet_add_eth(struct smc_pnettable *pnettable, struct net *net,
        return 0;
 
 out_put:
-       if (ndev)
-               dev_put(ndev);
+       dev_put(ndev);
        return rc;
 }
 
index 16c88beea48b8ed5b90460c76b8c217f11852d0d..dceed5b5b226758810d8e50e6570a5fd455040f7 100644 (file)
@@ -6527,8 +6527,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
        err = rdev_change_station(rdev, dev, mac_addr, &params);
 
  out_put_vlan:
-       if (params.vlan)
-               dev_put(params.vlan);
+       dev_put(params.vlan);
 
        return err;
 }
@@ -6763,8 +6762,7 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 
        err = rdev_add_station(rdev, dev, mac_addr, &params);
 
-       if (params.vlan)
-               dev_put(params.vlan);
+       dev_put(params.vlan);
        return err;
 }
 
@@ -8489,8 +8487,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
                goto out_free;
 
        nl80211_send_scan_start(rdev, wdev);
-       if (wdev->netdev)
-               dev_hold(wdev->netdev);
+       dev_hold(wdev->netdev);
 
        return 0;
 
@@ -14860,9 +14857,7 @@ static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
                        return -ENETDOWN;
                }
 
-               if (dev)
-                       dev_hold(dev);
-
+               dev_hold(dev);
                info->user_ptr[0] = rdev;
        }
 
@@ -14884,8 +14879,7 @@ static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
                if (ops->internal_flags & NL80211_FLAG_NEED_WDEV) {
                        struct wireless_dev *wdev = info->user_ptr[1];
 
-                       if (wdev->netdev)
-                               dev_put(wdev->netdev);
+                       dev_put(wdev->netdev);
                } else {
                        dev_put(info->user_ptr[1]);
                }
index 7897b1478c3c03b59bf72da33c67c9f5762db5ca..11c68b1593245926fc00667c1fb6fe206ddbbd14 100644 (file)
@@ -975,8 +975,7 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
        }
 #endif
 
-       if (wdev->netdev)
-               dev_put(wdev->netdev);
+       dev_put(wdev->netdev);
 
        kfree(rdev->int_scan_req);
        rdev->int_scan_req = NULL;