summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-02-21 22:02:58 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2026-02-21 22:02:58 +0300
commit8934827db5403eae57d4537114a9ff88b0a8460f (patch)
tree5167aa7e16b786b9135e19d508b234054fa6e8ce /net
parentc7decec2f2d2ab0366567f9e30c0e1418cece43f (diff)
parent7a70c15bd1449f1eb30991772edce37b41e496fb (diff)
downloadlinux-8934827db5403eae57d4537114a9ff88b0a8460f.tar.xz
Merge tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull kmalloc_obj conversion from Kees Cook: "This does the tree-wide conversion to kmalloc_obj() and friends using coccinelle, with a subsequent small manual cleanup of whitespace alignment that coccinelle does not handle. This uncovered a clang bug in __builtin_counted_by_ref(), so the conversion is preceded by disabling that for current versions of clang. The imminent clang 22.1 release has the fix. I've done allmodconfig build tests for x86_64, arm64, i386, and arm. I did defconfig builds for alpha, m68k, mips, parisc, powerpc, riscv, s390, sparc, sh, arc, csky, xtensa, hexagon, and openrisc" * tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: kmalloc_obj: Clean up after treewide replacements treewide: Replace kmalloc with kmalloc_obj for non-scalar types compiler_types: Disable __builtin_counted_by_ref for Clang
Diffstat (limited to 'net')
-rw-r--r--net/802/garp.c4
-rw-r--r--net/802/mrp.c4
-rw-r--r--net/802/psnap.c2
-rw-r--r--net/8021q/vlan_core.c4
-rw-r--r--net/8021q/vlan_dev.c4
-rw-r--r--net/9p/client.c8
-rw-r--r--net/9p/protocol.c5
-rw-r--r--net/9p/trans_fd.c5
-rw-r--r--net/9p/trans_rdma.c6
-rw-r--r--net/9p/trans_usbg.c6
-rw-r--r--net/9p/trans_virtio.c7
-rw-r--r--net/9p/trans_xen.c5
-rw-r--r--net/appletalk/aarp.c2
-rw-r--r--net/appletalk/ddp.c4
-rw-r--r--net/atm/addr.c2
-rw-r--r--net/atm/br2684.c2
-rw-r--r--net/atm/clip.c2
-rw-r--r--net/atm/lec.c6
-rw-r--r--net/atm/mpc.c4
-rw-r--r--net/atm/mpoa_caches.c4
-rw-r--r--net/atm/pppoatm.c2
-rw-r--r--net/atm/resources.c2
-rw-r--r--net/ax25/af_ax25.c4
-rw-r--r--net/ax25/ax25_dev.c2
-rw-r--r--net/ax25/ax25_iface.c2
-rw-r--r--net/ax25/ax25_in.c2
-rw-r--r--net/ax25/ax25_route.c6
-rw-r--r--net/ax25/ax25_uid.c2
-rw-r--r--net/batman-adv/bat_v_elp.c2
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c4
-rw-r--r--net/batman-adv/distributed-arp-table.c5
-rw-r--r--net/batman-adv/fragmentation.c2
-rw-r--r--net/batman-adv/gateway_client.c2
-rw-r--r--net/batman-adv/hard-interface.c2
-rw-r--r--net/batman-adv/hash.c7
-rw-r--r--net/batman-adv/mesh-interface.c2
-rw-r--r--net/batman-adv/multicast.c6
-rw-r--r--net/batman-adv/originator.c12
-rw-r--r--net/batman-adv/send.c2
-rw-r--r--net/batman-adv/tp_meter.c6
-rw-r--r--net/batman-adv/tvlv.c2
-rw-r--r--net/bluetooth/6lowpan.c6
-rw-r--r--net/bluetooth/cmtp/capi.c2
-rw-r--r--net/bluetooth/cmtp/core.c2
-rw-r--r--net/bluetooth/hci_conn.c12
-rw-r--r--net/bluetooth/hci_core.c22
-rw-r--r--net/bluetooth/hci_sync.c10
-rw-r--r--net/bluetooth/hidp/core.c2
-rw-r--r--net/bluetooth/iso.c2
-rw-r--r--net/bluetooth/l2cap_core.c4
-rw-r--r--net/bluetooth/l2cap_sock.c4
-rw-r--r--net/bluetooth/mgmt.c14
-rw-r--r--net/bluetooth/mgmt_util.c4
-rw-r--r--net/bluetooth/msft.c8
-rw-r--r--net/bluetooth/rfcomm/core.c4
-rw-r--r--net/bluetooth/rfcomm/tty.c4
-rw-r--r--net/bluetooth/sco.c2
-rw-r--r--net/bluetooth/smp.c8
-rw-r--r--net/bpf/bpf_dummy_struct_ops.c6
-rw-r--r--net/bridge/br_cfm.c4
-rw-r--r--net/bridge/br_device.c2
-rw-r--r--net/bridge/br_if.c2
-rw-r--r--net/bridge/br_ioctl.c4
-rw-r--r--net/bridge/br_mdb.c4
-rw-r--r--net/bridge/br_mrp.c2
-rw-r--r--net/bridge/br_multicast.c8
-rw-r--r--net/bridge/br_multicast_eht.c6
-rw-r--r--net/bridge/br_switchdev.c2
-rw-r--r--net/bridge/br_vlan.c8
-rw-r--r--net/bridge/netfilter/ebtables.c2
-rw-r--r--net/caif/caif_dev.c2
-rw-r--r--net/caif/caif_usb.c2
-rw-r--r--net/caif/cfcnfg.c4
-rw-r--r--net/caif/cfctrl.c4
-rw-r--r--net/caif/cfdbgl.c2
-rw-r--r--net/caif/cfdgml.c2
-rw-r--r--net/caif/cffrml.c2
-rw-r--r--net/caif/cfmuxl.c2
-rw-r--r--net/caif/cfrfml.c2
-rw-r--r--net/caif/cfserl.c2
-rw-r--r--net/caif/cfutill.c2
-rw-r--r--net/caif/cfveil.c2
-rw-r--r--net/caif/cfvidl.c2
-rw-r--r--net/can/af_can.c9
-rw-r--r--net/can/gw.c2
-rw-r--r--net/can/j1939/bus.c2
-rw-r--r--net/can/j1939/main.c2
-rw-r--r--net/can/j1939/transport.c2
-rw-r--r--net/ceph/auth.c2
-rw-r--r--net/ceph/auth_none.c4
-rw-r--r--net/ceph/auth_x.c6
-rw-r--r--net/ceph/buffer.c2
-rw-r--r--net/ceph/ceph_common.c11
-rw-r--r--net/ceph/cls_lock_client.c2
-rw-r--r--net/ceph/crypto.c2
-rw-r--r--net/ceph/messenger.c3
-rw-r--r--net/ceph/mon_client.c8
-rw-r--r--net/ceph/osd_client.c28
-rw-r--r--net/ceph/osdmap.c25
-rw-r--r--net/ceph/pagelist.c2
-rw-r--r--net/ceph/pagevec.c2
-rw-r--r--net/ceph/striper.c4
-rw-r--r--net/core/bpf_sk_storage.c2
-rw-r--r--net/core/dev.c25
-rw-r--r--net/core/devmem.c12
-rw-r--r--net/core/drop_monitor.c8
-rw-r--r--net/core/dst.c5
-rw-r--r--net/core/failover.c2
-rw-r--r--net/core/filter.c7
-rw-r--r--net/core/flow_offload.c13
-rw-r--r--net/core/gen_estimator.c2
-rw-r--r--net/core/gro_cells.c2
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/net_namespace.c2
-rw-r--r--net/core/netclassid_cgroup.c2
-rw-r--r--net/core/netpoll.c2
-rw-r--r--net/core/netprio_cgroup.c2
-rw-r--r--net/core/rtnetlink.c4
-rw-r--r--net/core/scm.c2
-rw-r--r--net/core/selftests.c2
-rw-r--r--net/core/skmsg.c2
-rw-r--r--net/core/sock.c2
-rw-r--r--net/core/sock_diag.c2
-rw-r--r--net/core/sock_map.c2
-rw-r--r--net/core/sock_reuseport.c2
-rw-r--r--net/core/xdp.c4
-rw-r--r--net/dcb/dcbnl.c5
-rw-r--r--net/devlink/core.c4
-rw-r--r--net/devlink/dpipe.c2
-rw-r--r--net/devlink/health.c6
-rw-r--r--net/devlink/linecard.c5
-rw-r--r--net/devlink/param.c2
-rw-r--r--net/devlink/rate.c6
-rw-r--r--net/devlink/region.c6
-rw-r--r--net/devlink/resource.c2
-rw-r--r--net/devlink/sb.c2
-rw-r--r--net/devlink/trap.c6
-rw-r--r--net/dsa/dsa.c8
-rw-r--r--net/dsa/port.c4
-rw-r--r--net/dsa/switch.c8
-rw-r--r--net/dsa/tag_8021q.c4
-rw-r--r--net/dsa/tag_ksz.c4
-rw-r--r--net/dsa/tag_ocelot_8021q.c4
-rw-r--r--net/dsa/tag_qca.c2
-rw-r--r--net/dsa/tag_sja1105.c4
-rw-r--r--net/dsa/user.c14
-rw-r--r--net/ethtool/cmis_cdb.c2
-rw-r--r--net/ethtool/common.c6
-rw-r--r--net/ethtool/ioctl.c4
-rw-r--r--net/ethtool/module.c2
-rw-r--r--net/ethtool/mse.c4
-rw-r--r--net/ethtool/tsconfig.c6
-rw-r--r--net/ethtool/tsinfo.c4
-rw-r--r--net/handshake/request.c2
-rw-r--r--net/hsr/hsr_framereg.c4
-rw-r--r--net/hsr/hsr_slave.c2
-rw-r--r--net/ieee802154/nl802154.c6
-rw-r--r--net/ipv4/af_inet.c4
-rw-r--r--net/ipv4/ah4.c2
-rw-r--r--net/ipv4/cipso_ipv4.c7
-rw-r--r--net/ipv4/devinet.c9
-rw-r--r--net/ipv4/fib_semantics.c6
-rw-r--r--net/ipv4/fou_core.c2
-rw-r--r--net/ipv4/igmp.c8
-rw-r--r--net/ipv4/inet_diag.c2
-rw-r--r--net/ipv4/inet_fragment.c2
-rw-r--r--net/ipv4/inet_hashtables.c2
-rw-r--r--net/ipv4/ip_sockglue.c2
-rw-r--r--net/ipv4/ipconfig.c2
-rw-r--r--net/ipv4/ipmr_base.c2
-rw-r--r--net/ipv4/metrics.c2
-rw-r--r--net/ipv4/nexthop.c20
-rw-r--r--net/ipv4/route.c8
-rw-r--r--net/ipv4/tcp.c4
-rw-r--r--net/ipv4/tcp_ao.c2
-rw-r--r--net/ipv4/tcp_bpf.c6
-rw-r--r--net/ipv4/tcp_cdg.c4
-rw-r--r--net/ipv4/tcp_fastopen.c6
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv4/tcp_metrics.c2
-rw-r--r--net/ipv4/udp.c6
-rw-r--r--net/ipv4/udp_tunnel_nic.c9
-rw-r--r--net/ipv6/addrconf.c17
-rw-r--r--net/ipv6/addrlabel.c2
-rw-r--r--net/ipv6/af_inet6.c4
-rw-r--r--net/ipv6/ah6.c2
-rw-r--r--net/ipv6/anycast.c2
-rw-r--r--net/ipv6/calipso.c7
-rw-r--r--net/ipv6/ila/ila_xlat.c4
-rw-r--r--net/ipv6/ioam6.c8
-rw-r--r--net/ipv6/ip6_fib.c18
-rw-r--r--net/ipv6/ip6_flowlabel.c4
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/ipv6_sockglue.c2
-rw-r--r--net/ipv6/mcast.c8
-rw-r--r--net/ipv6/route.c14
-rw-r--r--net/ipv6/seg6.c8
-rw-r--r--net/ipv6/sit.c8
-rw-r--r--net/iucv/af_iucv.c2
-rw-r--r--net/iucv/iucv.c6
-rw-r--r--net/key/af_key.c6
-rw-r--r--net/l2tp/l2tp_core.c4
-rw-r--r--net/l2tp/l2tp_debugfs.c2
-rw-r--r--net/lapb/lapb_iface.c2
-rw-r--r--net/llc/llc_core.c2
-rw-r--r--net/mac80211/agg-rx.c4
-rw-r--r--net/mac80211/agg-tx.c2
-rw-r--r--net/mac80211/cfg.c12
-rw-r--r--net/mac80211/chan.c2
-rw-r--r--net/mac80211/led.c2
-rw-r--r--net/mac80211/link.c2
-rw-r--r--net/mac80211/main.c5
-rw-r--r--net/mac80211/mesh.c5
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/mesh_pathtbl.c2
-rw-r--r--net/mac80211/mlme.c2
-rw-r--r--net/mac80211/offchannel.c2
-rw-r--r--net/mac80211/parse.c4
-rw-r--r--net/mac80211/rate.c4
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c6
-rw-r--r--net/mac80211/sta_info.c8
-rw-r--r--net/mac80211/tests/util.c6
-rw-r--r--net/mac80211/tx.c6
-rw-r--r--net/mac80211/util.c5
-rw-r--r--net/mac802154/cfg.c2
-rw-r--r--net/mac802154/llsec.c12
-rw-r--r--net/mac802154/rx.c4
-rw-r--r--net/mac802154/scan.c2
-rw-r--r--net/mctp/device.c2
-rw-r--r--net/mctp/neigh.c2
-rw-r--r--net/mctp/route.c4
-rw-r--r--net/mctp/test/utils.c2
-rw-r--r--net/mpls/af_mpls.c6
-rw-r--r--net/mptcp/pm.c2
-rw-r--r--net/mptcp/subflow.c2
-rw-r--r--net/ncsi/ncsi-manage.c8
-rw-r--r--net/netfilter/ipset/ip_set_core.c6
-rw-r--r--net/netfilter/ipset/ip_set_hash_gen.h5
-rw-r--r--net/netfilter/ipset/ip_set_list_set.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_conn.c4
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c8
-rw-r--r--net/netfilter/ipvs/ip_vs_dh.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_est.c4
-rw-r--r--net/netfilter/ipvs/ip_vs_lblc.c4
-rw-r--r--net/netfilter/ipvs/ip_vs_lblcr.c6
-rw-r--r--net/netfilter/ipvs/ip_vs_mh.c11
-rw-r--r--net/netfilter/ipvs/ip_vs_proto.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_sh.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_sync.c9
-rw-r--r--net/netfilter/ipvs/ip_vs_wrr.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c2
-rw-r--r--net/netfilter/nf_bpf_link.c2
-rw-r--r--net/netfilter/nf_conncount.c2
-rw-r--r--net/netfilter/nf_conntrack_core.c4
-rw-r--r--net/netfilter/nf_conntrack_netlink.c2
-rw-r--r--net/netfilter/nf_conntrack_proto_gre.c2
-rw-r--r--net/netfilter/nf_flow_table_offload.c4
-rw-r--r--net/netfilter/nf_flow_table_xdp.c4
-rw-r--r--net/netfilter/nf_log.c2
-rw-r--r--net/netfilter/nf_nat_core.c2
-rw-r--r--net/netfilter/nf_nat_masquerade.c2
-rw-r--r--net/netfilter/nf_tables_api.c33
-rw-r--r--net/netfilter/nf_tables_offload.c4
-rw-r--r--net/netfilter/nfnetlink.c2
-rw-r--r--net/netfilter/nfnetlink_acct.c2
-rw-r--r--net/netfilter/nfnetlink_cthelper.c11
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c3
-rw-r--r--net/netfilter/nfnetlink_hook.c2
-rw-r--r--net/netfilter/nfnetlink_log.c2
-rw-r--r--net/netfilter/nfnetlink_osf.c2
-rw-r--r--net/netfilter/nfnetlink_queue.c2
-rw-r--r--net/netfilter/nft_compat.c4
-rw-r--r--net/netfilter/nft_connlimit.c4
-rw-r--r--net/netfilter/nft_ct.c3
-rw-r--r--net/netfilter/nft_last.c4
-rw-r--r--net/netfilter/nft_limit.c4
-rw-r--r--net/netfilter/nft_numgen.c2
-rw-r--r--net/netfilter/nft_quota.c4
-rw-r--r--net/netfilter/nft_set_pipapo.c11
-rw-r--r--net/netfilter/nft_set_rbtree.c6
-rw-r--r--net/netfilter/x_tables.c6
-rw-r--r--net/netfilter/xt_IDLETIMER.c4
-rw-r--r--net/netfilter/xt_LED.c2
-rw-r--r--net/netfilter/xt_RATEEST.c2
-rw-r--r--net/netfilter/xt_TEE.c2
-rw-r--r--net/netfilter/xt_hashlimit.c2
-rw-r--r--net/netfilter/xt_limit.c2
-rw-r--r--net/netfilter/xt_quota.c2
-rw-r--r--net/netfilter/xt_recent.c4
-rw-r--r--net/netfilter/xt_statistic.c2
-rw-r--r--net/netlabel/netlabel_calipso.c2
-rw-r--r--net/netlabel/netlabel_cipso_v4.c8
-rw-r--r--net/netlabel/netlabel_domainhash.c8
-rw-r--r--net/netlabel/netlabel_kapi.c20
-rw-r--r--net/netlabel/netlabel_mgmt.c10
-rw-r--r--net/netlabel/netlabel_unlabeled.c14
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/netlink/diag.c2
-rw-r--r--net/netlink/genetlink.c9
-rw-r--r--net/netlink/policy.c4
-rw-r--r--net/netrom/af_netrom.c2
-rw-r--r--net/nfc/core.c4
-rw-r--r--net/nfc/digital_core.c8
-rw-r--r--net/nfc/digital_technology.c6
-rw-r--r--net/nfc/hci/core.c4
-rw-r--r--net/nfc/hci/hcp.c2
-rw-r--r--net/nfc/hci/llc.c4
-rw-r--r--net/nfc/hci/llc_nop.c2
-rw-r--r--net/nfc/hci/llc_shdlc.c2
-rw-r--r--net/nfc/llcp_commands.c4
-rw-r--r--net/nfc/llcp_core.c2
-rw-r--r--net/nfc/nci/core.c2
-rw-r--r--net/nfc/nci/hci.c2
-rw-r--r--net/nfc/nci/uart.c2
-rw-r--r--net/nfc/netlink.c8
-rw-r--r--net/openvswitch/conntrack.c11
-rw-r--r--net/openvswitch/datapath.c9
-rw-r--r--net/openvswitch/flow_netlink.c2
-rw-r--r--net/openvswitch/flow_table.c12
-rw-r--r--net/openvswitch/meter.c4
-rw-r--r--net/openvswitch/vport.c4
-rw-r--r--net/packet/af_packet.c10
-rw-r--r--net/phonet/pn_dev.c2
-rw-r--r--net/psample/psample.c2
-rw-r--r--net/psp/psp_main.c2
-rw-r--r--net/psp/psp_sock.c4
-rw-r--r--net/qrtr/af_qrtr.c4
-rw-r--r--net/qrtr/ns.c6
-rw-r--r--net/qrtr/tun.c2
-rw-r--r--net/rds/cong.c2
-rw-r--r--net/rds/connection.c2
-rw-r--r--net/rds/ib.c5
-rw-r--r--net/rds/ib_cm.c2
-rw-r--r--net/rds/ib_rdma.c6
-rw-r--r--net/rds/info.c2
-rw-r--r--net/rds/loop.c2
-rw-r--r--net/rds/message.c2
-rw-r--r--net/rds/rdma.c20
-rw-r--r--net/rfkill/core.c6
-rw-r--r--net/rfkill/input.c2
-rw-r--r--net/rose/af_rose.c3
-rw-r--r--net/rose/rose_route.c12
-rw-r--r--net/rxrpc/call_accept.c2
-rw-r--r--net/rxrpc/conn_client.c2
-rw-r--r--net/rxrpc/conn_object.c2
-rw-r--r--net/rxrpc/key.c6
-rw-r--r--net/rxrpc/local_object.c2
-rw-r--r--net/rxrpc/peer_object.c2
-rw-r--r--net/rxrpc/rxgk.c4
-rw-r--r--net/rxrpc/rxgk_kdf.c2
-rw-r--r--net/rxrpc/rxkad.c4
-rw-r--r--net/rxrpc/rxperf.c2
-rw-r--r--net/rxrpc/sendmsg.c2
-rw-r--r--net/rxrpc/txbuf.c2
-rw-r--r--net/sched/act_api.c4
-rw-r--r--net/sched/act_connmark.c2
-rw-r--r--net/sched/act_csum.c2
-rw-r--r--net/sched/act_ct.c4
-rw-r--r--net/sched/act_ctinfo.c2
-rw-r--r--net/sched/act_gate.c2
-rw-r--r--net/sched/act_ife.c4
-rw-r--r--net/sched/act_mpls.c2
-rw-r--r--net/sched/act_nat.c2
-rw-r--r--net/sched/act_pedit.c4
-rw-r--r--net/sched/act_police.c2
-rw-r--r--net/sched/act_skbedit.c2
-rw-r--r--net/sched/act_skbmod.c2
-rw-r--r--net/sched/act_vlan.c2
-rw-r--r--net/sched/cls_api.c16
-rw-r--r--net/sched/cls_basic.c4
-rw-r--r--net/sched/cls_bpf.c4
-rw-r--r--net/sched/cls_cgroup.c2
-rw-r--r--net/sched/cls_flow.c4
-rw-r--r--net/sched/cls_flower.c14
-rw-r--r--net/sched/cls_fw.c6
-rw-r--r--net/sched/cls_matchall.c2
-rw-r--r--net/sched/cls_route.c6
-rw-r--r--net/sched/cls_u32.c17
-rw-r--r--net/sched/em_meta.c2
-rw-r--r--net/sched/em_text.c2
-rw-r--r--net/sched/sch_api.c6
-rw-r--r--net/sched/sch_cake.c4
-rw-r--r--net/sched/sch_choke.c2
-rw-r--r--net/sched/sch_drr.c2
-rw-r--r--net/sched/sch_fq_codel.c5
-rw-r--r--net/sched/sch_fq_pie.c3
-rw-r--r--net/sched/sch_gred.c6
-rw-r--r--net/sched/sch_hfsc.c2
-rw-r--r--net/sched/sch_hhf.c6
-rw-r--r--net/sched/sch_htb.c8
-rw-r--r--net/sched/sch_mq.c4
-rw-r--r--net/sched/sch_mqprio.c4
-rw-r--r--net/sched/sch_multiq.c2
-rw-r--r--net/sched/sch_netem.c2
-rw-r--r--net/sched/sch_qfq.c6
-rw-r--r--net/sched/sch_sfq.c2
-rw-r--r--net/sched/sch_taprio.c11
-rw-r--r--net/sctp/associola.c2
-rw-r--r--net/sctp/auth.c6
-rw-r--r--net/sctp/bind_addr.c2
-rw-r--r--net/sctp/chunk.c2
-rw-r--r--net/sctp/endpointola.c2
-rw-r--r--net/sctp/ipv6.c4
-rw-r--r--net/sctp/protocol.c6
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/sctp/stream.c2
-rw-r--r--net/sctp/stream_sched_prio.c2
-rw-r--r--net/sctp/transport.c2
-rw-r--r--net/shaper/shaper.c7
-rw-r--r--net/smc/af_smc.c8
-rw-r--r--net/smc/smc_clc.c4
-rw-r--r--net/smc/smc_core.c8
-rw-r--r--net/smc/smc_ib.c2
-rw-r--r--net/smc/smc_ism.c9
-rw-r--r--net/smc/smc_llc.c8
-rw-r--r--net/smc/smc_pnet.c6
-rw-r--r--net/smc/smc_rx.c8
-rw-r--r--net/smc/smc_stats.c4
-rw-r--r--net/smc/smc_wr.c44
-rw-r--r--net/sunrpc/auth.c4
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c17
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_mech.c2
-rw-r--r--net/sunrpc/auth_gss/gss_mech_switch.c2
-rw-r--r--net/sunrpc/auth_gss/gss_rpc_upcall.c2
-rw-r--r--net/sunrpc/auth_gss/gss_rpc_xdr.c4
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c10
-rw-r--r--net/sunrpc/auth_unix.c2
-rw-r--r--net/sunrpc/backchannel_rqst.c2
-rw-r--r--net/sunrpc/cache.c8
-rw-r--r--net/sunrpc/clnt.c4
-rw-r--r--net/sunrpc/rpc_pipe.c2
-rw-r--r--net/sunrpc/rpcb_clnt.c2
-rw-r--r--net/sunrpc/stats.c2
-rw-r--r--net/sunrpc/svc.c5
-rw-r--r--net/sunrpc/svcauth_unix.c6
-rw-r--r--net/sunrpc/svcsock.c5
-rw-r--r--net/sunrpc/sysfs.c10
-rw-r--r--net/sunrpc/xdr.c2
-rw-r--r--net/sunrpc/xprt.c4
-rw-r--r--net/sunrpc/xprtmultipath.c2
-rw-r--r--net/sunrpc/xprtrdma/ib_client.c2
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_pcl.c2
-rw-r--r--net/sunrpc/xprtrdma/verbs.c12
-rw-r--r--net/switchdev/switchdev.c2
-rw-r--r--net/tipc/bcast.c2
-rw-r--r--net/tipc/bearer.c2
-rw-r--r--net/tipc/crypto.c8
-rw-r--r--net/tipc/discover.c2
-rw-r--r--net/tipc/group.c4
-rw-r--r--net/tipc/link.c2
-rw-r--r--net/tipc/monitor.c8
-rw-r--r--net/tipc/name_table.c10
-rw-r--r--net/tipc/netlink_compat.c9
-rw-r--r--net/tipc/node.c4
-rw-r--r--net/tipc/socket.c2
-rw-r--r--net/tipc/subscr.c2
-rw-r--r--net/tipc/topsrv.c6
-rw-r--r--net/tipc/udp_media.c4
-rw-r--r--net/tls/tls_device.c8
-rw-r--r--net/tls/tls_device_fallback.c2
-rw-r--r--net/tls/tls_main.c2
-rw-r--r--net/tls/tls_sw.c4
-rw-r--r--net/unix/af_unix.c9
-rw-r--r--net/unix/garbage.c6
-rw-r--r--net/vmw_vsock/hyperv_transport.c4
-rw-r--r--net/vmw_vsock/virtio_transport.c2
-rw-r--r--net/vmw_vsock/virtio_transport_common.c2
-rw-r--r--net/vmw_vsock/vmci_transport.c6
-rw-r--r--net/wireless/core.c7
-rw-r--r--net/wireless/ibss.c2
-rw-r--r--net/wireless/nl80211.c76
-rw-r--r--net/wireless/of.c2
-rw-r--r--net/wireless/pmsr.c2
-rw-r--r--net/wireless/reg.c22
-rw-r--r--net/wireless/scan.c14
-rw-r--r--net/wireless/sme.c2
-rw-r--r--net/wireless/tests/util.c2
-rw-r--r--net/wireless/util.c9
-rw-r--r--net/wireless/wext-compat.c3
-rw-r--r--net/x25/x25_forward.c3
-rw-r--r--net/x25/x25_link.c2
-rw-r--r--net/x25/x25_route.c2
-rw-r--r--net/xdp/xdp_umem.c5
-rw-r--r--net/xdp/xsk_buff_pool.c16
-rw-r--r--net/xdp/xsk_queue.c2
-rw-r--r--net/xfrm/espintcp.c2
-rw-r--r--net/xfrm/xfrm_ipcomp.c2
-rw-r--r--net/xfrm/xfrm_iptfs.c11
-rw-r--r--net/xfrm/xfrm_policy.c6
490 files changed, 1156 insertions, 1231 deletions
diff --git a/net/802/garp.c b/net/802/garp.c
index 2d1ffc4d9462..ceeb5f5fac02 100644
--- a/net/802/garp.c
+++ b/net/802/garp.c
@@ -547,7 +547,7 @@ static int garp_init_port(struct net_device *dev)
{
struct garp_port *port;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return -ENOMEM;
rcu_assign_pointer(dev->garp_port, port);
@@ -581,7 +581,7 @@ int garp_init_applicant(struct net_device *dev, struct garp_application *appl)
}
err = -ENOMEM;
- app = kzalloc(sizeof(*app), GFP_KERNEL);
+ app = kzalloc_obj(*app, GFP_KERNEL);
if (!app)
goto err2;
diff --git a/net/802/mrp.c b/net/802/mrp.c
index 23a88305f900..f65c95d43a4e 100644
--- a/net/802/mrp.c
+++ b/net/802/mrp.c
@@ -832,7 +832,7 @@ static int mrp_init_port(struct net_device *dev)
{
struct mrp_port *port;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return -ENOMEM;
rcu_assign_pointer(dev->mrp_port, port);
@@ -866,7 +866,7 @@ int mrp_init_applicant(struct net_device *dev, struct mrp_application *appl)
}
err = -ENOMEM;
- app = kzalloc(sizeof(*app), GFP_KERNEL);
+ app = kzalloc_obj(*app, GFP_KERNEL);
if (!app)
goto err2;
diff --git a/net/802/psnap.c b/net/802/psnap.c
index 389df460c8c4..8ae835e1cbae 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -132,7 +132,7 @@ struct datalink_proto *register_snap_client(const unsigned char *desc,
if (find_snap_client(desc))
goto out;
- proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
+ proto = kmalloc_obj(*proto, GFP_ATOMIC);
if (proto) {
memcpy(proto->type, desc, 5);
proto->rcvfunc = rcvfunc;
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 9404dd551dfd..d7849667ddf0 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -150,7 +150,7 @@ static struct vlan_info *vlan_info_alloc(struct net_device *dev)
{
struct vlan_info *vlan_info;
- vlan_info = kzalloc(sizeof(struct vlan_info), GFP_KERNEL);
+ vlan_info = kzalloc_obj(struct vlan_info, GFP_KERNEL);
if (!vlan_info)
return NULL;
@@ -193,7 +193,7 @@ static struct vlan_vid_info *vlan_vid_info_alloc(__be16 proto, u16 vid)
{
struct vlan_vid_info *vid_info;
- vid_info = kzalloc(sizeof(struct vlan_vid_info), GFP_KERNEL);
+ vid_info = kzalloc_obj(struct vlan_vid_info, GFP_KERNEL);
if (!vid_info)
return NULL;
vid_info->proto = proto;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index fbf296137b09..176912c62915 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -192,7 +192,7 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
/* Create a new mapping then. */
mp = vlan->egress_priority_map[skb_prio & 0xF];
- np = kmalloc(sizeof(struct vlan_priority_tci_mapping), GFP_KERNEL);
+ np = kmalloc_obj(struct vlan_priority_tci_mapping, GFP_KERNEL);
if (!np)
return -ENOBUFS;
@@ -708,7 +708,7 @@ static int vlan_dev_netpoll_setup(struct net_device *dev)
struct netpoll *netpoll;
int err = 0;
- netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);
+ netpoll = kzalloc_obj(*netpoll, GFP_KERNEL);
err = -ENOMEM;
if (!netpoll)
goto out;
diff --git a/net/9p/client.c b/net/9p/client.c
index 1b475525ac5b..3e8de85c7f7f 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -730,7 +730,7 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
struct p9_fid *fid;
p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
- fid = kzalloc(sizeof(*fid), GFP_KERNEL);
+ fid = kzalloc_obj(*fid, GFP_KERNEL);
if (!fid)
return NULL;
@@ -859,7 +859,7 @@ struct p9_client *p9_client_create(struct fs_context *fc)
char *client_id;
char *cache_name;
- clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
+ clnt = kmalloc_obj(*clnt, GFP_KERNEL);
if (!clnt)
return ERR_PTR(-ENOMEM);
@@ -1615,7 +1615,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
p9_debug(P9_DEBUG_9P, ">>> TSTAT fid %d\n", fid->fid);
- ret = kmalloc(sizeof(*ret), GFP_KERNEL);
+ ret = kmalloc_obj(*ret, GFP_KERNEL);
if (!ret)
return ERR_PTR(-ENOMEM);
@@ -1667,7 +1667,7 @@ struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
p9_debug(P9_DEBUG_9P, ">>> TGETATTR fid %d, request_mask %lld\n",
fid->fid, request_mask);
- ret = kmalloc(sizeof(*ret), GFP_KERNEL);
+ ret = kmalloc_obj(*ret, GFP_KERNEL);
if (!ret)
return ERR_PTR(-ENOMEM);
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index 0e6603b1ec90..67b0586d807f 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -451,9 +451,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
p9pdu_readf(pdu, proto_version, "w", nwqid);
if (!errcode) {
*wqids =
- kmalloc_array(*nwqid,
- sizeof(struct p9_qid),
- GFP_NOFS);
+ kmalloc_objs(struct p9_qid, *nwqid,
+ GFP_NOFS);
if (*wqids == NULL)
errcode = -ENOMEM;
}
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 0e331c1b2112..4e0f4a382ac4 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -719,8 +719,7 @@ static int p9_fd_show_options(struct seq_file *m, struct p9_client *clnt)
static int p9_fd_open(struct p9_client *client, int rfd, int wfd)
{
- struct p9_trans_fd *ts = kzalloc(sizeof(struct p9_trans_fd),
- GFP_KERNEL);
+ struct p9_trans_fd *ts = kzalloc_obj(struct p9_trans_fd, GFP_KERNEL);
if (!ts)
return -ENOMEM;
@@ -764,7 +763,7 @@ static int p9_socket_open(struct p9_client *client, struct socket *csocket)
struct p9_trans_fd *p;
struct file *file;
- p = kzalloc(sizeof(struct p9_trans_fd), GFP_KERNEL);
+ p = kzalloc_obj(struct p9_trans_fd, GFP_KERNEL);
if (!p) {
sock_release(csocket);
return -ENOMEM;
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 4d406479f83b..c8e27c08a3a2 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -334,7 +334,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
}
/* Allocate an fcall for the reply */
- rpl_context = kmalloc(sizeof *rpl_context, GFP_NOFS);
+ rpl_context = kmalloc_obj(*rpl_context, GFP_NOFS);
if (!rpl_context) {
err = -ENOMEM;
goto recv_error;
@@ -363,7 +363,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
dont_need_post_recv:
/* Post the request */
- c = kmalloc(sizeof *c, GFP_NOFS);
+ c = kmalloc_obj(*c, GFP_NOFS);
if (!c) {
err = -ENOMEM;
goto send_error;
@@ -460,7 +460,7 @@ static struct p9_trans_rdma *alloc_rdma(struct p9_rdma_opts *opts)
{
struct p9_trans_rdma *rdma;
- rdma = kzalloc(sizeof(struct p9_trans_rdma), GFP_KERNEL);
+ rdma = kzalloc_obj(struct p9_trans_rdma, GFP_KERNEL);
if (!rdma)
return NULL;
diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c
index 93547637deae..e167f9f23d65 100644
--- a/net/9p/trans_usbg.c
+++ b/net/9p/trans_usbg.c
@@ -757,7 +757,7 @@ static struct usb_function *usb9pfs_alloc(struct usb_function_instance *fi)
struct f_usb9pfs_opts *usb9pfs_opts;
struct f_usb9pfs *usb9pfs;
- usb9pfs = kzalloc(sizeof(*usb9pfs), GFP_KERNEL);
+ usb9pfs = kzalloc_obj(*usb9pfs, GFP_KERNEL);
if (!usb9pfs)
return ERR_PTR(-ENOMEM);
@@ -910,7 +910,7 @@ static struct usb_function_instance *usb9pfs_alloc_instance(void)
struct f_usb9pfs_opts *usb9pfs_opts;
struct f_usb9pfs_dev *dev;
- usb9pfs_opts = kzalloc(sizeof(*usb9pfs_opts), GFP_KERNEL);
+ usb9pfs_opts = kzalloc_obj(*usb9pfs_opts, GFP_KERNEL);
if (!usb9pfs_opts)
return ERR_PTR(-ENOMEM);
@@ -921,7 +921,7 @@ static struct usb_function_instance *usb9pfs_alloc_instance(void)
usb9pfs_opts->buflen = DEFAULT_BUFLEN;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev) {
kfree(usb9pfs_opts);
return ERR_PTR(-ENOMEM);
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 370f4f37dcec..0577bdcb67bf 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -358,8 +358,7 @@ static int p9_get_mapped_pages(struct virtio_chan *chan,
nr_pages = DIV_ROUND_UP((unsigned long)p + len, PAGE_SIZE) -
(unsigned long)p / PAGE_SIZE;
- *pages = kmalloc_array(nr_pages, sizeof(struct page *),
- GFP_NOFS);
+ *pages = kmalloc_objs(struct page *, nr_pages, GFP_NOFS);
if (!*pages)
return -ENOMEM;
@@ -602,7 +601,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
return -EINVAL;
}
- chan = kmalloc(sizeof(struct virtio_chan), GFP_KERNEL);
+ chan = kmalloc_obj(struct virtio_chan, GFP_KERNEL);
if (!chan) {
pr_err("Failed to allocate virtio 9P channel\n");
err = -ENOMEM;
@@ -642,7 +641,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
if (err) {
goto out_free_tag;
}
- chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL);
+ chan->vc_wq = kmalloc_obj(wait_queue_head_t, GFP_KERNEL);
if (!chan->vc_wq) {
err = -ENOMEM;
goto out_remove_file;
diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index dde9cbf1426c..fd6ac8658549 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -417,12 +417,11 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)
if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order))
p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->dev = dev;
- priv->rings = kcalloc(XEN_9PFS_NUM_RINGS, sizeof(*priv->rings),
- GFP_KERNEL);
+ priv->rings = kzalloc_objs(*priv->rings, XEN_9PFS_NUM_RINGS, GFP_KERNEL);
if (!priv->rings) {
kfree(priv);
return -ENOMEM;
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 4744e3fd4544..e7315c01a299 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -393,7 +393,7 @@ static void aarp_purge(void)
*/
static struct aarp_entry *aarp_alloc(void)
{
- struct aarp_entry *a = kmalloc(sizeof(*a), GFP_ATOMIC);
+ struct aarp_entry *a = kmalloc_obj(*a, GFP_ATOMIC);
if (!a)
return NULL;
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 2a01fff46c9d..53c613e36245 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -233,7 +233,7 @@ static void atif_drop_device(struct net_device *dev)
static struct atalk_iface *atif_add_device(struct net_device *dev,
struct atalk_addr *sa)
{
- struct atalk_iface *iface = kzalloc(sizeof(*iface), GFP_KERNEL);
+ struct atalk_iface *iface = kzalloc_obj(*iface, GFP_KERNEL);
if (!iface)
goto out;
@@ -564,7 +564,7 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
}
if (!rt) {
- rt = kzalloc(sizeof(*rt), GFP_ATOMIC);
+ rt = kzalloc_obj(*rt, GFP_ATOMIC);
retval = -ENOBUFS;
if (!rt)
diff --git a/net/atm/addr.c b/net/atm/addr.c
index 0530b63f509a..938f360ae230 100644
--- a/net/atm/addr.c
+++ b/net/atm/addr.c
@@ -87,7 +87,7 @@ int atm_add_addr(struct atm_dev *dev, const struct sockaddr_atmsvc *addr,
return -EEXIST;
}
}
- this = kmalloc(sizeof(struct atm_dev_addr), GFP_ATOMIC);
+ this = kmalloc_obj(struct atm_dev_addr, GFP_ATOMIC);
if (!this) {
spin_unlock_irqrestore(&dev->lock, flags);
return -ENOMEM;
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index f666f2f98ba5..8fdc25271708 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -538,7 +538,7 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
if (copy_from_user(&be, arg, sizeof be))
return -EFAULT;
- brvcc = kzalloc(sizeof(struct br2684_vcc), GFP_KERNEL);
+ brvcc = kzalloc_obj(struct br2684_vcc, GFP_KERNEL);
if (!brvcc)
return -ENOMEM;
/*
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 8f152e5fa659..40553fcab389 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -431,7 +431,7 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout)
return -EBADFD;
if (vcc->user_back)
return -EINVAL;
- clip_vcc = kmalloc(sizeof(struct clip_vcc), GFP_KERNEL);
+ clip_vcc = kmalloc_obj(struct clip_vcc, GFP_KERNEL);
if (!clip_vcc)
return -ENOMEM;
pr_debug("%p vcc %p\n", clip_vcc, vcc);
diff --git a/net/atm/lec.c b/net/atm/lec.c
index afb8d3eb2185..cba26158c4ad 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -696,7 +696,7 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
ioc_data.dev_num = array_index_nospec(ioc_data.dev_num, MAX_LEC_ITF);
if (!dev_lec[ioc_data.dev_num])
return -EINVAL;
- vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
+ vpriv = kmalloc_obj(struct lec_vcc_priv, GFP_KERNEL);
if (!vpriv)
return -ENOMEM;
vpriv->xoff = 0;
@@ -1541,7 +1541,7 @@ static struct lec_arp_table *make_entry(struct lec_priv *priv,
{
struct lec_arp_table *to_return;
- to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC);
+ to_return = kzalloc_obj(struct lec_arp_table, GFP_ATOMIC);
if (!to_return)
return NULL;
ether_addr_copy(to_return->mac_addr, mac_addr);
@@ -2125,7 +2125,7 @@ static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
struct lec_vcc_priv *vpriv;
int err = 0;
- vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
+ vpriv = kmalloc_obj(struct lec_vcc_priv, GFP_KERNEL);
if (!vpriv)
return -ENOMEM;
vpriv->xoff = 0;
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index f6b447bba329..3e2b13734fc4 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -184,7 +184,7 @@ struct atm_mpoa_qos *atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos)
return entry;
}
- entry = kmalloc(sizeof(struct atm_mpoa_qos), GFP_KERNEL);
+ entry = kmalloc_obj(struct atm_mpoa_qos, GFP_KERNEL);
if (entry == NULL) {
pr_info("mpoa: out of memory\n");
return entry;
@@ -282,7 +282,7 @@ static struct mpoa_client *alloc_mpc(void)
{
struct mpoa_client *mpc;
- mpc = kzalloc(sizeof(struct mpoa_client), GFP_KERNEL);
+ mpc = kzalloc_obj(struct mpoa_client, GFP_KERNEL);
if (mpc == NULL)
return NULL;
rwlock_init(&mpc->ingress_lock);
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
index f7a2f0e41105..b584ab72ed2f 100644
--- a/net/atm/mpoa_caches.c
+++ b/net/atm/mpoa_caches.c
@@ -97,7 +97,7 @@ static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc,
static in_cache_entry *in_cache_add_entry(__be32 dst_ip,
struct mpoa_client *client)
{
- in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL);
+ in_cache_entry *entry = kzalloc_obj(in_cache_entry, GFP_KERNEL);
if (entry == NULL) {
pr_info("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n");
@@ -456,7 +456,7 @@ static void eg_cache_remove_entry(eg_cache_entry *entry,
static eg_cache_entry *eg_cache_add_entry(struct k_message *msg,
struct mpoa_client *client)
{
- eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL);
+ eg_cache_entry *entry = kzalloc_obj(eg_cache_entry, GFP_KERNEL);
if (entry == NULL) {
pr_info("out of memory\n");
diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c
index 3e4f17d335fe..133b0cda7063 100644
--- a/net/atm/pppoatm.c
+++ b/net/atm/pppoatm.c
@@ -397,7 +397,7 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, void __user *arg)
if (be.encaps != PPPOATM_ENCAPS_AUTODETECT &&
be.encaps != PPPOATM_ENCAPS_VC && be.encaps != PPPOATM_ENCAPS_LLC)
return -EINVAL;
- pvcc = kzalloc(sizeof(*pvcc), GFP_KERNEL);
+ pvcc = kzalloc_obj(*pvcc, GFP_KERNEL);
if (pvcc == NULL)
return -ENOMEM;
pvcc->atmvcc = atmvcc;
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 7c6fdedbcf4e..9849521feaf3 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -36,7 +36,7 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
{
struct atm_dev *dev;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev)
return NULL;
dev->type = type;
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 7ebbff2f0020..855ae9df824d 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -528,7 +528,7 @@ ax25_cb *ax25_create_cb(void)
{
ax25_cb *ax25;
- if ((ax25 = kzalloc(sizeof(*ax25), GFP_ATOMIC)) == NULL)
+ if ((ax25 = kzalloc_obj(*ax25, GFP_ATOMIC)) == NULL)
return NULL;
refcount_set(&ax25->refcount, 1);
@@ -1249,7 +1249,7 @@ static int __must_check ax25_connect(struct socket *sock,
goto out_release;
}
- if ((digi = kmalloc(sizeof(ax25_digi), GFP_KERNEL)) == NULL) {
+ if ((digi = kmalloc_obj(ax25_digi, GFP_KERNEL)) == NULL) {
err = -ENOBUFS;
goto out_release;
}
diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
index c504ed9c3a88..56f605ddd88d 100644
--- a/net/ax25/ax25_dev.c
+++ b/net/ax25/ax25_dev.c
@@ -54,7 +54,7 @@ void ax25_dev_device_up(struct net_device *dev)
{
ax25_dev *ax25_dev;
- ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_KERNEL);
+ ax25_dev = kzalloc_obj(*ax25_dev, GFP_KERNEL);
if (!ax25_dev) {
printk(KERN_ERR "AX.25: ax25_dev_device_up - out of memory\n");
return;
diff --git a/net/ax25/ax25_iface.c b/net/ax25/ax25_iface.c
index 979bc4b828a0..3ad454416a5c 100644
--- a/net/ax25/ax25_iface.c
+++ b/net/ax25/ax25_iface.c
@@ -105,7 +105,7 @@ int ax25_listen_register(const ax25_address *callsign, struct net_device *dev)
if (ax25_listen_mine(callsign, dev))
return 0;
- if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL)
+ if ((listen = kmalloc_obj(*listen, GFP_ATOMIC)) == NULL)
return -ENOMEM;
listen->callsign = *callsign;
diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c
index f2d66af86359..d75b3e9ed93d 100644
--- a/net/ax25/ax25_in.c
+++ b/net/ax25/ax25_in.c
@@ -377,7 +377,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
* Sort out any digipeated paths.
*/
if (dp.ndigi && !ax25->digipeat &&
- (ax25->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
+ (ax25->digipeat = kmalloc_obj(ax25_digi, GFP_ATOMIC)) == NULL) {
kfree_skb(skb);
ax25_destroy_socket(ax25);
if (sk)
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index 10577434f40b..1d5c59ccf142 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -91,7 +91,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
kfree(ax25_rt->digipeat);
ax25_rt->digipeat = NULL;
if (route->digi_count != 0) {
- if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
+ if ((ax25_rt->digipeat = kmalloc_obj(ax25_digi, GFP_ATOMIC)) == NULL) {
write_unlock_bh(&ax25_route_lock);
ax25_dev_put(ax25_dev);
return -ENOMEM;
@@ -110,7 +110,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
ax25_rt = ax25_rt->next;
}
- if ((ax25_rt = kmalloc(sizeof(ax25_route), GFP_ATOMIC)) == NULL) {
+ if ((ax25_rt = kmalloc_obj(ax25_route, GFP_ATOMIC)) == NULL) {
write_unlock_bh(&ax25_route_lock);
ax25_dev_put(ax25_dev);
return -ENOMEM;
@@ -121,7 +121,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
ax25_rt->digipeat = NULL;
ax25_rt->ip_mode = ' ';
if (route->digi_count != 0) {
- if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
+ if ((ax25_rt->digipeat = kmalloc_obj(ax25_digi, GFP_ATOMIC)) == NULL) {
write_unlock_bh(&ax25_route_lock);
kfree(ax25_rt);
ax25_dev_put(ax25_dev);
diff --git a/net/ax25/ax25_uid.c b/net/ax25/ax25_uid.c
index 241e4680ecb1..95c5915f1ab9 100644
--- a/net/ax25/ax25_uid.c
+++ b/net/ax25/ax25_uid.c
@@ -101,7 +101,7 @@ int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
}
if (sax->sax25_uid == 0)
return -EINVAL;
- if ((ax25_uid = kmalloc(sizeof(*ax25_uid), GFP_KERNEL)) == NULL)
+ if ((ax25_uid = kmalloc_obj(*ax25_uid, GFP_KERNEL)) == NULL)
return -ENOMEM;
refcount_set(&ax25_uid->refcount, 1);
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index cb16c1ed2a58..2ce4e5bf9292 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -355,7 +355,7 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
* context. Therefore add it to metric_queue and process it
* outside rcu protected context.
*/
- metric_entry = kzalloc(sizeof(*metric_entry), GFP_ATOMIC);
+ metric_entry = kzalloc_obj(*metric_entry, GFP_ATOMIC);
if (!metric_entry) {
batadv_hardif_neigh_put(hardif_neigh);
continue;
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 3dc791c15bf7..49ae92b9a152 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -505,7 +505,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, const u8 *orig,
"%s(): not found (%pM, %d), creating new entry\n", __func__,
orig, batadv_print_vid(vid));
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
return NULL;
@@ -699,7 +699,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
/* create a new claim entry if it does not exist yet. */
if (!claim) {
- claim = kzalloc(sizeof(*claim), GFP_ATOMIC);
+ claim = kzalloc_obj(*claim, GFP_ATOMIC);
if (!claim)
return;
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 8b8132eb0a79..3efc4cf50b46 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -381,7 +381,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
goto out;
}
- dat_entry = kmalloc(sizeof(*dat_entry), GFP_ATOMIC);
+ dat_entry = kmalloc_obj(*dat_entry, GFP_ATOMIC);
if (!dat_entry)
goto out;
@@ -635,8 +635,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
if (!bat_priv->orig_hash)
return NULL;
- res = kmalloc_array(BATADV_DAT_CANDIDATES_NUM, sizeof(*res),
- GFP_ATOMIC);
+ res = kmalloc_objs(*res, BATADV_DAT_CANDIDATES_NUM, GFP_ATOMIC);
if (!res)
return NULL;
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index cc14bc41381e..f4e45cc25816 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -156,7 +156,7 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
seqno = ntohs(frag_packet->seqno);
bucket = seqno % BATADV_FRAG_BUFFER_COUNT;
- frag_entry_new = kmalloc(sizeof(*frag_entry_new), GFP_ATOMIC);
+ frag_entry_new = kmalloc_obj(*frag_entry_new, GFP_ATOMIC);
if (!frag_entry_new)
goto err;
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 7a11b245e9f4..51e9c081a2a4 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -332,7 +332,7 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
if (gateway->bandwidth_down == 0)
return;
- gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC);
+ gw_node = kzalloc_obj(*gw_node, GFP_ATOMIC);
if (!gw_node)
return;
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 5113f879736b..7b7640f3ffe2 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -871,7 +871,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
if (!batadv_is_valid_iface(net_dev))
return NULL;
- hard_iface = kzalloc(sizeof(*hard_iface), GFP_ATOMIC);
+ hard_iface = kzalloc_obj(*hard_iface, GFP_ATOMIC);
if (!hard_iface)
return NULL;
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index 8016e619787f..759fa29176db 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -45,16 +45,15 @@ struct batadv_hashtable *batadv_hash_new(u32 size)
{
struct batadv_hashtable *hash;
- hash = kmalloc(sizeof(*hash), GFP_ATOMIC);
+ hash = kmalloc_obj(*hash, GFP_ATOMIC);
if (!hash)
return NULL;
- hash->table = kmalloc_array(size, sizeof(*hash->table), GFP_ATOMIC);
+ hash->table = kmalloc_objs(*hash->table, size, GFP_ATOMIC);
if (!hash->table)
goto free_hash;
- hash->list_locks = kmalloc_array(size, sizeof(*hash->list_locks),
- GFP_ATOMIC);
+ hash->list_locks = kmalloc_objs(*hash->list_locks, size, GFP_ATOMIC);
if (!hash->list_locks)
goto free_table;
diff --git a/net/batman-adv/mesh-interface.c b/net/batman-adv/mesh-interface.c
index df7e95811ef5..56ca1c1b83f2 100644
--- a/net/batman-adv/mesh-interface.c
+++ b/net/batman-adv/mesh-interface.c
@@ -555,7 +555,7 @@ int batadv_meshif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
return -EEXIST;
}
- vlan = kzalloc(sizeof(*vlan), GFP_ATOMIC);
+ vlan = kzalloc_obj(*vlan, GFP_ATOMIC);
if (!vlan) {
spin_unlock_bh(&bat_priv->meshif_vlan_list_lock);
return -ENOMEM;
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index e8c6b0bf670f..a3d3efe22d30 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -399,7 +399,7 @@ batadv_mcast_mla_meshif_get_ipv4(struct net_device *dev,
if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_list))
continue;
- new = kmalloc(sizeof(*new), GFP_ATOMIC);
+ new = kmalloc_obj(*new, GFP_ATOMIC);
if (!new) {
ret = -ENOMEM;
break;
@@ -472,7 +472,7 @@ batadv_mcast_mla_meshif_get_ipv6(struct net_device *dev,
if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_list))
continue;
- new = kmalloc(sizeof(*new), GFP_ATOMIC);
+ new = kmalloc_obj(*new, GFP_ATOMIC);
if (!new) {
ret = -ENOMEM;
break;
@@ -632,7 +632,7 @@ static int batadv_mcast_mla_bridge_get(struct net_device *dev,
if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_list))
continue;
- new = kmalloc(sizeof(*new), GFP_ATOMIC);
+ new = kmalloc_obj(*new, GFP_ATOMIC);
if (!new) {
ret = -ENOMEM;
break;
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index a662408ad867..b3468ccab535 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -179,7 +179,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
if (vlan)
goto out;
- vlan = kzalloc(sizeof(*vlan), GFP_ATOMIC);
+ vlan = kzalloc_obj(*vlan, GFP_ATOMIC);
if (!vlan)
goto out;
@@ -417,7 +417,7 @@ batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
if (orig_ifinfo)
goto out;
- orig_ifinfo = kzalloc(sizeof(*orig_ifinfo), GFP_ATOMIC);
+ orig_ifinfo = kzalloc_obj(*orig_ifinfo, GFP_ATOMIC);
if (!orig_ifinfo)
goto out;
@@ -495,7 +495,7 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
if (neigh_ifinfo)
goto out;
- neigh_ifinfo = kzalloc(sizeof(*neigh_ifinfo), GFP_ATOMIC);
+ neigh_ifinfo = kzalloc_obj(*neigh_ifinfo, GFP_ATOMIC);
if (!neigh_ifinfo)
goto out;
@@ -575,7 +575,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
if (hardif_neigh)
goto out;
- hardif_neigh = kzalloc(sizeof(*hardif_neigh), GFP_ATOMIC);
+ hardif_neigh = kzalloc_obj(*hardif_neigh, GFP_ATOMIC);
if (!hardif_neigh)
goto out;
@@ -683,7 +683,7 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node,
if (!hardif_neigh)
goto out;
- neigh_node = kzalloc(sizeof(*neigh_node), GFP_ATOMIC);
+ neigh_node = kzalloc_obj(*neigh_node, GFP_ATOMIC);
if (!neigh_node)
goto out;
@@ -947,7 +947,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Creating new originator: %pM\n", addr);
- orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC);
+ orig_node = kzalloc_obj(*orig_node, GFP_ATOMIC);
if (!orig_node)
return NULL;
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 20d85c681064..60cd67ec9cea 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -503,7 +503,7 @@ batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
return NULL;
}
- forw_packet = kmalloc(sizeof(*forw_packet), GFP_ATOMIC);
+ forw_packet = kmalloc_obj(*forw_packet, GFP_ATOMIC);
if (!forw_packet)
goto err;
diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index 350b149e48be..2e42f6b348c8 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -967,7 +967,7 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
return;
}
- tp_vars = kmalloc(sizeof(*tp_vars), GFP_ATOMIC);
+ tp_vars = kmalloc_obj(*tp_vars, GFP_ATOMIC);
if (!tp_vars) {
spin_unlock_bh(&bat_priv->tp_list_lock);
batadv_dbg(BATADV_DBG_TP_METER, bat_priv,
@@ -1228,7 +1228,7 @@ static bool batadv_tp_handle_out_of_order(struct batadv_tp_vars *tp_vars,
u32 payload_len;
bool added = false;
- new = kmalloc(sizeof(*new), GFP_ATOMIC);
+ new = kmalloc_obj(*new, GFP_ATOMIC);
if (unlikely(!new))
return false;
@@ -1343,7 +1343,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
goto out_unlock;
}
- tp_vars = kmalloc(sizeof(*tp_vars), GFP_ATOMIC);
+ tp_vars = kmalloc_obj(*tp_vars, GFP_ATOMIC);
if (!tp_vars)
goto out_unlock;
diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c
index 76dff1f9c559..8129a3f9c44d 100644
--- a/net/batman-adv/tvlv.c
+++ b/net/batman-adv/tvlv.c
@@ -557,7 +557,7 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
return;
}
- tvlv_handler = kzalloc(sizeof(*tvlv_handler), GFP_ATOMIC);
+ tvlv_handler = kzalloc_obj(*tvlv_handler, GFP_ATOMIC);
if (!tvlv_handler) {
spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
return;
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 2c21ae8abadc..acaf7c9e4a69 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -645,7 +645,7 @@ static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan,
{
struct lowpan_peer *peer;
- peer = kzalloc(sizeof(*peer), GFP_ATOMIC);
+ peer = kzalloc_obj(*peer, GFP_ATOMIC);
if (!peer)
return NULL;
@@ -1107,7 +1107,7 @@ static int lowpan_enable_set(void *data, u64 val)
{
struct set_enable *set_enable;
- set_enable = kzalloc(sizeof(*set_enable), GFP_KERNEL);
+ set_enable = kzalloc_obj(*set_enable, GFP_KERNEL);
if (!set_enable)
return -ENOMEM;
@@ -1245,7 +1245,7 @@ static void disconnect_devices(void)
rcu_read_lock();
list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
- new_dev = kmalloc(sizeof(*new_dev), GFP_ATOMIC);
+ new_dev = kmalloc_obj(*new_dev, GFP_ATOMIC);
if (!new_dev)
break;
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 884703fda979..df4edd43176e 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -72,7 +72,7 @@
static struct cmtp_application *cmtp_application_add(struct cmtp_session *session, __u16 appl)
{
- struct cmtp_application *app = kzalloc(sizeof(*app), GFP_KERNEL);
+ struct cmtp_application *app = kzalloc_obj(*app, GFP_KERNEL);
BT_DBG("session %p application %p appl %u", session, app, appl);
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 90d130588a3e..ebfa049598dc 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -341,7 +341,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
if (req->flags & ~valid_flags)
return -EINVAL;
- session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL);
+ session = kzalloc_obj(struct cmtp_session, GFP_KERNEL);
if (!session)
return -ENOMEM;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0795818963a5..02d33fe11042 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -462,7 +462,7 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle)
struct conn_handle_t *conn_handle;
if (enhanced_sync_conn_capable(conn->hdev)) {
- conn_handle = kzalloc(sizeof(*conn_handle), GFP_KERNEL);
+ conn_handle = kzalloc_obj(*conn_handle, GFP_KERNEL);
if (!conn_handle)
return false;
@@ -726,7 +726,7 @@ static int hci_le_terminate_big(struct hci_dev *hdev, struct hci_conn *conn)
bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", conn->iso_qos.bcast.big,
conn->iso_qos.bcast.bis);
- d = kzalloc(sizeof(*d), GFP_KERNEL);
+ d = kzalloc_obj(*d, GFP_KERNEL);
if (!d)
return -ENOMEM;
@@ -777,7 +777,7 @@ static int hci_le_big_terminate(struct hci_dev *hdev, struct hci_conn *conn)
bt_dev_dbg(hdev, "hcon %p big 0x%2.2x sync_handle 0x%4.4x", conn,
conn->iso_qos.bcast.big, conn->sync_handle);
- d = kzalloc(sizeof(*d), GFP_KERNEL);
+ d = kzalloc_obj(*d, GFP_KERNEL);
if (!d)
return -ENOMEM;
@@ -960,7 +960,7 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type,
bt_dev_dbg(hdev, "dst %pMR handle 0x%4.4x", dst, handle);
- conn = kzalloc(sizeof(*conn), GFP_KERNEL);
+ conn = kzalloc_obj(*conn, GFP_KERNEL);
if (!conn)
return ERR_PTR(-ENOMEM);
@@ -1739,7 +1739,7 @@ static struct hci_link *hci_conn_link(struct hci_conn *parent,
if (conn->parent)
return NULL;
- link = kzalloc(sizeof(*link), GFP_KERNEL);
+ link = kzalloc_obj(*link, GFP_KERNEL);
if (!link)
return NULL;
@@ -2781,7 +2781,7 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn)
return NULL;
}
- chan = kzalloc(sizeof(*chan), GFP_KERNEL);
+ chan = kzalloc_obj(*chan, GFP_KERNEL);
if (!chan)
return NULL;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b069607b145b..a0cad792be0b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -262,7 +262,7 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
}
/* Entry not in the cache. Add new one. */
- ie = kzalloc(sizeof(*ie), GFP_KERNEL);
+ ie = kzalloc_obj(*ie, GFP_KERNEL);
if (!ie) {
flags |= MGMT_DEV_FOUND_CONFIRM_NAME;
goto done;
@@ -797,7 +797,7 @@ int hci_get_dev_list(void __user *arg)
if (!dev_num || dev_num > (PAGE_SIZE * 2) / sizeof(*dr))
return -EINVAL;
- dl = kzalloc(struct_size(dl, dev_req, dev_num), GFP_KERNEL);
+ dl = kzalloc_flex(*dl, dev_req, dev_num, GFP_KERNEL);
if (!dl)
return -ENOMEM;
@@ -1286,7 +1286,7 @@ struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
key = old_key;
} else {
old_key_type = conn ? conn->key_type : 0xff;
- key = kzalloc(sizeof(*key), GFP_KERNEL);
+ key = kzalloc_obj(*key, GFP_KERNEL);
if (!key)
return NULL;
list_add_rcu(&key->list, &hdev->link_keys);
@@ -1331,7 +1331,7 @@ struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
if (old_key)
key = old_key;
else {
- key = kzalloc(sizeof(*key), GFP_KERNEL);
+ key = kzalloc_obj(*key, GFP_KERNEL);
if (!key)
return NULL;
list_add_rcu(&key->list, &hdev->long_term_keys);
@@ -1356,7 +1356,7 @@ struct smp_irk *hci_add_irk(struct hci_dev *hdev, bdaddr_t *bdaddr,
irk = hci_find_irk_by_addr(hdev, bdaddr, addr_type);
if (!irk) {
- irk = kzalloc(sizeof(*irk), GFP_KERNEL);
+ irk = kzalloc_obj(*irk, GFP_KERNEL);
if (!irk)
return NULL;
@@ -1550,7 +1550,7 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
data = hci_find_remote_oob_data(hdev, bdaddr, bdaddr_type);
if (!data) {
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -1718,7 +1718,7 @@ struct adv_info *hci_add_adv_instance(struct hci_dev *hdev, u8 instance,
instance < 1 || instance > hdev->le_num_of_adv_sets + 1)
return ERR_PTR(-EOVERFLOW);
- adv = kzalloc(sizeof(*adv), GFP_KERNEL);
+ adv = kzalloc_obj(*adv, GFP_KERNEL);
if (!adv)
return ERR_PTR(-ENOMEM);
@@ -2107,7 +2107,7 @@ int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type)
if (hci_bdaddr_list_lookup(list, bdaddr, type))
return -EEXIST;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
@@ -2130,7 +2130,7 @@ int hci_bdaddr_list_add_with_irk(struct list_head *list, bdaddr_t *bdaddr,
if (hci_bdaddr_list_lookup(list, bdaddr, type))
return -EEXIST;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
@@ -2159,7 +2159,7 @@ int hci_bdaddr_list_add_with_flags(struct list_head *list, bdaddr_t *bdaddr,
if (hci_bdaddr_list_lookup(list, bdaddr, type))
return -EEXIST;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
@@ -2276,7 +2276,7 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev,
if (params)
return params;
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ params = kzalloc_obj(*params, GFP_KERNEL);
if (!params) {
bt_dev_err(hdev, "out of memory");
return NULL;
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index f04a90bce4a9..ed5db3eb3df3 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -711,7 +711,7 @@ int hci_cmd_sync_submit(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
goto unlock;
}
- entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kmalloc_obj(*entry, GFP_KERNEL);
if (!entry) {
err = -ENOMEM;
goto unlock;
@@ -2685,7 +2685,7 @@ static struct conn_params *conn_params_copy(struct list_head *list, size_t *n)
rcu_read_unlock();
- p = kvcalloc(*n, sizeof(struct conn_params), GFP_KERNEL);
+ p = kvzalloc_objs(struct conn_params, *n, GFP_KERNEL);
if (!p)
return NULL;
@@ -7341,7 +7341,7 @@ int hci_past_sync(struct hci_conn *conn, struct hci_conn *le)
if (!past_sender_capable(conn->hdev))
return -EOPNOTSUPP;
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -7473,7 +7473,7 @@ int hci_acl_change_pkt_type(struct hci_conn *conn, u16 pkt_type)
struct hci_dev *hdev = conn->hdev;
struct hci_cp_change_conn_ptype *cp;
- cp = kmalloc(sizeof(*cp), GFP_KERNEL);
+ cp = kmalloc_obj(*cp, GFP_KERNEL);
if (!cp)
return -ENOMEM;
@@ -7508,7 +7508,7 @@ int hci_le_set_phy(struct hci_conn *conn, u8 tx_phys, u8 rx_phys)
struct hci_dev *hdev = conn->hdev;
struct hci_cp_le_set_phy *cp;
- cp = kmalloc(sizeof(*cp), GFP_KERNEL);
+ cp = kmalloc_obj(*cp, GFP_KERNEL);
if (!cp)
return -ENOMEM;
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 6724adce615b..a91d5452f24a 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -920,7 +920,7 @@ static int hidp_session_new(struct hidp_session **out, const bdaddr_t *bdaddr,
ctrl = bt_sk(ctrl_sock->sk);
intr = bt_sk(intr_sock->sk);
- session = kzalloc(sizeof(*session), GFP_KERNEL);
+ session = kzalloc_obj(*session, GFP_KERNEL);
if (!session)
return -ENOMEM;
diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index 1459ab161fd2..693271af6c22 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -212,7 +212,7 @@ static struct iso_conn *iso_conn_add(struct hci_conn *hcon)
return conn;
}
- conn = kzalloc(sizeof(*conn), GFP_KERNEL);
+ conn = kzalloc_obj(*conn, GFP_KERNEL);
if (!conn)
return NULL;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b628b0fa39b2..4804377781b6 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -442,7 +442,7 @@ struct l2cap_chan *l2cap_chan_create(void)
{
struct l2cap_chan *chan;
- chan = kzalloc(sizeof(*chan), GFP_ATOMIC);
+ chan = kzalloc_obj(*chan, GFP_ATOMIC);
if (!chan)
return NULL;
@@ -6902,7 +6902,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon)
if (!hchan)
return NULL;
- conn = kzalloc(sizeof(*conn), GFP_KERNEL);
+ conn = kzalloc_obj(*conn, GFP_KERNEL);
if (!conn) {
hci_chan_del(hchan);
return NULL;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 3ba3ce7eaa98..66ab920d8f50 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1564,8 +1564,8 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
(chan->mode == L2CAP_MODE_ERTM ||
chan->mode == L2CAP_MODE_LE_FLOWCTL ||
chan->mode == L2CAP_MODE_EXT_FLOWCTL)) {
- struct l2cap_rx_busy *rx_busy =
- kmalloc(sizeof(*rx_busy), GFP_KERNEL);
+ struct l2cap_rx_busy *rx_busy = kmalloc_obj(*rx_busy,
+ GFP_KERNEL);
if (!rx_busy) {
err = -ENOMEM;
goto done;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 0e46f9e08b10..c9725ca3356c 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -560,7 +560,7 @@ static int read_ext_index_list(struct sock *sk, struct hci_dev *hdev,
list_for_each_entry(d, &hci_dev_list, list)
count++;
- rp = kmalloc(struct_size(rp, entry, count), GFP_ATOMIC);
+ rp = kmalloc_flex(*rp, entry, count, GFP_ATOMIC);
if (!rp) {
read_unlock(&hci_dev_list_lock);
return -ENOMEM;
@@ -2767,7 +2767,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
goto failed;
}
- uuid = kmalloc(sizeof(*uuid), GFP_KERNEL);
+ uuid = kmalloc_obj(*uuid, GFP_KERNEL);
if (!uuid) {
err = -ENOMEM;
goto failed;
@@ -3360,7 +3360,7 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data,
i++;
}
- rp = kmalloc(struct_size(rp, addr, i), GFP_KERNEL);
+ rp = kmalloc_flex(*rp, addr, i, GFP_KERNEL);
if (!rp) {
err = -ENOMEM;
goto unlock;
@@ -4377,7 +4377,7 @@ static int set_blocked_keys(struct sock *sk, struct hci_dev *hdev, void *data,
hci_blocked_keys_clear(hdev);
for (i = 0; i < key_count; ++i) {
- struct blocked_key *b = kzalloc(sizeof(*b), GFP_KERNEL);
+ struct blocked_key *b = kzalloc_obj(*b, GFP_KERNEL);
if (!b) {
err = MGMT_STATUS_NO_RESOURCES;
@@ -5490,7 +5490,7 @@ static u8 parse_adv_monitor_pattern(struct adv_monitor *m, u8 pattern_count,
(offset + length) > HCI_MAX_AD_LENGTH)
return MGMT_STATUS_INVALID_PARAMS;
- p = kmalloc(sizeof(*p), GFP_KERNEL);
+ p = kmalloc_obj(*p, GFP_KERNEL);
if (!p)
return MGMT_STATUS_NO_RESOURCES;
@@ -5527,7 +5527,7 @@ static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,
goto done;
}
- m = kzalloc(sizeof(*m), GFP_KERNEL);
+ m = kzalloc_obj(*m, GFP_KERNEL);
if (!m) {
status = MGMT_STATUS_NO_RESOURCES;
goto done;
@@ -5564,7 +5564,7 @@ static int add_adv_patterns_monitor_rssi(struct sock *sk, struct hci_dev *hdev,
goto done;
}
- m = kzalloc(sizeof(*m), GFP_KERNEL);
+ m = kzalloc_obj(*m, GFP_KERNEL);
if (!m) {
status = MGMT_STATUS_NO_RESOURCES;
goto done;
diff --git a/net/bluetooth/mgmt_util.c b/net/bluetooth/mgmt_util.c
index aa7b5585cb26..4ed16ca8771d 100644
--- a/net/bluetooth/mgmt_util.c
+++ b/net/bluetooth/mgmt_util.c
@@ -266,7 +266,7 @@ struct mgmt_pending_cmd *mgmt_pending_new(struct sock *sk, u16 opcode,
{
struct mgmt_pending_cmd *cmd;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+ cmd = kzalloc_obj(*cmd, GFP_KERNEL);
if (!cmd)
return NULL;
@@ -413,7 +413,7 @@ struct mgmt_mesh_tx *mgmt_mesh_add(struct sock *sk, struct hci_dev *hdev,
{
struct mgmt_mesh_tx *mesh_tx;
- mesh_tx = kzalloc(sizeof(*mesh_tx), GFP_KERNEL);
+ mesh_tx = kzalloc_obj(*mesh_tx, GFP_KERNEL);
if (!mesh_tx)
return NULL;
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index c560d8467669..25cde1ea5d23 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -276,7 +276,7 @@ static int msft_le_monitor_advertisement_cb(struct hci_dev *hdev, u16 opcode,
if (status)
goto unlock;
- handle_data = kmalloc(sizeof(*handle_data), GFP_KERNEL);
+ handle_data = kmalloc_obj(*handle_data, GFP_KERNEL);
if (!handle_data) {
status = HCI_ERROR_UNSPECIFIED;
goto unlock;
@@ -756,7 +756,7 @@ void msft_register(struct hci_dev *hdev)
bt_dev_dbg(hdev, "Register MSFT extension");
- msft = kzalloc(sizeof(*msft), GFP_KERNEL);
+ msft = kzalloc_obj(*msft, GFP_KERNEL);
if (!msft) {
bt_dev_err(hdev, "Failed to register MSFT extension");
return;
@@ -790,7 +790,7 @@ static void msft_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr,
{
struct monitored_device *dev;
- dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kmalloc_obj(*dev, GFP_KERNEL);
if (!dev) {
bt_dev_err(hdev, "MSFT vendor event %u: no memory",
MSFT_EV_LE_MONITOR_DEVICE);
@@ -932,7 +932,7 @@ static struct msft_monitor_addr_filter_data *msft_add_address_filter
struct msft_data *msft = hdev->msft_data;
int err;
- address_filter = kzalloc(sizeof(*address_filter), GFP_KERNEL);
+ address_filter = kzalloc_obj(*address_filter, GFP_KERNEL);
if (!address_filter)
return NULL;
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 57b1dca8141f..d7718844c520 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -302,7 +302,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d)
struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
{
- struct rfcomm_dlc *d = kzalloc(sizeof(*d), prio);
+ struct rfcomm_dlc *d = kzalloc_obj(*d, prio);
if (!d)
return NULL;
@@ -680,7 +680,7 @@ int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig)
/* ---- RFCOMM sessions ---- */
static struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state)
{
- struct rfcomm_session *s = kzalloc(sizeof(*s), GFP_KERNEL);
+ struct rfcomm_session *s = kzalloc_obj(*s, GFP_KERNEL);
if (!s)
return NULL;
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index b783526ab588..4d8ab1a49e92 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -221,7 +221,7 @@ static struct rfcomm_dev *__rfcomm_dev_add(struct rfcomm_dev_req *req,
struct list_head *head = &rfcomm_dev_list;
int err = 0;
- dev = kzalloc(sizeof(struct rfcomm_dev), GFP_KERNEL);
+ dev = kzalloc_obj(struct rfcomm_dev, GFP_KERNEL);
if (!dev)
return ERR_PTR(-ENOMEM);
@@ -510,7 +510,7 @@ static int rfcomm_get_dev_list(void __user *arg)
if (!dev_num || dev_num > (PAGE_SIZE * 4) / sizeof(*di))
return -EINVAL;
- dl = kzalloc(struct_size(dl, dev_info, dev_num), GFP_KERNEL);
+ dl = kzalloc_flex(*dl, dev_info, dev_num, GFP_KERNEL);
if (!dl)
return -ENOMEM;
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 87ba90336e80..26c5c5fe7c5a 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -204,7 +204,7 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon)
return conn;
}
- conn = kzalloc(sizeof(struct sco_conn), GFP_KERNEL);
+ conn = kzalloc_obj(struct sco_conn, GFP_KERNEL);
if (!conn)
return NULL;
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index bf61e8841535..e0e66dc95007 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1344,7 +1344,7 @@ static void smp_distribute_keys(struct smp_chan *smp)
/* Generate a new random key */
get_random_bytes(sign.csrk, sizeof(sign.csrk));
- csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
+ csrk = kzalloc_obj(*csrk, GFP_KERNEL);
if (csrk) {
if (hcon->sec_level > BT_SECURITY_MEDIUM)
csrk->type = MGMT_CSRK_LOCAL_AUTHENTICATED;
@@ -1388,7 +1388,7 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn)
struct l2cap_chan *chan = conn->smp;
struct smp_chan *smp;
- smp = kzalloc(sizeof(*smp), GFP_ATOMIC);
+ smp = kzalloc_obj(*smp, GFP_ATOMIC);
if (!smp)
return NULL;
@@ -2664,7 +2664,7 @@ static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb)
skb_pull(skb, sizeof(*rp));
- csrk = kzalloc(sizeof(*csrk), GFP_KERNEL);
+ csrk = kzalloc_obj(*csrk, GFP_KERNEL);
if (csrk) {
if (conn->hcon->sec_level > BT_SECURITY_MEDIUM)
csrk->type = MGMT_CSRK_REMOTE_AUTHENTICATED;
@@ -3293,7 +3293,7 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)
goto create_chan;
}
- smp = kzalloc(sizeof(*smp), GFP_KERNEL);
+ smp = kzalloc_obj(*smp, GFP_KERNEL);
if (!smp)
return ERR_PTR(-ENOMEM);
diff --git a/net/bpf/bpf_dummy_struct_ops.c b/net/bpf/bpf_dummy_struct_ops.c
index 812457819b5a..52117422e0f2 100644
--- a/net/bpf/bpf_dummy_struct_ops.c
+++ b/net/bpf/bpf_dummy_struct_ops.c
@@ -36,7 +36,7 @@ dummy_ops_init_args(const union bpf_attr *kattr, unsigned int nr)
if (size_in != sizeof(u64) * nr)
return ERR_PTR(-EINVAL);
- args = kzalloc(sizeof(*args), GFP_KERNEL);
+ args = kzalloc_obj(*args, GFP_KERNEL);
if (!args)
return ERR_PTR(-ENOMEM);
@@ -158,13 +158,13 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr,
if (err)
goto out;
- tlinks = kcalloc(BPF_TRAMP_MAX, sizeof(*tlinks), GFP_KERNEL);
+ tlinks = kzalloc_objs(*tlinks, BPF_TRAMP_MAX, GFP_KERNEL);
if (!tlinks) {
err = -ENOMEM;
goto out;
}
- link = kzalloc(sizeof(*link), GFP_USER);
+ link = kzalloc_obj(*link, GFP_USER);
if (!link) {
err = -ENOMEM;
goto out;
diff --git a/net/bridge/br_cfm.c b/net/bridge/br_cfm.c
index c2c1c7d44c61..a2276ce350fa 100644
--- a/net/bridge/br_cfm.c
+++ b/net/bridge/br_cfm.c
@@ -547,7 +547,7 @@ int br_cfm_mep_create(struct net_bridge *br,
}
}
- mep = kzalloc(sizeof(*mep), GFP_KERNEL);
+ mep = kzalloc_obj(*mep, GFP_KERNEL);
if (!mep)
return -ENOMEM;
@@ -693,7 +693,7 @@ int br_cfm_cc_peer_mep_add(struct net_bridge *br, const u32 instance,
return -EEXIST;
}
- peer_mep = kzalloc(sizeof(*peer_mep), GFP_KERNEL);
+ peer_mep = kzalloc_obj(*peer_mep, GFP_KERNEL);
if (!peer_mep)
return -ENOMEM;
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index a818fdc22da9..1a3bcb5dd955 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -308,7 +308,7 @@ static int __br_netpoll_enable(struct net_bridge_port *p)
struct netpoll *np;
int err;
- np = kzalloc(sizeof(*p->np), GFP_KERNEL);
+ np = kzalloc_obj(*p->np, GFP_KERNEL);
if (!np)
return -ENOMEM;
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 4c67a32745f6..4737ee16bebb 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -429,7 +429,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
if (index < 0)
return ERR_PTR(index);
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (p == NULL)
return ERR_PTR(-ENOMEM);
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index 6bc0a11f2ed3..7245ca29c5ea 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -204,7 +204,7 @@ int br_dev_siocdevprivate(struct net_device *dev, struct ifreq *rq,
if (num > BR_MAX_PORTS)
num = BR_MAX_PORTS;
- indices = kcalloc(num, sizeof(int), GFP_KERNEL);
+ indices = kzalloc_objs(int, num, GFP_KERNEL);
if (indices == NULL)
return -ENOMEM;
@@ -357,7 +357,7 @@ static int old_deviceless(struct net *net, void __user *data)
if (args[2] >= 2048)
return -ENOMEM;
- indices = kcalloc(args[2], sizeof(int), GFP_KERNEL);
+ indices = kzalloc_objs(int, args[2], GFP_KERNEL);
if (indices == NULL)
return -ENOMEM;
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index 400eb872b403..a5f0b74b59f3 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -1133,8 +1133,8 @@ static int br_mdb_config_src_list_init(struct nlattr *src_list,
return -EINVAL;
}
- cfg->src_entries = kcalloc(cfg->num_src_entries,
- sizeof(struct br_mdb_src_entry), GFP_KERNEL);
+ cfg->src_entries = kzalloc_objs(struct br_mdb_src_entry,
+ cfg->num_src_entries, GFP_KERNEL);
if (!cfg->src_entries)
return -ENOMEM;
diff --git a/net/bridge/br_mrp.c b/net/bridge/br_mrp.c
index 3c36fa24bc05..d587f99afef6 100644
--- a/net/bridge/br_mrp.c
+++ b/net/bridge/br_mrp.c
@@ -516,7 +516,7 @@ int br_mrp_add(struct net_bridge *br, struct br_mrp_instance *instance)
!br_mrp_unique_ifindex(br, instance->s_ifindex))
return -EINVAL;
- mrp = kzalloc(sizeof(*mrp), GFP_KERNEL);
+ mrp = kzalloc_obj(*mrp, GFP_KERNEL);
if (!mrp)
return -ENOMEM;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index b6a5147886ca..881d866d687a 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1290,7 +1290,7 @@ struct net_bridge_mdb_entry *br_multicast_new_group(struct net_bridge *br,
return ERR_PTR(-E2BIG);
}
- mp = kzalloc(sizeof(*mp), GFP_ATOMIC);
+ mp = kzalloc_obj(*mp, GFP_ATOMIC);
if (unlikely(!mp))
return ERR_PTR(-ENOMEM);
@@ -1381,7 +1381,7 @@ br_multicast_new_group_src(struct net_bridge_port_group *pg, struct br_ip *src_i
#endif
}
- grp_src = kzalloc(sizeof(*grp_src), GFP_ATOMIC);
+ grp_src = kzalloc_obj(*grp_src, GFP_ATOMIC);
if (unlikely(!grp_src))
return NULL;
@@ -1414,7 +1414,7 @@ struct net_bridge_port_group *br_multicast_new_port_group(
if (err)
return NULL;
- p = kzalloc(sizeof(*p), GFP_ATOMIC);
+ p = kzalloc_obj(*p, GFP_ATOMIC);
if (unlikely(!p)) {
NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new port group");
goto dec_out;
@@ -4891,7 +4891,7 @@ int br_multicast_list_adjacent(struct net_device *dev,
continue;
hlist_for_each_entry_rcu(group, &port->mglist, mglist) {
- entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kmalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
goto unlock;
diff --git a/net/bridge/br_multicast_eht.c b/net/bridge/br_multicast_eht.c
index adfd74102019..18eaf9c0dada 100644
--- a/net/bridge/br_multicast_eht.c
+++ b/net/bridge/br_multicast_eht.c
@@ -266,7 +266,7 @@ __eht_lookup_create_host(struct net_bridge_port_group *pg,
if (br_multicast_eht_hosts_over_limit(pg))
return NULL;
- eht_host = kzalloc(sizeof(*eht_host), GFP_ATOMIC);
+ eht_host = kzalloc_obj(*eht_host, GFP_ATOMIC);
if (!eht_host)
return NULL;
@@ -313,7 +313,7 @@ __eht_lookup_create_set_entry(struct net_bridge *br,
if (!allow_zero_src && eht_host->num_entries >= PG_SRC_ENT_LIMIT)
return NULL;
- set_h = kzalloc(sizeof(*set_h), GFP_ATOMIC);
+ set_h = kzalloc_obj(*set_h, GFP_ATOMIC);
if (!set_h)
return NULL;
@@ -360,7 +360,7 @@ __eht_lookup_create_set(struct net_bridge_port_group *pg,
return this;
}
- eht_set = kzalloc(sizeof(*eht_set), GFP_ATOMIC);
+ eht_set = kzalloc_obj(*eht_set, GFP_ATOMIC);
if (!eht_set)
return NULL;
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index fe3f7bbe86ee..4fac002922d2 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -661,7 +661,7 @@ void br_switchdev_mdb_notify(struct net_device *dev,
mdb.obj.orig_dev = pg->key.port->dev;
switch (type) {
case RTM_NEWMDB:
- complete_info = kmalloc(sizeof(*complete_info), GFP_ATOMIC);
+ complete_info = kmalloc_obj(*complete_info, GFP_ATOMIC);
if (!complete_info)
break;
complete_info->port = pg->key.port;
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index ce72b837ff8e..e3a5eb9e6ed1 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -787,7 +787,7 @@ int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags, bool *changed,
return br_vlan_add_existing(br, vg, vlan, flags, changed,
extack);
- vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
+ vlan = kzalloc_obj(*vlan, GFP_KERNEL);
if (!vlan)
return -ENOMEM;
@@ -1224,7 +1224,7 @@ int br_vlan_init(struct net_bridge *br)
struct net_bridge_vlan_group *vg;
int ret = -ENOMEM;
- vg = kzalloc(sizeof(*vg), GFP_KERNEL);
+ vg = kzalloc_obj(*vg, GFP_KERNEL);
if (!vg)
goto out;
ret = rhashtable_init(&vg->vlan_hash, &br_vlan_rht_params);
@@ -1260,7 +1260,7 @@ int nbp_vlan_init(struct net_bridge_port *p, struct netlink_ext_ack *extack)
struct net_bridge_vlan_group *vg;
int ret = -ENOMEM;
- vg = kzalloc(sizeof(struct net_bridge_vlan_group), GFP_KERNEL);
+ vg = kzalloc_obj(struct net_bridge_vlan_group, GFP_KERNEL);
if (!vg)
goto out;
@@ -1334,7 +1334,7 @@ int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
return 0;
}
- vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
+ vlan = kzalloc_obj(*vlan, GFP_KERNEL);
if (!vlan)
return -ENOMEM;
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index a04fc1757528..f01efd0b139e 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1303,7 +1303,7 @@ int ebt_register_template(const struct ebt_table *t, int (*table_init)(struct ne
}
}
- tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL);
+ tmpl = kzalloc_obj(*tmpl, GFP_KERNEL);
if (!tmpl) {
mutex_unlock(&ebt_mutex);
return -ENOMEM;
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index 24e85c5487ef..18f7769405f9 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -94,7 +94,7 @@ static struct caif_device_entry *caif_device_alloc(struct net_device *dev)
{
struct caif_device_entry *caifd;
- caifd = kzalloc(sizeof(*caifd), GFP_KERNEL);
+ caifd = kzalloc_obj(*caifd, GFP_KERNEL);
if (!caifd)
return NULL;
caifd->pcpu_refcnt = alloc_percpu(int);
diff --git a/net/caif/caif_usb.c b/net/caif/caif_usb.c
index 5dc05a1e3178..4d44960d4c2f 100644
--- a/net/caif/caif_usb.c
+++ b/net/caif/caif_usb.c
@@ -85,7 +85,7 @@ static void cfusbl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
static struct cflayer *cfusbl_create(int phyid, const u8 ethaddr[ETH_ALEN],
u8 braddr[ETH_ALEN])
{
- struct cfusbl *this = kmalloc(sizeof(struct cfusbl), GFP_ATOMIC);
+ struct cfusbl *this = kmalloc_obj(struct cfusbl, GFP_ATOMIC);
if (!this)
return NULL;
diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
index 52509e185960..8a80914783e8 100644
--- a/net/caif/cfcnfg.c
+++ b/net/caif/cfcnfg.c
@@ -77,7 +77,7 @@ struct cfcnfg *cfcnfg_create(void)
might_sleep();
/* Initiate this layer */
- this = kzalloc(sizeof(struct cfcnfg), GFP_ATOMIC);
+ this = kzalloc_obj(struct cfcnfg, GFP_ATOMIC);
if (!this)
return NULL;
this->mux = cfmuxl_create();
@@ -477,7 +477,7 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
goto out;
got_phyid:
- phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC);
+ phyinfo = kzalloc_obj(struct cfcnfg_phyinfo, GFP_ATOMIC);
if (!phyinfo) {
res = -ENOMEM;
goto out;
diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
index 2aa1e7d46eb2..566546da4152 100644
--- a/net/caif/cfctrl.c
+++ b/net/caif/cfctrl.c
@@ -36,7 +36,7 @@ struct cflayer *cfctrl_create(void)
{
struct dev_info dev_info;
struct cfctrl *this =
- kzalloc(sizeof(struct cfctrl), GFP_ATOMIC);
+ kzalloc_obj(struct cfctrl, GFP_ATOMIC);
if (!this)
return NULL;
caif_assert(offsetof(struct cfctrl, serv.layer) == 0);
@@ -270,7 +270,7 @@ int cfctrl_linkup_request(struct cflayer *layer,
cfpkt_destroy(pkt);
return -EINVAL;
}
- req = kzalloc(sizeof(*req), GFP_KERNEL);
+ req = kzalloc_obj(*req, GFP_KERNEL);
if (!req) {
cfpkt_destroy(pkt);
return -ENOMEM;
diff --git a/net/caif/cfdbgl.c b/net/caif/cfdbgl.c
index 77f428428b47..57ad3f82e004 100644
--- a/net/caif/cfdbgl.c
+++ b/net/caif/cfdbgl.c
@@ -19,7 +19,7 @@ static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
{
- struct cfsrvl *dbg = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
+ struct cfsrvl *dbg = kzalloc_obj(struct cfsrvl, GFP_ATOMIC);
if (!dbg)
return NULL;
caif_assert(offsetof(struct cfsrvl, layer) == 0);
diff --git a/net/caif/cfdgml.c b/net/caif/cfdgml.c
index eb6f8ef47a79..c451ddd155a7 100644
--- a/net/caif/cfdgml.c
+++ b/net/caif/cfdgml.c
@@ -26,7 +26,7 @@ static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
{
- struct cfsrvl *dgm = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
+ struct cfsrvl *dgm = kzalloc_obj(struct cfsrvl, GFP_ATOMIC);
if (!dgm)
return NULL;
caif_assert(offsetof(struct cfsrvl, layer) == 0);
diff --git a/net/caif/cffrml.c b/net/caif/cffrml.c
index d4d63586053a..0f4979d89fcb 100644
--- a/net/caif/cffrml.c
+++ b/net/caif/cffrml.c
@@ -34,7 +34,7 @@ static u32 cffrml_rcv_error;
static u32 cffrml_rcv_checsum_error;
struct cflayer *cffrml_create(u16 phyid, bool use_fcs)
{
- struct cffrml *this = kzalloc(sizeof(struct cffrml), GFP_ATOMIC);
+ struct cffrml *this = kzalloc_obj(struct cffrml, GFP_ATOMIC);
if (!this)
return NULL;
this->pcpu_refcnt = alloc_percpu(int);
diff --git a/net/caif/cfmuxl.c b/net/caif/cfmuxl.c
index 4172b0d0db63..77a1f31639b7 100644
--- a/net/caif/cfmuxl.c
+++ b/net/caif/cfmuxl.c
@@ -47,7 +47,7 @@ static struct cflayer *get_up(struct cfmuxl *muxl, u16 id);
struct cflayer *cfmuxl_create(void)
{
- struct cfmuxl *this = kzalloc(sizeof(struct cfmuxl), GFP_ATOMIC);
+ struct cfmuxl *this = kzalloc_obj(struct cfmuxl, GFP_ATOMIC);
if (!this)
return NULL;
diff --git a/net/caif/cfrfml.c b/net/caif/cfrfml.c
index 3c335057f255..93732ebbd1e2 100644
--- a/net/caif/cfrfml.c
+++ b/net/caif/cfrfml.c
@@ -46,7 +46,7 @@ struct cflayer *cfrfml_create(u8 channel_id, struct dev_info *dev_info,
int mtu_size)
{
int tmp;
- struct cfrfml *this = kzalloc(sizeof(struct cfrfml), GFP_ATOMIC);
+ struct cfrfml *this = kzalloc_obj(struct cfrfml, GFP_ATOMIC);
if (!this)
return NULL;
diff --git a/net/caif/cfserl.c b/net/caif/cfserl.c
index aee11c74d3c8..faf78fb754e2 100644
--- a/net/caif/cfserl.c
+++ b/net/caif/cfserl.c
@@ -38,7 +38,7 @@ void cfserl_release(struct cflayer *layer)
struct cflayer *cfserl_create(int instance, bool use_stx)
{
- struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
+ struct cfserl *this = kzalloc_obj(struct cfserl, GFP_ATOMIC);
if (!this)
return NULL;
caif_assert(offsetof(struct cfserl, layer) == 0);
diff --git a/net/caif/cfutill.c b/net/caif/cfutill.c
index b2e47ede912f..5111090bb2c0 100644
--- a/net/caif/cfutill.c
+++ b/net/caif/cfutill.c
@@ -26,7 +26,7 @@ static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
{
- struct cfsrvl *util = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
+ struct cfsrvl *util = kzalloc_obj(struct cfsrvl, GFP_ATOMIC);
if (!util)
return NULL;
caif_assert(offsetof(struct cfsrvl, layer) == 0);
diff --git a/net/caif/cfveil.c b/net/caif/cfveil.c
index db2274b94a5d..53f844c49bbb 100644
--- a/net/caif/cfveil.c
+++ b/net/caif/cfveil.c
@@ -25,7 +25,7 @@ static int cfvei_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
{
- struct cfsrvl *vei = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
+ struct cfsrvl *vei = kzalloc_obj(struct cfsrvl, GFP_ATOMIC);
if (!vei)
return NULL;
caif_assert(offsetof(struct cfsrvl, layer) == 0);
diff --git a/net/caif/cfvidl.c b/net/caif/cfvidl.c
index 134bad43196c..39e075b0a259 100644
--- a/net/caif/cfvidl.c
+++ b/net/caif/cfvidl.c
@@ -21,7 +21,7 @@ static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt);
struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
{
- struct cfsrvl *vid = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
+ struct cfsrvl *vid = kzalloc_obj(struct cfsrvl, GFP_ATOMIC);
if (!vid)
return NULL;
caif_assert(offsetof(struct cfsrvl, layer) == 0);
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 22c65a014861..6fa0dd649d0c 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -798,14 +798,15 @@ EXPORT_SYMBOL(can_proto_unregister);
static int can_pernet_init(struct net *net)
{
spin_lock_init(&net->can.rcvlists_lock);
- net->can.rx_alldev_list =
- kzalloc(sizeof(*net->can.rx_alldev_list), GFP_KERNEL);
+ net->can.rx_alldev_list = kzalloc_obj(*net->can.rx_alldev_list,
+ GFP_KERNEL);
if (!net->can.rx_alldev_list)
goto out;
- net->can.pkg_stats = kzalloc(sizeof(*net->can.pkg_stats), GFP_KERNEL);
+ net->can.pkg_stats = kzalloc_obj(*net->can.pkg_stats, GFP_KERNEL);
if (!net->can.pkg_stats)
goto out_free_rx_alldev_list;
- net->can.rcv_lists_stats = kzalloc(sizeof(*net->can.rcv_lists_stats), GFP_KERNEL);
+ net->can.rcv_lists_stats = kzalloc_obj(*net->can.rcv_lists_stats,
+ GFP_KERNEL);
if (!net->can.rcv_lists_stats)
goto out_free_pkg_stats;
diff --git a/net/can/gw.c b/net/can/gw.c
index 61a1e6b1b83f..c6cf4cb72891 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -1099,7 +1099,7 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh,
if (r->gwtype != CGW_TYPE_CAN_CAN)
return -EINVAL;
- mod = kmalloc(sizeof(*mod), GFP_KERNEL);
+ mod = kmalloc_obj(*mod, GFP_KERNEL);
if (!mod)
return -ENOMEM;
diff --git a/net/can/j1939/bus.c b/net/can/j1939/bus.c
index 797719cb227e..dc374286eeb6 100644
--- a/net/can/j1939/bus.c
+++ b/net/can/j1939/bus.c
@@ -151,7 +151,7 @@ struct j1939_ecu *j1939_ecu_create_locked(struct j1939_priv *priv, name_t name)
lockdep_assert_held(&priv->lock);
- ecu = kzalloc(sizeof(*ecu), gfp_any());
+ ecu = kzalloc_obj(*ecu, gfp_any());
if (!ecu)
return ERR_PTR(-ENOMEM);
kref_init(&ecu->kref);
diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
index a93af55df5fd..45b718c680e0 100644
--- a/net/can/j1939/main.c
+++ b/net/can/j1939/main.c
@@ -128,7 +128,7 @@ static struct j1939_priv *j1939_priv_create(struct net_device *ndev)
{
struct j1939_priv *priv;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return NULL;
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 2cbe94fc487a..df93d57907da 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1508,7 +1508,7 @@ static struct j1939_session *j1939_session_new(struct j1939_priv *priv,
struct j1939_session *session;
struct j1939_sk_buff_cb *skcb;
- session = kzalloc(sizeof(*session), gfp_any());
+ session = kzalloc_obj(*session, gfp_any());
if (!session)
return NULL;
diff --git a/net/ceph/auth.c b/net/ceph/auth.c
index d38c9eadbe2f..343c841784ce 100644
--- a/net/ceph/auth.c
+++ b/net/ceph/auth.c
@@ -59,7 +59,7 @@ struct ceph_auth_client *ceph_auth_init(const char *name,
{
struct ceph_auth_client *ac;
- ac = kzalloc(sizeof(*ac), GFP_NOFS);
+ ac = kzalloc_obj(*ac, GFP_NOFS);
if (!ac)
return ERR_PTR(-ENOMEM);
diff --git a/net/ceph/auth_none.c b/net/ceph/auth_none.c
index 77b5519bc45f..99e1f3e10a4c 100644
--- a/net/ceph/auth_none.c
+++ b/net/ceph/auth_none.c
@@ -97,7 +97,7 @@ static int ceph_auth_none_create_authorizer(
struct ceph_none_authorizer *au;
int ret;
- au = kmalloc(sizeof(*au), GFP_NOFS);
+ au = kmalloc_obj(*au, GFP_NOFS);
if (!au)
return -ENOMEM;
@@ -133,7 +133,7 @@ int ceph_auth_none_init(struct ceph_auth_client *ac)
struct ceph_auth_none_info *xi;
dout("ceph_auth_none_init %p\n", ac);
- xi = kzalloc(sizeof(*xi), GFP_NOFS);
+ xi = kzalloc_obj(*xi, GFP_NOFS);
if (!xi)
return -ENOMEM;
diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
index 13b3df9af0ac..692e0b868822 100644
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -166,7 +166,7 @@ get_ticket_handler(struct ceph_auth_client *ac, int service)
}
/* add it */
- th = kzalloc(sizeof(*th), GFP_NOFS);
+ th = kzalloc_obj(*th, GFP_NOFS);
if (!th)
return ERR_PTR(-ENOMEM);
th->service = service;
@@ -808,7 +808,7 @@ static int ceph_x_create_authorizer(
if (IS_ERR(th))
return PTR_ERR(th);
- au = kzalloc(sizeof(*au), GFP_NOFS);
+ au = kzalloc_obj(*au, GFP_NOFS);
if (!au)
return -ENOMEM;
@@ -1174,7 +1174,7 @@ int ceph_x_init(struct ceph_auth_client *ac)
int ret;
dout("ceph_x_init %p\n", ac);
- xi = kzalloc(sizeof(*xi), GFP_NOFS);
+ xi = kzalloc_obj(*xi, GFP_NOFS);
if (!xi)
return -ENOMEM;
diff --git a/net/ceph/buffer.c b/net/ceph/buffer.c
index 7e51f128045d..98c2ac4387ae 100644
--- a/net/ceph/buffer.c
+++ b/net/ceph/buffer.c
@@ -13,7 +13,7 @@ struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp)
{
struct ceph_buffer *b;
- b = kmalloc(sizeof(*b), gfp);
+ b = kmalloc_obj(*b, gfp);
if (!b)
return NULL;
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index e734e57be083..455787422784 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -309,13 +309,12 @@ struct ceph_options *ceph_alloc_options(void)
{
struct ceph_options *opt;
- opt = kzalloc(sizeof(*opt), GFP_KERNEL);
+ opt = kzalloc_obj(*opt, GFP_KERNEL);
if (!opt)
return NULL;
opt->crush_locs = RB_ROOT;
- opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr),
- GFP_KERNEL);
+ opt->mon_addr = kzalloc_objs(*opt->mon_addr, CEPH_MAX_MON, GFP_KERNEL);
if (!opt->mon_addr) {
kfree(opt);
return NULL;
@@ -456,7 +455,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
ceph_crypto_key_destroy(opt->key);
kfree(opt->key);
- opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
+ opt->key = kzalloc_obj(*opt->key, GFP_KERNEL);
if (!opt->key)
return -ENOMEM;
err = ceph_crypto_key_unarmor(opt->key, param->string);
@@ -469,7 +468,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
ceph_crypto_key_destroy(opt->key);
kfree(opt->key);
- opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
+ opt->key = kzalloc_obj(*opt->key, GFP_KERNEL);
if (!opt->key)
return -ENOMEM;
return get_secret(opt->key, param->string, &log);
@@ -714,7 +713,7 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private)
if (err < 0)
return ERR_PTR(err);
- client = kzalloc(sizeof(*client), GFP_KERNEL);
+ client = kzalloc_obj(*client, GFP_KERNEL);
if (client == NULL)
return ERR_PTR(-ENOMEM);
diff --git a/net/ceph/cls_lock_client.c b/net/ceph/cls_lock_client.c
index 66136a4c1ce7..c6956f1df333 100644
--- a/net/ceph/cls_lock_client.c
+++ b/net/ceph/cls_lock_client.c
@@ -300,7 +300,7 @@ static int decode_lockers(void **p, void *end, u8 *type, char **tag,
return ret;
*num_lockers = ceph_decode_32(p);
- *lockers = kcalloc(*num_lockers, sizeof(**lockers), GFP_NOIO);
+ *lockers = kzalloc_objs(**lockers, *num_lockers, GFP_NOIO);
if (!*lockers)
return -ENOMEM;
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index b2067ea6c38a..ef8a98c1174f 100644
--- a/net/ceph/crypto.c
+++ b/net/ceph/crypto.c
@@ -466,7 +466,7 @@ static int ceph_key_preparse(struct key_preparsed_payload *prep)
goto err;
ret = -ENOMEM;
- ckey = kzalloc(sizeof(*ckey), GFP_KERNEL);
+ ckey = kzalloc_obj(*ckey, GFP_KERNEL);
if (!ckey)
goto err;
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 70b25f4ecba6..108adb583744 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1993,8 +1993,7 @@ struct ceph_msg *ceph_msg_new2(int type, int front_len, int max_data_items,
m->front_alloc_len = m->front.iov_len = front_len;
if (max_data_items) {
- m->data = kmalloc_array(max_data_items, sizeof(*m->data),
- flags);
+ m->data = kmalloc_objs(*m->data, max_data_items, flags);
if (!m->data)
goto out2;
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index fa8dd2a20f7d..2e2fd241dd19 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -117,7 +117,7 @@ static struct ceph_monmap *ceph_monmap_decode(void **p, void *end, bool msgr2)
if (num_mon > CEPH_MAX_MON)
goto e_inval;
- monmap = kmalloc(struct_size(monmap, mon_inst, num_mon), GFP_NOIO);
+ monmap = kmalloc_flex(*monmap, mon_inst, num_mon, GFP_NOIO);
if (!monmap) {
ret = -ENOMEM;
goto fail;
@@ -611,7 +611,7 @@ alloc_generic_request(struct ceph_mon_client *monc, gfp_t gfp)
{
struct ceph_mon_generic_request *req;
- req = kzalloc(sizeof(*req), gfp);
+ req = kzalloc_obj(*req, gfp);
if (!req)
return NULL;
@@ -1140,8 +1140,8 @@ static int build_initial_monmap(struct ceph_mon_client *monc)
int i;
/* build initial monmap */
- monc->monmap = kzalloc(struct_size(monc->monmap, mon_inst, num_mon),
- GFP_KERNEL);
+ monc->monmap = kzalloc_flex(*monc->monmap, mon_inst, num_mon,
+ GFP_KERNEL);
if (!monc->monmap)
return -ENOMEM;
monc->monmap->num_mon = num_mon;
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 610e584524d1..2ff00070c181 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -556,7 +556,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
req = kmem_cache_alloc(ceph_osd_request_cache, gfp_flags);
} else {
BUG_ON(num_ops > CEPH_OSD_MAX_OPS);
- req = kmalloc(struct_size(req, r_ops, num_ops), gfp_flags);
+ req = kmalloc_flex(*req, r_ops, num_ops, gfp_flags);
}
if (unlikely(!req))
return NULL;
@@ -1153,9 +1153,8 @@ int __ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt)
WARN_ON(op->op != CEPH_OSD_OP_SPARSE_READ);
op->extent.sparse_ext_cnt = cnt;
- op->extent.sparse_ext = kmalloc_array(cnt,
- sizeof(*op->extent.sparse_ext),
- GFP_NOFS);
+ op->extent.sparse_ext = kmalloc_objs(*op->extent.sparse_ext, cnt,
+ GFP_NOFS);
if (!op->extent.sparse_ext)
return -ENOMEM;
return 0;
@@ -1264,7 +1263,7 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
WARN_ON(onum == CEPH_HOMELESS_OSD);
- osd = kzalloc(sizeof(*osd), GFP_NOIO | __GFP_NOFAIL);
+ osd = kzalloc_obj(*osd, GFP_NOIO | __GFP_NOFAIL);
osd_init(osd);
osd->o_osdc = osdc;
osd->o_osd = onum;
@@ -1718,7 +1717,7 @@ static struct ceph_spg_mapping *alloc_spg_mapping(void)
{
struct ceph_spg_mapping *spg;
- spg = kmalloc(sizeof(*spg), GFP_NOIO);
+ spg = kmalloc_obj(*spg, GFP_NOIO);
if (!spg)
return NULL;
@@ -1913,7 +1912,7 @@ static struct ceph_osd_backoff *alloc_backoff(void)
{
struct ceph_osd_backoff *backoff;
- backoff = kzalloc(sizeof(*backoff), GFP_NOIO);
+ backoff = kzalloc_obj(*backoff, GFP_NOIO);
if (!backoff)
return NULL;
@@ -2806,7 +2805,7 @@ linger_alloc(struct ceph_osd_client *osdc)
{
struct ceph_osd_linger_request *lreq;
- lreq = kzalloc(sizeof(*lreq), GFP_NOIO);
+ lreq = kzalloc_obj(*lreq, GFP_NOIO);
if (!lreq)
return NULL;
@@ -2948,7 +2947,7 @@ static struct linger_work *lwork_alloc(struct ceph_osd_linger_request *lreq,
{
struct linger_work *lwork;
- lwork = kzalloc(sizeof(*lwork), GFP_NOIO);
+ lwork = kzalloc_obj(*lwork, GFP_NOIO);
if (!lwork)
return NULL;
@@ -4329,7 +4328,7 @@ static int decode_MOSDBackoff(const struct ceph_msg *msg, struct MOSDBackoff *m)
ceph_decode_8_safe(&p, end, m->op, e_inval);
ceph_decode_64_safe(&p, end, m->id, e_inval);
- m->begin = kzalloc(sizeof(*m->begin), GFP_NOIO);
+ m->begin = kzalloc_obj(*m->begin, GFP_NOIO);
if (!m->begin)
return -ENOMEM;
@@ -4339,7 +4338,7 @@ static int decode_MOSDBackoff(const struct ceph_msg *msg, struct MOSDBackoff *m)
return ret;
}
- m->end = kzalloc(sizeof(*m->end), GFP_NOIO);
+ m->end = kzalloc_obj(*m->end, GFP_NOIO);
if (!m->end) {
free_hoid(m->begin);
return -ENOMEM;
@@ -5032,7 +5031,7 @@ static int decode_watchers(void **p, void *end,
return ret;
*num_watchers = ceph_decode_32(p);
- *watchers = kcalloc(*num_watchers, sizeof(**watchers), GFP_NOIO);
+ *watchers = kzalloc_objs(**watchers, *num_watchers, GFP_NOIO);
if (!*watchers)
return -ENOMEM;
@@ -5832,9 +5831,8 @@ next_op:
if (!sr->sr_extent || count > sr->sr_ext_len) {
/* no extent array provided, or too short */
kfree(sr->sr_extent);
- sr->sr_extent = kmalloc_array(count,
- sizeof(*sr->sr_extent),
- GFP_NOIO);
+ sr->sr_extent = kmalloc_objs(*sr->sr_extent,
+ count, GFP_NOIO);
if (!sr->sr_extent) {
pr_err("%s: failed to allocate %u extents\n",
__func__, count);
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 92a44026de29..c89e66d4fcb7 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -231,7 +231,7 @@ static struct crush_choose_arg_map *alloc_choose_arg_map(void)
{
struct crush_choose_arg_map *arg_map;
- arg_map = kzalloc(sizeof(*arg_map), GFP_NOIO);
+ arg_map = kzalloc_obj(*arg_map, GFP_NOIO);
if (!arg_map)
return NULL;
@@ -320,9 +320,8 @@ static int decode_choose_arg(void **p, void *end, struct crush_choose_arg *arg)
if (arg->weight_set_size) {
u32 i;
- arg->weight_set = kmalloc_array(arg->weight_set_size,
- sizeof(*arg->weight_set),
- GFP_NOIO);
+ arg->weight_set = kmalloc_objs(*arg->weight_set,
+ arg->weight_set_size, GFP_NOIO);
if (!arg->weight_set)
return -ENOMEM;
@@ -368,8 +367,8 @@ static int decode_choose_args(void **p, void *end, struct crush_map *c)
ceph_decode_64_safe(p, end, arg_map->choose_args_index,
e_inval);
arg_map->size = c->max_buckets;
- arg_map->args = kcalloc(arg_map->size, sizeof(*arg_map->args),
- GFP_NOIO);
+ arg_map->args = kzalloc_objs(*arg_map->args, arg_map->size,
+ GFP_NOIO);
if (!arg_map->args) {
ret = -ENOMEM;
goto fail;
@@ -443,7 +442,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
dout("crush_decode %p to %p len %d\n", *p, end, (int)(end - *p));
- c = kzalloc(sizeof(*c), GFP_NOFS);
+ c = kzalloc_obj(*c, GFP_NOFS);
if (c == NULL)
return ERR_PTR(-ENOMEM);
@@ -468,10 +467,10 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
c->max_rules = ceph_decode_32(p);
c->max_devices = ceph_decode_32(p);
- c->buckets = kcalloc(c->max_buckets, sizeof(*c->buckets), GFP_NOFS);
+ c->buckets = kzalloc_objs(*c->buckets, c->max_buckets, GFP_NOFS);
if (c->buckets == NULL)
goto badmem;
- c->rules = kcalloc(c->max_rules, sizeof(*c->rules), GFP_NOFS);
+ c->rules = kzalloc_objs(*c->rules, c->max_rules, GFP_NOFS);
if (c->rules == NULL)
goto badmem;
@@ -524,7 +523,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
dout("crush_decode bucket size %d off %x %p to %p\n",
b->size, (int)(*p-start), *p, end);
- b->items = kcalloc(b->size, sizeof(__s32), GFP_NOFS);
+ b->items = kzalloc_objs(__s32, b->size, GFP_NOFS);
if (b->items == NULL)
goto badmem;
@@ -590,7 +589,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
/ sizeof(struct crush_rule_step))
goto bad;
#endif
- r = kmalloc(struct_size(r, steps, yes), GFP_NOFS);
+ r = kmalloc_flex(*r, steps, yes, GFP_NOFS);
if (r == NULL)
goto badmem;
dout(" rule %d is at %p\n", i, r);
@@ -1116,7 +1115,7 @@ struct ceph_osdmap *ceph_osdmap_alloc(void)
{
struct ceph_osdmap *map;
- map = kzalloc(sizeof(*map), GFP_NOIO);
+ map = kzalloc_obj(*map, GFP_NOIO);
if (!map)
return NULL;
@@ -1343,7 +1342,7 @@ static int __decode_pools(void **p, void *end, struct ceph_osdmap *map,
pi = lookup_pg_pool(&map->pg_pools, pool);
if (!incremental || !pi) {
- pi = kzalloc(sizeof(*pi), GFP_NOFS);
+ pi = kzalloc_obj(*pi, GFP_NOFS);
if (!pi)
return -ENOMEM;
diff --git a/net/ceph/pagelist.c b/net/ceph/pagelist.c
index 5a9c4be5f222..40847d873cff 100644
--- a/net/ceph/pagelist.c
+++ b/net/ceph/pagelist.c
@@ -10,7 +10,7 @@ struct ceph_pagelist *ceph_pagelist_alloc(gfp_t gfp_flags)
{
struct ceph_pagelist *pl;
- pl = kmalloc(sizeof(*pl), gfp_flags);
+ pl = kmalloc_obj(*pl, gfp_flags);
if (!pl)
return NULL;
diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c
index 4509757d8b3b..858359873c4d 100644
--- a/net/ceph/pagevec.c
+++ b/net/ceph/pagevec.c
@@ -41,7 +41,7 @@ struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags)
struct page **pages;
int i;
- pages = kmalloc_array(num_pages, sizeof(*pages), flags);
+ pages = kmalloc_objs(*pages, num_pages, flags);
if (!pages)
return ERR_PTR(-ENOMEM);
for (i = 0; i < num_pages; i++) {
diff --git a/net/ceph/striper.c b/net/ceph/striper.c
index 3b3fa75d1189..2b8288858079 100644
--- a/net/ceph/striper.c
+++ b/net/ceph/striper.c
@@ -230,8 +230,8 @@ int ceph_extent_to_file(struct ceph_file_layout *l,
*num_file_extents = DIV_ROUND_UP_ULL(objoff + objlen, l->stripe_unit) -
DIV_ROUND_DOWN_ULL(objoff, l->stripe_unit);
- *file_extents = kmalloc_array(*num_file_extents, sizeof(**file_extents),
- GFP_NOIO);
+ *file_extents = kmalloc_objs(**file_extents, *num_file_extents,
+ GFP_NOIO);
if (!*file_extents)
return -ENOMEM;
diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
index 1eb3e060994e..8165d606bfd4 100644
--- a/net/core/bpf_sk_storage.c
+++ b/net/core/bpf_sk_storage.c
@@ -500,7 +500,7 @@ bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs)
nr_maps++;
}
- diag = kzalloc(struct_size(diag, maps, nr_maps), GFP_KERNEL);
+ diag = kzalloc_flex(*diag, maps, nr_maps, GFP_KERNEL);
if (!diag)
return ERR_PTR(-ENOMEM);
diff --git a/net/core/dev.c b/net/core/dev.c
index 096b3ff13f6b..525cf5952101 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -273,7 +273,7 @@ static struct netdev_name_node *netdev_name_node_alloc(struct net_device *dev,
{
struct netdev_name_node *name_node;
- name_node = kmalloc(sizeof(*name_node), GFP_KERNEL);
+ name_node = kmalloc_obj(*name_node, GFP_KERNEL);
if (!name_node)
return NULL;
INIT_HLIST_NODE(&name_node->hlist);
@@ -6510,8 +6510,7 @@ struct flush_backlogs {
static struct flush_backlogs *flush_backlogs_alloc(void)
{
- return kmalloc(struct_size_t(struct flush_backlogs, w, nr_cpu_ids),
- GFP_KERNEL);
+ return kmalloc_flex(struct flush_backlogs, w, nr_cpu_ids, GFP_KERNEL);
}
static struct flush_backlogs *flush_backlogs_fallback;
@@ -8694,7 +8693,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
return 0;
}
- adj = kmalloc(sizeof(*adj), GFP_KERNEL);
+ adj = kmalloc_obj(*adj, GFP_KERNEL);
if (!adj)
return -ENOMEM;
@@ -9134,8 +9133,8 @@ static int netdev_offload_xstats_enable_l3(struct net_device *dev,
int err;
int rc;
- dev->offload_xstats_l3 = kzalloc(sizeof(*dev->offload_xstats_l3),
- GFP_KERNEL);
+ dev->offload_xstats_l3 = kzalloc_obj(*dev->offload_xstats_l3,
+ GFP_KERNEL);
if (!dev->offload_xstats_l3)
return -ENOMEM;
@@ -10660,7 +10659,7 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
return -EINVAL;
}
- link = kzalloc(sizeof(*link), GFP_USER);
+ link = kzalloc_obj(*link, GFP_USER);
if (!link) {
err = -ENOMEM;
goto unlock;
@@ -11941,7 +11940,7 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
#ifdef CONFIG_NET_CLS_ACT
if (queue)
return queue;
- queue = kzalloc(sizeof(*queue), GFP_KERNEL);
+ queue = kzalloc_obj(*queue, GFP_KERNEL);
if (!queue)
return NULL;
netdev_init_one_queue(dev, queue, NULL);
@@ -12016,8 +12015,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
maxqs = max(txqs, rxqs);
- dev = kvzalloc(struct_size(dev, priv, sizeof_priv),
- GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL);
+ dev = kvzalloc_flex(*dev, priv, sizeof_priv,
+ GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL);
if (!dev)
return NULL;
@@ -12088,11 +12087,11 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
dev->real_num_rx_queues = rxqs;
if (netif_alloc_rx_queues(dev))
goto free_all;
- dev->ethtool = kzalloc(sizeof(*dev->ethtool), GFP_KERNEL_ACCOUNT);
+ dev->ethtool = kzalloc_obj(*dev->ethtool, GFP_KERNEL_ACCOUNT);
if (!dev->ethtool)
goto free_all;
- dev->cfg = kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT);
+ dev->cfg = kzalloc_obj(*dev->cfg, GFP_KERNEL_ACCOUNT);
if (!dev->cfg)
goto free_all;
dev->cfg_pending = dev->cfg;
@@ -12858,7 +12857,7 @@ static struct hlist_head * __net_init netdev_create_hash(void)
int i;
struct hlist_head *hash;
- hash = kmalloc_array(NETDEV_HASHENTRIES, sizeof(*hash), GFP_KERNEL);
+ hash = kmalloc_objs(*hash, NETDEV_HASHENTRIES, GFP_KERNEL);
if (hash != NULL)
for (i = 0; i < NETDEV_HASHENTRIES; i++)
INIT_HLIST_HEAD(&hash[i]);
diff --git a/net/core/devmem.c b/net/core/devmem.c
index 63f093f7d2b2..16a1949dbed1 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -241,9 +241,9 @@ net_devmem_bind_dmabuf(struct net_device *dev,
}
if (direction == DMA_TO_DEVICE) {
- binding->tx_vec = kvmalloc_array(dmabuf->size / PAGE_SIZE,
- sizeof(struct net_iov *),
- GFP_KERNEL);
+ binding->tx_vec = kvmalloc_objs(struct net_iov *,
+ dmabuf->size / PAGE_SIZE,
+ GFP_KERNEL);
if (!binding->tx_vec) {
err = -ENOMEM;
goto err_unmap;
@@ -289,9 +289,9 @@ net_devmem_bind_dmabuf(struct net_device *dev,
goto err_free_chunks;
}
- owner->area.niovs = kvmalloc_array(owner->area.num_niovs,
- sizeof(*owner->area.niovs),
- GFP_KERNEL);
+ owner->area.niovs = kvmalloc_objs(*owner->area.niovs,
+ owner->area.num_niovs,
+ GFP_KERNEL);
if (!owner->area.niovs) {
err = -ENOMEM;
goto err_free_chunks;
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 60d31c2feed3..99f9d4dfb866 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -306,8 +306,8 @@ net_dm_hw_reset_per_cpu_data(struct per_cpu_dm_data *hw_data)
struct net_dm_hw_entries *hw_entries;
unsigned long flags;
- hw_entries = kzalloc(struct_size(hw_entries, entries, dm_hit_limit),
- GFP_KERNEL);
+ hw_entries = kzalloc_flex(*hw_entries, entries, dm_hit_limit,
+ GFP_KERNEL);
if (!hw_entries) {
/* If the memory allocation failed, we try to perform another
* allocation in 1/10 second. Otherwise, the probe function
@@ -856,7 +856,7 @@ net_dm_hw_metadata_copy(const struct devlink_trap_metadata *metadata)
const char *trap_group_name;
const char *trap_name;
- hw_metadata = kzalloc(sizeof(*hw_metadata), GFP_ATOMIC);
+ hw_metadata = kzalloc_obj(*hw_metadata, GFP_ATOMIC);
if (!hw_metadata)
return NULL;
@@ -1583,7 +1583,7 @@ static int dropmon_net_event(struct notifier_block *ev_block,
case NETDEV_REGISTER:
if (WARN_ON_ONCE(rtnl_dereference(dev->dm_private)))
break;
- stat = kzalloc(sizeof(*stat), GFP_KERNEL);
+ stat = kzalloc_obj(*stat, GFP_KERNEL);
if (!stat)
break;
diff --git a/net/core/dst.c b/net/core/dst.c
index 1dae26c51ebe..092861133023 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -191,7 +191,7 @@ EXPORT_SYMBOL(dst_release_immediate);
u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old)
{
- struct dst_metrics *p = kmalloc(sizeof(*p), GFP_ATOMIC);
+ struct dst_metrics *p = kmalloc_obj(*p, GFP_ATOMIC);
if (p) {
struct dst_metrics *old_p = (struct dst_metrics *)__DST_METRICS_PTR(old);
@@ -295,8 +295,7 @@ struct metadata_dst *metadata_dst_alloc(u8 optslen, enum metadata_type type,
{
struct metadata_dst *md_dst;
- md_dst = kmalloc(struct_size(md_dst, u.tun_info.options, optslen),
- flags);
+ md_dst = kmalloc_flex(*md_dst, u.tun_info.options, optslen, flags);
if (!md_dst)
return NULL;
diff --git a/net/core/failover.c b/net/core/failover.c
index 2a140b3ea669..fcc04e6995d0 100644
--- a/net/core/failover.c
+++ b/net/core/failover.c
@@ -247,7 +247,7 @@ struct failover *failover_register(struct net_device *dev,
if (dev->type != ARPHRD_ETHER)
return ERR_PTR(-EINVAL);
- failover = kzalloc(sizeof(*failover), GFP_KERNEL);
+ failover = kzalloc_obj(*failover, GFP_KERNEL);
if (!failover)
return ERR_PTR(-ENOMEM);
diff --git a/net/core/filter.c b/net/core/filter.c
index ba019ded773d..6957d3449f2c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -600,8 +600,7 @@ static int bpf_convert_filter(struct sock_filter *prog, int len,
if (new_prog) {
first_insn = new_prog->insnsi;
- addrs = kcalloc(len, sizeof(*addrs),
- GFP_KERNEL | __GFP_NOWARN);
+ addrs = kzalloc_objs(*addrs, len, GFP_KERNEL | __GFP_NOWARN);
if (!addrs)
return -ENOMEM;
}
@@ -1162,7 +1161,7 @@ static int bpf_prog_store_orig_filter(struct bpf_prog *fp,
unsigned int fsize = bpf_classic_proglen(fprog);
struct sock_fprog_kern *fkprog;
- fp->orig_prog = kmalloc(sizeof(*fkprog), GFP_KERNEL);
+ fp->orig_prog = kmalloc_obj(*fkprog, GFP_KERNEL);
if (!fp->orig_prog)
return -ENOMEM;
@@ -1482,7 +1481,7 @@ static int __sk_attach_prog(struct bpf_prog *prog, struct sock *sk)
{
struct sk_filter *fp, *old_fp;
- fp = kmalloc(sizeof(*fp), GFP_KERNEL);
+ fp = kmalloc_obj(*fp, GFP_KERNEL);
if (!fp)
return -ENOMEM;
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index bc5169482710..630f94e2c2c1 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -12,8 +12,7 @@ struct flow_rule *flow_rule_alloc(unsigned int num_actions)
struct flow_rule *rule;
int i;
- rule = kzalloc(struct_size(rule, action.entries, num_actions),
- GFP_KERNEL);
+ rule = kzalloc_flex(*rule, action.entries, num_actions, GFP_KERNEL);
if (!rule)
return NULL;
@@ -33,8 +32,8 @@ struct flow_offload_action *offload_action_alloc(unsigned int num_actions)
struct flow_offload_action *fl_action;
int i;
- fl_action = kzalloc(struct_size(fl_action, action.entries, num_actions),
- GFP_KERNEL);
+ fl_action = kzalloc_flex(*fl_action, action.entries, num_actions,
+ GFP_KERNEL);
if (!fl_action)
return NULL;
@@ -264,7 +263,7 @@ struct flow_block_cb *flow_block_cb_alloc(flow_setup_cb_t *cb,
{
struct flow_block_cb *block_cb;
- block_cb = kzalloc(sizeof(*block_cb), GFP_KERNEL);
+ block_cb = kzalloc_obj(*block_cb, GFP_KERNEL);
if (!block_cb)
return ERR_PTR(-ENOMEM);
@@ -391,7 +390,7 @@ static struct flow_indr_dev *flow_indr_dev_alloc(flow_indr_block_bind_cb_t *cb,
{
struct flow_indr_dev *indr_dev;
- indr_dev = kmalloc(sizeof(*indr_dev), GFP_KERNEL);
+ indr_dev = kmalloc_obj(*indr_dev, GFP_KERNEL);
if (!indr_dev)
return NULL;
@@ -571,7 +570,7 @@ static int indir_dev_add(void *data, struct net_device *dev, struct Qdisc *sch,
if (info)
return -EEXIST;
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index f112156db587..64d0d55fa2b2 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -154,7 +154,7 @@ int gen_new_estimator(struct gnet_stats_basic_sync *bstats,
if (parm->ewma_log == 0 || parm->ewma_log >= 31)
return -EINVAL;
- est = kzalloc(sizeof(*est), GFP_KERNEL);
+ est = kzalloc_obj(*est, GFP_KERNEL);
if (!est)
return -ENOBUFS;
diff --git a/net/core/gro_cells.c b/net/core/gro_cells.c
index a725d21159a6..1b84385c04bd 100644
--- a/net/core/gro_cells.c
+++ b/net/core/gro_cells.c
@@ -132,7 +132,7 @@ void gro_cells_destroy(struct gro_cells *gcells)
* because we might be called from cleanup_net(), and we
* definitely do not want to block this critical task.
*/
- defer = kmalloc(sizeof(*defer), GFP_KERNEL | __GFP_NOWARN);
+ defer = kmalloc_obj(*defer, GFP_KERNEL | __GFP_NOWARN);
if (likely(defer)) {
defer->ptr = gcells->cells;
call_rcu(&defer->rcu, percpu_free_defer_callback);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index e0897eb41c8d..a95cfe77f7f0 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -562,7 +562,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
struct neigh_hash_table *ret;
int i;
- ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
+ ret = kmalloc_obj(*ret, GFP_ATOMIC);
if (!ret)
return NULL;
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index aef44e617361..7a040a9233e7 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -492,7 +492,7 @@ static struct net *net_alloc(void)
goto out_free;
#ifdef CONFIG_KEYS
- net->key_domain = kzalloc(sizeof(struct key_tag), GFP_KERNEL);
+ net->key_domain = kzalloc_obj(struct key_tag, GFP_KERNEL);
if (!net->key_domain)
goto out_free_2;
refcount_set(&net->key_domain->usage, 1);
diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
index db9a5354f9de..9267880a0a17 100644
--- a/net/core/netclassid_cgroup.c
+++ b/net/core/netclassid_cgroup.c
@@ -32,7 +32,7 @@ cgrp_css_alloc(struct cgroup_subsys_state *parent_css)
{
struct cgroup_cls_state *cs;
- cs = kzalloc(sizeof(*cs), GFP_KERNEL);
+ cs = kzalloc_obj(*cs, GFP_KERNEL);
if (!cs)
return ERR_PTR(-ENOMEM);
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 09f72f10813c..70e458893ea5 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -565,7 +565,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
npinfo = rtnl_dereference(ndev->npinfo);
if (!npinfo) {
- npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
+ npinfo = kmalloc_obj(*npinfo, GFP_KERNEL);
if (!npinfo) {
err = -ENOMEM;
goto out;
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 8456dfbe2eb4..fb3cd2886e1f 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -135,7 +135,7 @@ cgrp_css_alloc(struct cgroup_subsys_state *parent_css)
{
struct cgroup_subsys_state *css;
- css = kzalloc(sizeof(*css), GFP_KERNEL);
+ css = kzalloc_obj(*css, GFP_KERNEL);
if (!css)
return ERR_PTR(-ENOMEM);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index b1ed55141d8a..da268fc45356 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -414,7 +414,7 @@ static int rtnl_register_internal(struct module *owner,
if (!link)
goto unlock;
} else {
- link = kzalloc(sizeof(*link), GFP_KERNEL);
+ link = kzalloc_obj(*link, GFP_KERNEL);
if (!link)
goto unlock;
}
@@ -3969,7 +3969,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
int ops_srcu_index;
int ret;
- tbs = kmalloc(sizeof(*tbs), GFP_KERNEL);
+ tbs = kmalloc_obj(*tbs, GFP_KERNEL);
if (!tbs)
return -ENOMEM;
diff --git a/net/core/scm.c b/net/core/scm.c
index cd87f66671aa..a29aa8fb8065 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -83,7 +83,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
if (!fpl)
{
- fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL_ACCOUNT);
+ fpl = kmalloc_obj(struct scm_fp_list, GFP_KERNEL_ACCOUNT);
if (!fpl)
return -ENOMEM;
*fplp = fpl;
diff --git a/net/core/selftests.c b/net/core/selftests.c
index 8b81feb82c4a..248112bd51a8 100644
--- a/net/core/selftests.c
+++ b/net/core/selftests.c
@@ -237,7 +237,7 @@ static int __net_test_loopback(struct net_device *ndev,
struct sk_buff *skb = NULL;
int ret = 0;
- tpriv = kzalloc(sizeof(*tpriv), GFP_KERNEL);
+ tpriv = kzalloc_obj(*tpriv, GFP_KERNEL);
if (!tpriv)
return -ENOMEM;
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index ddde93dd8bc6..2e26174c9919 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -522,7 +522,7 @@ static struct sk_msg *alloc_sk_msg(gfp_t gfp)
{
struct sk_msg *msg;
- msg = kzalloc(sizeof(*msg), gfp | __GFP_NOWARN);
+ msg = kzalloc_obj(*msg, gfp | __GFP_NOWARN);
if (unlikely(!msg))
return NULL;
sg_init_marker(msg->sg.data, NR_MSG_FRAG_IDS);
diff --git a/net/core/sock.c b/net/core/sock.c
index 693e6d80f501..b62e509e06d9 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1097,7 +1097,7 @@ sock_devmem_dontneed(struct sock *sk, sockptr_t optval, unsigned int optlen)
return -EINVAL;
num_tokens = optlen / sizeof(*tokens);
- tokens = kvmalloc_array(num_tokens, sizeof(*tokens), GFP_KERNEL);
+ tokens = kvmalloc_objs(*tokens, num_tokens, GFP_KERNEL);
if (!tokens)
return -ENOMEM;
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index 026ce9bd9e5e..c83335c62360 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -177,7 +177,7 @@ void sock_diag_broadcast_destroy(struct sock *sk)
{
/* Note, this function is often called from an interrupt context. */
struct broadcast_sk *bsk =
- kmalloc(sizeof(struct broadcast_sk), GFP_ATOMIC);
+ kmalloc_obj(struct broadcast_sk, GFP_ATOMIC);
if (!bsk)
return sk_destruct(sk);
bsk->sk = sk;
diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 5947b38e4f8b..b0e96337a269 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -1858,7 +1858,7 @@ int sock_map_link_create(const union bpf_attr *attr, struct bpf_prog *prog)
goto out;
}
- sockmap_link = kzalloc(sizeof(*sockmap_link), GFP_USER);
+ sockmap_link = kzalloc_obj(*sockmap_link, GFP_USER);
if (!sockmap_link) {
ret = -ENOMEM;
goto out;
diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
index 4211710393a8..29948cb44b7d 100644
--- a/net/core/sock_reuseport.c
+++ b/net/core/sock_reuseport.c
@@ -175,7 +175,7 @@ static struct sock_reuseport *__reuseport_alloc(unsigned int max_socks)
{
struct sock_reuseport *reuse;
- reuse = kzalloc(struct_size(reuse, socks, max_socks), GFP_ATOMIC);
+ reuse = kzalloc_flex(*reuse, socks, max_socks, GFP_ATOMIC);
if (!reuse)
return NULL;
diff --git a/net/core/xdp.c b/net/core/xdp.c
index fee6d080ee85..8c65d7dafd89 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -214,7 +214,7 @@ static int __mem_id_init_hash_table(void)
if (unlikely(mem_id_init))
return 0;
- rht = kzalloc(sizeof(*rht), GFP_KERNEL);
+ rht = kzalloc_obj(*rht, GFP_KERNEL);
if (!rht)
return -ENOMEM;
@@ -297,7 +297,7 @@ static struct xdp_mem_allocator *__xdp_reg_mem_model(struct xdp_mem_info *mem,
return ERR_PTR(ret);
}
- xdp_alloc = kzalloc(sizeof(*xdp_alloc), gfp);
+ xdp_alloc = kzalloc_obj(*xdp_alloc, gfp);
if (!xdp_alloc)
return ERR_PTR(-ENOMEM);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 03eb1d941fca..ff2198133213 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1021,8 +1021,7 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
*/
err = ops->peer_getappinfo(netdev, &info, &app_count);
if (!err && app_count) {
- table = kmalloc_array(app_count, sizeof(struct dcb_app),
- GFP_KERNEL);
+ table = kmalloc_objs(struct dcb_app, app_count, GFP_KERNEL);
if (!table)
return -ENOMEM;
@@ -2004,7 +2003,7 @@ static int dcb_app_add(struct list_head *list, const struct dcb_app *app,
{
struct dcb_app_type *entry;
- entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kmalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
return -ENOMEM;
diff --git a/net/devlink/core.c b/net/devlink/core.c
index da56e2b8afc1..44584f3613ca 100644
--- a/net/devlink/core.c
+++ b/net/devlink/core.c
@@ -111,7 +111,7 @@ static struct devlink_rel *devlink_rel_alloc(void)
static u32 next;
int err;
- rel = kzalloc(sizeof(*rel), GFP_KERNEL);
+ rel = kzalloc_obj(*rel, GFP_KERNEL);
if (!rel)
return ERR_PTR(-ENOMEM);
@@ -418,7 +418,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
if (!devlink_reload_actions_valid(ops))
return NULL;
- devlink = kvzalloc(struct_size(devlink, priv, priv_size), GFP_KERNEL);
+ devlink = kvzalloc_flex(*devlink, priv, priv_size, GFP_KERNEL);
if (!devlink)
return NULL;
diff --git a/net/devlink/dpipe.c b/net/devlink/dpipe.c
index e55701b007f0..3b86dc25e7f2 100644
--- a/net/devlink/dpipe.c
+++ b/net/devlink/dpipe.c
@@ -851,7 +851,7 @@ int devl_dpipe_table_register(struct devlink *devlink,
devlink))
return -EEXIST;
- table = kzalloc(sizeof(*table), GFP_KERNEL);
+ table = kzalloc_obj(*table, GFP_KERNEL);
if (!table)
return -ENOMEM;
diff --git a/net/devlink/health.c b/net/devlink/health.c
index 136a67c36a20..0578f7b460f5 100644
--- a/net/devlink/health.c
+++ b/net/devlink/health.c
@@ -32,7 +32,7 @@ static struct devlink_fmsg *devlink_fmsg_alloc(void)
{
struct devlink_fmsg *fmsg;
- fmsg = kzalloc(sizeof(*fmsg), GFP_KERNEL);
+ fmsg = kzalloc_obj(*fmsg, GFP_KERNEL);
if (!fmsg)
return NULL;
@@ -119,7 +119,7 @@ __devlink_health_reporter_create(struct devlink *devlink,
if (WARN_ON(ops->default_burst_period && !ops->default_graceful_period))
return ERR_PTR(-EINVAL);
- reporter = kzalloc(sizeof(*reporter), GFP_KERNEL);
+ reporter = kzalloc_obj(*reporter, GFP_KERNEL);
if (!reporter)
return ERR_PTR(-ENOMEM);
@@ -738,7 +738,7 @@ static void devlink_fmsg_nest_common(struct devlink_fmsg *fmsg, int attrtype)
if (fmsg->err)
return;
- item = kzalloc(sizeof(*item), GFP_KERNEL);
+ item = kzalloc_obj(*item, GFP_KERNEL);
if (!item) {
fmsg->err = -ENOMEM;
return;
diff --git a/net/devlink/linecard.c b/net/devlink/linecard.c
index 67f70a621d27..110f1347b9c6 100644
--- a/net/devlink/linecard.c
+++ b/net/devlink/linecard.c
@@ -404,8 +404,7 @@ static int devlink_linecard_types_init(struct devlink_linecard *linecard)
int i;
count = linecard->ops->types_count(linecard, linecard->priv);
- linecard->types = kmalloc_array(count, sizeof(*linecard_type),
- GFP_KERNEL);
+ linecard->types = kmalloc_objs(*linecard_type, count, GFP_KERNEL);
if (!linecard->types)
return -ENOMEM;
linecard->types_count = count;
@@ -451,7 +450,7 @@ devl_linecard_create(struct devlink *devlink, unsigned int linecard_index,
if (devlink_linecard_index_exists(devlink, linecard_index))
return ERR_PTR(-EEXIST);
- linecard = kzalloc(sizeof(*linecard), GFP_KERNEL);
+ linecard = kzalloc_obj(*linecard, GFP_KERNEL);
if (!linecard)
return ERR_PTR(-ENOMEM);
diff --git a/net/devlink/param.c b/net/devlink/param.c
index e0ea93eded43..74adb0fdb5f7 100644
--- a/net/devlink/param.c
+++ b/net/devlink/param.c
@@ -718,7 +718,7 @@ static int devlink_param_register(struct devlink *devlink,
else
WARN_ON(!param->get || !param->set);
- param_item = kzalloc(sizeof(*param_item), GFP_KERNEL);
+ param_item = kzalloc_obj(*param_item, GFP_KERNEL);
if (!param_item)
return -ENOMEM;
diff --git a/net/devlink/rate.c b/net/devlink/rate.c
index 0d68b5c477dc..8d8a688ad140 100644
--- a/net/devlink/rate.c
+++ b/net/devlink/rate.c
@@ -627,7 +627,7 @@ int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
else if (rate_node == ERR_PTR(-EINVAL))
return -EINVAL;
- rate_node = kzalloc(sizeof(*rate_node), GFP_KERNEL);
+ rate_node = kzalloc_obj(*rate_node, GFP_KERNEL);
if (!rate_node)
return -ENOMEM;
@@ -721,7 +721,7 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name,
if (!IS_ERR(rate_node))
return ERR_PTR(-EEXIST);
- rate_node = kzalloc(sizeof(*rate_node), GFP_KERNEL);
+ rate_node = kzalloc_obj(*rate_node, GFP_KERNEL);
if (!rate_node)
return ERR_PTR(-ENOMEM);
@@ -766,7 +766,7 @@ int devl_rate_leaf_create(struct devlink_port *devlink_port, void *priv,
if (WARN_ON(devlink_port->devlink_rate))
return -EBUSY;
- devlink_rate = kzalloc(sizeof(*devlink_rate), GFP_KERNEL);
+ devlink_rate = kzalloc_obj(*devlink_rate, GFP_KERNEL);
if (!devlink_rate)
return -ENOMEM;
diff --git a/net/devlink/region.c b/net/devlink/region.c
index d6e5805cf3a0..654e3766710f 100644
--- a/net/devlink/region.c
+++ b/net/devlink/region.c
@@ -428,7 +428,7 @@ __devlink_region_snapshot_create(struct devlink_region *region,
if (devlink_region_snapshot_get_by_id(region, snapshot_id))
return -EEXIST;
- snapshot = kzalloc(sizeof(*snapshot), GFP_KERNEL);
+ snapshot = kzalloc_obj(*snapshot, GFP_KERNEL);
if (!snapshot)
return -ENOMEM;
@@ -1055,7 +1055,7 @@ struct devlink_region *devl_region_create(struct devlink *devlink,
if (devlink_region_get_by_name(devlink, ops->name))
return ERR_PTR(-EEXIST);
- region = kzalloc(sizeof(*region), GFP_KERNEL);
+ region = kzalloc_obj(*region, GFP_KERNEL);
if (!region)
return ERR_PTR(-ENOMEM);
@@ -1128,7 +1128,7 @@ devlink_port_region_create(struct devlink_port *port,
goto unlock;
}
- region = kzalloc(sizeof(*region), GFP_KERNEL);
+ region = kzalloc_obj(*region, GFP_KERNEL);
if (!region) {
err = -ENOMEM;
goto unlock;
diff --git a/net/devlink/resource.c b/net/devlink/resource.c
index 2d6324f3d91f..aa3621c28a00 100644
--- a/net/devlink/resource.c
+++ b/net/devlink/resource.c
@@ -347,7 +347,7 @@ int devl_resource_register(struct devlink *devlink,
if (resource)
return -EEXIST;
- resource = kzalloc(sizeof(*resource), GFP_KERNEL);
+ resource = kzalloc_obj(*resource, GFP_KERNEL);
if (!resource)
return -ENOMEM;
diff --git a/net/devlink/sb.c b/net/devlink/sb.c
index 0a76bb32502b..bcfeed079433 100644
--- a/net/devlink/sb.c
+++ b/net/devlink/sb.c
@@ -943,7 +943,7 @@ int devl_sb_register(struct devlink *devlink, unsigned int sb_index,
if (devlink_sb_index_exists(devlink, sb_index))
return -EEXIST;
- devlink_sb = kzalloc(sizeof(*devlink_sb), GFP_KERNEL);
+ devlink_sb = kzalloc_obj(*devlink_sb, GFP_KERNEL);
if (!devlink_sb)
return -ENOMEM;
devlink_sb->index = sb_index;
diff --git a/net/devlink/trap.c b/net/devlink/trap.c
index f36087f90db5..e4255c0a6a30 100644
--- a/net/devlink/trap.c
+++ b/net/devlink/trap.c
@@ -1271,7 +1271,7 @@ devlink_trap_register(struct devlink *devlink,
if (devlink_trap_item_lookup(devlink, trap->name))
return -EEXIST;
- trap_item = kzalloc(sizeof(*trap_item), GFP_KERNEL);
+ trap_item = kzalloc_obj(*trap_item, GFP_KERNEL);
if (!trap_item)
return -ENOMEM;
@@ -1545,7 +1545,7 @@ devlink_trap_group_register(struct devlink *devlink,
if (devlink_trap_group_item_lookup(devlink, group->name))
return -EEXIST;
- group_item = kzalloc(sizeof(*group_item), GFP_KERNEL);
+ group_item = kzalloc_obj(*group_item, GFP_KERNEL);
if (!group_item)
return -ENOMEM;
@@ -1751,7 +1751,7 @@ devlink_trap_policer_register(struct devlink *devlink,
if (devlink_trap_policer_item_lookup(devlink, policer->id))
return -EEXIST;
- policer_item = kzalloc(sizeof(*policer_item), GFP_KERNEL);
+ policer_item = kzalloc_obj(*policer_item, GFP_KERNEL);
if (!policer_item)
return -ENOMEM;
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 35ce3941fae3..b0ae980ca684 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -213,7 +213,7 @@ static struct dsa_switch_tree *dsa_tree_alloc(int index)
{
struct dsa_switch_tree *dst;
- dst = kzalloc(sizeof(*dst), GFP_KERNEL);
+ dst = kzalloc_obj(*dst, GFP_KERNEL);
if (!dst)
return NULL;
@@ -298,7 +298,7 @@ static struct dsa_link *dsa_link_touch(struct dsa_port *dp,
if (dl->dp == dp && dl->link_dp == link_dp)
return dl;
- dl = kzalloc(sizeof(*dl), GFP_KERNEL);
+ dl = kzalloc_obj(*dl, GFP_KERNEL);
if (!dl)
return NULL;
@@ -844,7 +844,7 @@ static int dsa_tree_setup_lags(struct dsa_switch_tree *dst)
if (!len)
return 0;
- dst->lags = kcalloc(len, sizeof(*dst->lags), GFP_KERNEL);
+ dst->lags = kzalloc_objs(*dst->lags, len, GFP_KERNEL);
if (!dst->lags)
return -ENOMEM;
@@ -1092,7 +1092,7 @@ static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index)
if (dp->index == index)
return dp;
- dp = kzalloc(sizeof(*dp), GFP_KERNEL);
+ dp = kzalloc_obj(*dp, GFP_KERNEL);
if (!dp)
return NULL;
diff --git a/net/dsa/port.c b/net/dsa/port.c
index ca3a7f52229b..4da911edc512 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -431,7 +431,7 @@ static int dsa_port_bridge_create(struct dsa_port *dp,
return 0;
}
- bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
+ bridge = kzalloc_obj(*bridge, GFP_KERNEL);
if (!bridge)
return -ENOMEM;
@@ -617,7 +617,7 @@ static int dsa_port_lag_create(struct dsa_port *dp,
return 0;
}
- lag = kzalloc(sizeof(*lag), GFP_KERNEL);
+ lag = kzalloc_obj(*lag, GFP_KERNEL);
if (!lag)
return -ENOMEM;
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 3d2feeea897b..e00997977c93 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -182,7 +182,7 @@ static int dsa_port_do_mdb_add(struct dsa_port *dp,
goto out;
}
- a = kzalloc(sizeof(*a), GFP_KERNEL);
+ a = kzalloc_obj(*a, GFP_KERNEL);
if (!a) {
err = -ENOMEM;
goto out;
@@ -280,7 +280,7 @@ static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr,
goto out;
}
- a = kzalloc(sizeof(*a), GFP_KERNEL);
+ a = kzalloc_obj(*a, GFP_KERNEL);
if (!a) {
err = -ENOMEM;
goto out;
@@ -368,7 +368,7 @@ static int dsa_switch_do_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag *lag,
goto out;
}
- a = kzalloc(sizeof(*a), GFP_KERNEL);
+ a = kzalloc_obj(*a, GFP_KERNEL);
if (!a) {
err = -ENOMEM;
goto out;
@@ -719,7 +719,7 @@ static int dsa_port_do_vlan_add(struct dsa_port *dp,
goto out;
}
- v = kzalloc(sizeof(*v), GFP_KERNEL);
+ v = kzalloc_obj(*v, GFP_KERNEL);
if (!v) {
err = -ENOMEM;
goto out;
diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c
index 53e03fd8071b..c9bea6808da3 100644
--- a/net/dsa/tag_8021q.c
+++ b/net/dsa/tag_8021q.c
@@ -158,7 +158,7 @@ static int dsa_port_do_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid,
return 0;
}
- v = kzalloc(sizeof(*v), GFP_KERNEL);
+ v = kzalloc_obj(*v, GFP_KERNEL);
if (!v)
return -ENOMEM;
@@ -420,7 +420,7 @@ int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto)
struct dsa_8021q_context *ctx;
int err;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index 9170a0148cc4..15aa44478807 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -62,7 +62,7 @@ static int ksz_connect(struct dsa_switch *ds)
struct ksz_tagger_private *priv;
int ret;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -258,7 +258,7 @@ static struct sk_buff *ksz_defer_xmit(struct dsa_port *dp, struct sk_buff *skb)
if (!xmit_work_fn || !xmit_worker)
return NULL;
- xmit_work = kzalloc(sizeof(*xmit_work), GFP_ATOMIC);
+ xmit_work = kzalloc_obj(*xmit_work, GFP_ATOMIC);
if (!xmit_work)
return NULL;
diff --git a/net/dsa/tag_ocelot_8021q.c b/net/dsa/tag_ocelot_8021q.c
index 3929584791e4..b9bf2895309a 100644
--- a/net/dsa/tag_ocelot_8021q.c
+++ b/net/dsa/tag_ocelot_8021q.c
@@ -43,7 +43,7 @@ static struct sk_buff *ocelot_defer_xmit(struct dsa_port *dp,
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
return NULL;
- xmit_work = kzalloc(sizeof(*xmit_work), GFP_ATOMIC);
+ xmit_work = kzalloc_obj(*xmit_work, GFP_ATOMIC);
if (!xmit_work)
return NULL;
@@ -106,7 +106,7 @@ static int ocelot_connect(struct dsa_switch *ds)
struct ocelot_8021q_tagger_private *priv;
int err;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c
index 6d56a28c914c..4326487c1f29 100644
--- a/net/dsa/tag_qca.c
+++ b/net/dsa/tag_qca.c
@@ -92,7 +92,7 @@ static int qca_tag_connect(struct dsa_switch *ds)
{
struct qca_tagger_data *tagger_data;
- tagger_data = kzalloc(sizeof(*tagger_data), GFP_KERNEL);
+ tagger_data = kzalloc_obj(*tagger_data, GFP_KERNEL);
if (!tagger_data)
return -ENOMEM;
diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c
index 02adec693811..2083ef3b4b90 100644
--- a/net/dsa/tag_sja1105.c
+++ b/net/dsa/tag_sja1105.c
@@ -152,7 +152,7 @@ static struct sk_buff *sja1105_defer_xmit(struct dsa_port *dp,
if (!xmit_work_fn || !xmit_worker)
return NULL;
- xmit_work = kzalloc(sizeof(*xmit_work), GFP_ATOMIC);
+ xmit_work = kzalloc_obj(*xmit_work, GFP_ATOMIC);
if (!xmit_work)
return NULL;
@@ -701,7 +701,7 @@ static int sja1105_connect(struct dsa_switch *ds)
struct kthread_worker *xmit_worker;
int err;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
diff --git a/net/dsa/user.c b/net/dsa/user.c
index 5697291d43cf..5df8cb69295d 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -147,7 +147,7 @@ static int dsa_user_schedule_standalone_work(struct net_device *dev,
{
struct dsa_standalone_event_work *standalone_work;
- standalone_work = kzalloc(sizeof(*standalone_work), GFP_ATOMIC);
+ standalone_work = kzalloc_obj(*standalone_work, GFP_ATOMIC);
if (!standalone_work)
return -ENOMEM;
@@ -1318,7 +1318,7 @@ static int dsa_user_netpoll_setup(struct net_device *dev)
struct netpoll *netpoll;
int err = 0;
- netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);
+ netpoll = kzalloc_obj(*netpoll, GFP_KERNEL);
if (!netpoll)
return -ENOMEM;
@@ -1430,7 +1430,7 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev,
return -EOPNOTSUPP;
}
- mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
+ mall_tc_entry = kzalloc_obj(*mall_tc_entry, GFP_KERNEL);
if (!mall_tc_entry)
return -ENOMEM;
@@ -1490,7 +1490,7 @@ dsa_user_add_cls_matchall_police(struct net_device *dev,
act = &cls->rule->action.entries[0];
- mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL);
+ mall_tc_entry = kzalloc_obj(*mall_tc_entry, GFP_KERNEL);
if (!mall_tc_entry)
return -ENOMEM;
@@ -1823,7 +1823,7 @@ static int dsa_user_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
!dsa_switch_supports_mc_filtering(ds))
return 0;
- v = kzalloc(sizeof(*v), GFP_KERNEL);
+ v = kzalloc_obj(*v, GFP_KERNEL);
if (!v) {
ret = -ENOMEM;
goto rollback;
@@ -2070,7 +2070,7 @@ static void dsa_bridge_mtu_normalization(struct dsa_port *dp)
if (min_mtu > user->mtu)
min_mtu = user->mtu;
- hw_port = kzalloc(sizeof(*hw_port), GFP_KERNEL);
+ hw_port = kzalloc_obj(*hw_port, GFP_KERNEL);
if (!hw_port)
goto out;
@@ -3738,7 +3738,7 @@ static int dsa_user_fdb_event(struct net_device *dev,
return -EOPNOTSUPP;
}
- switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
+ switchdev_work = kzalloc_obj(*switchdev_work, GFP_ATOMIC);
if (!switchdev_work)
return -ENOMEM;
diff --git a/net/ethtool/cmis_cdb.c b/net/ethtool/cmis_cdb.c
index 3057576bc81e..674439bedd49 100644
--- a/net/ethtool/cmis_cdb.c
+++ b/net/ethtool/cmis_cdb.c
@@ -276,7 +276,7 @@ ethtool_cmis_cdb_init(struct net_device *dev,
struct ethtool_cmis_cdb *cdb;
int err;
- cdb = kzalloc(sizeof(*cdb), GFP_KERNEL);
+ cdb = kzalloc_obj(*cdb, GFP_KERNEL);
if (!cdb)
return ERR_PTR(-ENOMEM);
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 5fae329795c8..7a302a93f52c 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -687,7 +687,7 @@ static int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max)
if (rule_cnt <= 0)
return -EINVAL;
- info = kvzalloc(struct_size(info, rule_locs, rule_cnt), GFP_KERNEL);
+ info = kvzalloc_flex(*info, rule_locs, rule_cnt, GFP_KERNEL);
if (!info)
return -ENOMEM;
@@ -770,7 +770,7 @@ static u32 ethtool_get_max_rxfh_channel(struct net_device *dev)
if (dev_size == 0)
return current_max;
- rxfh.indir = kcalloc(dev_size, sizeof(rxfh.indir[0]), GFP_USER);
+ rxfh.indir = kzalloc_objs(rxfh.indir[0], dev_size, GFP_USER);
if (!rxfh.indir)
return U32_MAX;
@@ -841,7 +841,7 @@ int ethtool_check_rss_ctx_busy(struct net_device *dev, u32 rss_context)
if (rule_cnt < 0)
return -EINVAL;
- info = kvzalloc(struct_size(info, rule_locs, rule_cnt), GFP_KERNEL);
+ info = kvzalloc_flex(*info, rule_locs, rule_cnt, GFP_KERNEL);
if (!info)
return -ENOMEM;
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 9431e305b233..b4e7c6ccf9f3 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -3040,7 +3040,7 @@ ethtool_set_per_queue_coalesce(struct net_device *dev,
bitmap_from_arr32(queue_mask, per_queue_opt->queue_mask, MAX_NUM_QUEUE);
n_queue = bitmap_weight(queue_mask, MAX_NUM_QUEUE);
- tmp = backup = kmalloc_array(n_queue, sizeof(*backup), GFP_KERNEL);
+ tmp = backup = kmalloc_objs(*backup, n_queue, GFP_KERNEL);
if (!backup)
return -ENOMEM;
@@ -3554,7 +3554,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr)
if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
return -EFAULT;
- state = kzalloc(sizeof(*state), GFP_KERNEL);
+ state = kzalloc_obj(*state, GFP_KERNEL);
if (!state)
return -ENOMEM;
diff --git a/net/ethtool/module.c b/net/ethtool/module.c
index 4d4e0a82579a..d033a20aa48c 100644
--- a/net/ethtool/module.c
+++ b/net/ethtool/module.c
@@ -301,7 +301,7 @@ module_flash_fw_schedule(struct net_device *dev, const char *file_name,
struct ethtool_module_fw_flash *module_fw;
int err;
- module_fw = kzalloc(sizeof(*module_fw), GFP_KERNEL);
+ module_fw = kzalloc_obj(*module_fw, GFP_KERNEL);
if (!module_fw)
return -ENOMEM;
diff --git a/net/ethtool/mse.c b/net/ethtool/mse.c
index 6aac004c3ffc..4de15aad543b 100644
--- a/net/ethtool/mse.c
+++ b/net/ethtool/mse.c
@@ -64,8 +64,8 @@ static int mse_get_channels(struct phy_device *phydev,
if (!data->capability.supported_caps)
return 0;
- data->snapshots = kcalloc(PHY_MSE_CHANNEL_COUNT,
- sizeof(*data->snapshots), GFP_KERNEL);
+ data->snapshots = kzalloc_objs(*data->snapshots, PHY_MSE_CHANNEL_COUNT,
+ GFP_KERNEL);
if (!data->snapshots)
return -ENOMEM;
diff --git a/net/ethtool/tsconfig.c b/net/ethtool/tsconfig.c
index 169b413b31fc..acd0477b3a2d 100644
--- a/net/ethtool/tsconfig.c
+++ b/net/ethtool/tsconfig.c
@@ -202,10 +202,10 @@ static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info)
int reply_len = 0;
int ret;
- req_info = kzalloc(sizeof(*req_info), GFP_KERNEL);
+ req_info = kzalloc_obj(*req_info, GFP_KERNEL);
if (!req_info)
return -ENOMEM;
- reply_data = kmalloc(sizeof(*reply_data), GFP_KERNEL);
+ reply_data = kmalloc_obj(*reply_data, GFP_KERNEL);
if (!reply_data) {
kfree(req_info);
return -ENOMEM;
@@ -280,7 +280,7 @@ tsconfig_set_hwprov_from_desc(struct net_device *dev,
source = HWTSTAMP_SOURCE_PHYLIB;
}
- hwprov = kzalloc(sizeof(*hwprov), GFP_KERNEL);
+ hwprov = kzalloc_obj(*hwprov, GFP_KERNEL);
if (!hwprov)
return ERR_PTR(-ENOMEM);
diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c
index 8c654caa6805..df9c7de9a640 100644
--- a/net/ethtool/tsinfo.c
+++ b/net/ethtool/tsinfo.c
@@ -505,10 +505,10 @@ int ethnl_tsinfo_start(struct netlink_callback *cb)
BUILD_BUG_ON(sizeof(*ctx) > sizeof(cb->ctx));
- req_info = kzalloc(sizeof(*req_info), GFP_KERNEL);
+ req_info = kzalloc_obj(*req_info, GFP_KERNEL);
if (!req_info)
return -ENOMEM;
- reply_data = kzalloc(sizeof(*reply_data), GFP_KERNEL);
+ reply_data = kzalloc_obj(*reply_data, GFP_KERNEL);
if (!reply_data) {
ret = -ENOMEM;
goto free_req_info;
diff --git a/net/handshake/request.c b/net/handshake/request.c
index 6b7e3e0bf399..2829adbeb149 100644
--- a/net/handshake/request.c
+++ b/net/handshake/request.c
@@ -119,7 +119,7 @@ struct handshake_req *handshake_req_alloc(const struct handshake_proto *proto,
if (!proto->hp_accept || !proto->hp_done)
return NULL;
- req = kzalloc(struct_size(req, hr_priv, proto->hp_privsize), flags);
+ req = kzalloc_flex(*req, hr_priv, proto->hp_privsize, flags);
if (!req)
return NULL;
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index 7d87f304ded4..d5a742cb77d1 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -80,7 +80,7 @@ int hsr_create_self_node(struct hsr_priv *hsr,
{
struct hsr_self_node *sn, *old;
- sn = kmalloc(sizeof(*sn), GFP_KERNEL);
+ sn = kmalloc_obj(*sn, GFP_KERNEL);
if (!sn)
return -ENOMEM;
@@ -159,7 +159,7 @@ static struct hsr_node *hsr_add_node(struct hsr_priv *hsr,
size_t block_sz;
int i;
- new_node = kzalloc(sizeof(*new_node), GFP_ATOMIC);
+ new_node = kzalloc_obj(*new_node, GFP_ATOMIC);
if (!new_node)
return NULL;
diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
index afe06ba00ea4..9a3f3add4b47 100644
--- a/net/hsr/hsr_slave.c
+++ b/net/hsr/hsr_slave.c
@@ -198,7 +198,7 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
if (port)
return -EBUSY; /* This port already exists */
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return -ENOMEM;
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 5a024ca60d35..f743d1568f3f 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -603,7 +603,7 @@ nl802154_dump_wpan_phy(struct sk_buff *skb, struct netlink_callback *cb)
rtnl_lock();
if (!state) {
- state = kzalloc(sizeof(*state), GFP_KERNEL);
+ state = kzalloc_obj(*state, GFP_KERNEL);
if (!state) {
rtnl_unlock();
return -ENOMEM;
@@ -1418,7 +1418,7 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)
return -EOPNOTSUPP;
}
- request = kzalloc(sizeof(*request), GFP_KERNEL);
+ request = kzalloc_obj(*request, GFP_KERNEL);
if (!request)
return -ENOMEM;
@@ -1586,7 +1586,7 @@ nl802154_send_beacons(struct sk_buff *skb, struct genl_info *info)
return -EOPNOTSUPP;
}
- request = kzalloc(sizeof(*request), GFP_KERNEL);
+ request = kzalloc_obj(*request, GFP_KERNEL);
if (!request)
return -ENOMEM;
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 08d811f11896..6e62e80236a4 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1737,8 +1737,8 @@ static __net_init int ipv4_mib_init_net(struct net *net)
net->mib.icmp_statistics = alloc_percpu(struct icmp_mib);
if (!net->mib.icmp_statistics)
goto err_icmp_mib;
- net->mib.icmpmsg_statistics = kzalloc(sizeof(struct icmpmsg_mib),
- GFP_KERNEL);
+ net->mib.icmpmsg_statistics = kzalloc_obj(struct icmpmsg_mib,
+ GFP_KERNEL);
if (!net->mib.icmpmsg_statistics)
goto err_icmpmsg_mib;
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 64aec3dff8ec..f4a207c7cfc6 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -484,7 +484,7 @@ static int ah_init_state(struct xfrm_state *x, struct netlink_ext_ack *extack)
goto error;
}
- ahp = kzalloc(sizeof(*ahp), GFP_KERNEL);
+ ahp = kzalloc_obj(*ahp, GFP_KERNEL);
if (!ahp)
return -ENOMEM;
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 32b951ebc0c2..3fb181a3f3c0 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -168,9 +168,8 @@ static int __init cipso_v4_cache_init(void)
{
u32 iter;
- cipso_v4_cache = kcalloc(CIPSO_V4_CACHE_BUCKETS,
- sizeof(struct cipso_v4_map_cache_bkt),
- GFP_KERNEL);
+ cipso_v4_cache = kzalloc_objs(struct cipso_v4_map_cache_bkt,
+ CIPSO_V4_CACHE_BUCKETS, GFP_KERNEL);
if (!cipso_v4_cache)
return -ENOMEM;
@@ -308,7 +307,7 @@ int cipso_v4_cache_add(const unsigned char *cipso_ptr,
cipso_ptr_len = cipso_ptr[1];
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
return -ENOMEM;
entry->key = kmemdup(cipso_ptr, cipso_ptr_len, GFP_ATOMIC);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 942a887bf089..9fd41dfbe788 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -209,7 +209,7 @@ static struct in_ifaddr *inet_alloc_ifa(struct in_device *in_dev)
{
struct in_ifaddr *ifa;
- ifa = kzalloc(sizeof(*ifa), GFP_KERNEL_ACCOUNT);
+ ifa = kzalloc_obj(*ifa, GFP_KERNEL_ACCOUNT);
if (!ifa)
return NULL;
@@ -270,7 +270,7 @@ static struct in_device *inetdev_init(struct net_device *dev)
ASSERT_RTNL();
- in_dev = kzalloc(sizeof(*in_dev), GFP_KERNEL);
+ in_dev = kzalloc_obj(*in_dev, GFP_KERNEL);
if (!in_dev)
goto out;
memcpy(&in_dev->cnf, dev_net(dev)->ipv4.devconf_dflt,
@@ -2754,9 +2754,8 @@ static __net_init int devinet_init_net(struct net *net)
int i;
err = -ENOMEM;
- net->ipv4.inet_addr_lst = kmalloc_array(IN4_ADDR_HSIZE,
- sizeof(struct hlist_head),
- GFP_KERNEL);
+ net->ipv4.inet_addr_lst = kmalloc_objs(struct hlist_head,
+ IN4_ADDR_HSIZE, GFP_KERNEL);
if (!net->ipv4.inet_addr_lst)
goto err_alloc_hash;
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 0caf38e44c73..ceef080112a9 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -365,8 +365,8 @@ static struct hlist_head *fib_info_laddrhash_bucket(const struct net *net,
static struct hlist_head *fib_info_hash_alloc(unsigned int hash_bits)
{
/* The second half is used for prefsrc */
- return kvcalloc((1 << hash_bits) * 2, sizeof(struct hlist_head),
- GFP_KERNEL);
+ return kvzalloc_objs(struct hlist_head, (1 << hash_bits) * 2,
+ GFP_KERNEL);
}
static void fib_info_hash_free(struct hlist_head *head)
@@ -1399,7 +1399,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
fib_info_hash_grow(net);
- fi = kzalloc(struct_size(fi, fib_nh, nhs), GFP_KERNEL);
+ fi = kzalloc_flex(*fi, fib_nh, nhs, GFP_KERNEL);
if (!fi) {
err = -ENOBUFS;
goto failure;
diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c
index ab8f309f8925..885f3b06f6e9 100644
--- a/net/ipv4/fou_core.c
+++ b/net/ipv4/fou_core.c
@@ -581,7 +581,7 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
goto error;
/* Allocate FOU port structure */
- fou = kzalloc(sizeof(*fou), GFP_KERNEL);
+ fou = kzalloc_obj(*fou, GFP_KERNEL);
if (!fou) {
err = -ENOMEM;
goto error;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 0adc993c211d..a674fb44ec25 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1187,7 +1187,7 @@ static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im,
* for deleted items allows change reports to use common code with
* non-deleted or query-response MCA's.
*/
- pmc = kzalloc(sizeof(*pmc), gfp);
+ pmc = kzalloc_obj(*pmc, gfp);
if (!pmc)
return;
spin_lock_init(&pmc->lock);
@@ -1532,7 +1532,7 @@ static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
goto out;
}
- im = kzalloc(sizeof(*im), gfp);
+ im = kzalloc_obj(*im, gfp);
if (!im)
goto out;
@@ -2075,7 +2075,7 @@ static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode,
psf_prev = psf;
}
if (!psf) {
- psf = kzalloc(sizeof(*psf), GFP_ATOMIC);
+ psf = kzalloc_obj(*psf, GFP_ATOMIC);
if (!psf)
return -ENOBUFS;
psf->sf_inaddr = *psfsrc;
@@ -2150,7 +2150,7 @@ static int sf_setstate(struct ip_mc_list *pmc)
if (dpsf->sf_inaddr == psf->sf_inaddr)
break;
if (!dpsf) {
- dpsf = kmalloc(sizeof(*dpsf), GFP_ATOMIC);
+ dpsf = kmalloc_obj(*dpsf, GFP_ATOMIC);
if (!dpsf)
continue;
*dpsf = *psf;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 3f5b1418a610..89f99c7ee69e 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -845,7 +845,7 @@ static int __inet_diag_dump_start(struct netlink_callback *cb, int hdrlen)
struct nlattr *nla;
int err;
- cb_data = kzalloc(sizeof(*cb_data), GFP_KERNEL);
+ cb_data = kzalloc_obj(*cb_data, GFP_KERNEL);
if (!cb_data)
return -ENOMEM;
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 4e6d7467ed44..b006606ebb1d 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -188,7 +188,7 @@ static void fqdir_work_fn(struct work_struct *work)
int fqdir_init(struct fqdir **fqdirp, struct inet_frags *f, struct net *net)
{
- struct fqdir *fqdir = kzalloc(sizeof(*fqdir), GFP_KERNEL);
+ struct fqdir *fqdir = kzalloc_obj(*fqdir, GFP_KERNEL);
int res;
if (!fqdir)
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index f5826ec4bcaa..50bf4ec8213a 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -1284,7 +1284,7 @@ void __init inet_hashinfo2_init(struct inet_hashinfo *h, const char *name,
int inet_hashinfo2_init_mod(struct inet_hashinfo *h)
{
- h->lhash2 = kmalloc_array(INET_LHTABLE_SIZE, sizeof(*h->lhash2), GFP_KERNEL);
+ h->lhash2 = kmalloc_objs(*h->lhash2, INET_LHTABLE_SIZE, GFP_KERNEL);
if (!h->lhash2)
return -ENOMEM;
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index c062d9519818..d09377780942 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -350,7 +350,7 @@ int ip_ra_control(struct sock *sk, unsigned char on,
if (sk->sk_type != SOCK_RAW || inet_sk(sk)->inet_num == IPPROTO_RAW)
return -EINVAL;
- new_ra = on ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
+ new_ra = on ? kmalloc_obj(*new_ra, GFP_KERNEL) : NULL;
if (on && !new_ra)
return -ENOMEM;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index b1e1be00ff8b..5dcac1fb4209 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -244,7 +244,7 @@ static int __init ic_open_devs(void)
dev->name);
continue;
}
- if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
+ if (!(d = kmalloc_obj(struct ic_device, GFP_KERNEL))) {
rtnl_unlock();
return -ENOMEM;
}
diff --git a/net/ipv4/ipmr_base.c b/net/ipv4/ipmr_base.c
index 28d77d454d44..77b7717b9c14 100644
--- a/net/ipv4/ipmr_base.c
+++ b/net/ipv4/ipmr_base.c
@@ -38,7 +38,7 @@ mr_table_alloc(struct net *net, u32 id,
struct mr_table *mrt;
int err;
- mrt = kzalloc(sizeof(*mrt), GFP_KERNEL);
+ mrt = kzalloc_obj(*mrt, GFP_KERNEL);
if (!mrt)
return ERR_PTR(-ENOMEM);
mrt->id = id;
diff --git a/net/ipv4/metrics.c b/net/ipv4/metrics.c
index 82cf8a9e5ded..8b88d674a1ea 100644
--- a/net/ipv4/metrics.c
+++ b/net/ipv4/metrics.c
@@ -73,7 +73,7 @@ struct dst_metrics *ip_fib_metrics_init(struct nlattr *fc_mx,
if (!fc_mx)
return (struct dst_metrics *)&dst_default_metrics;
- fib_metrics = kzalloc(sizeof(*fib_metrics), GFP_KERNEL);
+ fib_metrics = kzalloc_obj(*fib_metrics, GFP_KERNEL);
if (unlikely(!fib_metrics))
return ERR_PTR(-ENOMEM);
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 7b9d70f9b31c..36b52a92e999 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -116,7 +116,7 @@ static int nh_notifier_single_info_init(struct nh_notifier_info *info,
struct nh_info *nhi = rtnl_dereference(nh->nh_info);
info->type = NH_NOTIFIER_INFO_TYPE_SINGLE;
- info->nh = kzalloc(sizeof(*info->nh), GFP_KERNEL);
+ info->nh = kzalloc_obj(*info->nh, GFP_KERNEL);
if (!info->nh)
return -ENOMEM;
@@ -137,8 +137,8 @@ static int nh_notifier_mpath_info_init(struct nh_notifier_info *info,
int i;
info->type = NH_NOTIFIER_INFO_TYPE_GRP;
- info->nh_grp = kzalloc(struct_size(info->nh_grp, nh_entries, num_nh),
- GFP_KERNEL);
+ info->nh_grp = kzalloc_flex(*info->nh_grp, nh_entries, num_nh,
+ GFP_KERNEL);
if (!info->nh_grp)
return -ENOMEM;
@@ -318,8 +318,7 @@ static int nh_notifier_res_bucket_info_init(struct nh_notifier_info *info,
return err;
info->type = NH_NOTIFIER_INFO_TYPE_RES_BUCKET;
- info->nh_res_bucket = kzalloc(sizeof(*info->nh_res_bucket),
- GFP_KERNEL);
+ info->nh_res_bucket = kzalloc_obj(*info->nh_res_bucket, GFP_KERNEL);
if (!info->nh_res_bucket)
return -ENOMEM;
@@ -535,7 +534,7 @@ static struct nexthop *nexthop_alloc(void)
{
struct nexthop *nh;
- nh = kzalloc(sizeof(struct nexthop), GFP_KERNEL);
+ nh = kzalloc_obj(struct nexthop, GFP_KERNEL);
if (nh) {
INIT_LIST_HEAD(&nh->fi_list);
INIT_LIST_HEAD(&nh->f6i_list);
@@ -550,7 +549,7 @@ static struct nh_group *nexthop_grp_alloc(u16 num_nh)
{
struct nh_group *nhg;
- nhg = kzalloc(struct_size(nhg, nh_entries, num_nh), GFP_KERNEL);
+ nhg = kzalloc_flex(*nhg, nh_entries, num_nh, GFP_KERNEL);
if (nhg)
nhg->num_nh = num_nh;
@@ -715,9 +714,8 @@ static int nh_notifier_grp_hw_stats_init(struct nh_notifier_info *info,
info->id = nh->id;
info->type = NH_NOTIFIER_INFO_TYPE_GRP_HW_STATS;
- info->nh_grp_hw_stats = kzalloc(struct_size(info->nh_grp_hw_stats,
- stats, nhg->num_nh),
- GFP_KERNEL);
+ info->nh_grp_hw_stats = kzalloc_flex(*info->nh_grp_hw_stats, stats,
+ nhg->num_nh, GFP_KERNEL);
if (!info->nh_grp_hw_stats)
return -ENOMEM;
@@ -2897,7 +2895,7 @@ static struct nexthop *nexthop_create(struct net *net, struct nh_config *cfg,
if (!nh)
return ERR_PTR(-ENOMEM);
- nhi = kzalloc(sizeof(*nhi), GFP_KERNEL);
+ nhi = kzalloc_obj(*nhi, GFP_KERNEL);
if (!nhi) {
kfree(nh);
return ERR_PTR(-ENOMEM);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 06aa39ae80d6..c75b92f60742 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -315,7 +315,7 @@ static int rt_acct_proc_show(struct seq_file *m, void *v)
struct ip_rt_acct *dst, *src;
unsigned int i, j;
- dst = kcalloc(256, sizeof(struct ip_rt_acct), GFP_KERNEL);
+ dst = kzalloc_objs(struct ip_rt_acct, 256, GFP_KERNEL);
if (!dst)
return -ENOMEM;
@@ -659,7 +659,7 @@ static void update_or_create_fnhe(struct fib_nh_common *nhc, __be32 daddr,
hash = rcu_dereference(nhc->nhc_exceptions);
if (!hash) {
- hash = kcalloc(FNHE_HASH_SIZE, sizeof(*hash), GFP_ATOMIC);
+ hash = kzalloc_objs(*hash, FNHE_HASH_SIZE, GFP_ATOMIC);
if (!hash)
goto out_unlock;
rcu_assign_pointer(nhc->nhc_exceptions, hash);
@@ -702,7 +702,7 @@ static void update_or_create_fnhe(struct fib_nh_common *nhc, __be32 daddr,
depth--;
}
- fnhe = kzalloc(sizeof(*fnhe), GFP_ATOMIC);
+ fnhe = kzalloc_obj(*fnhe, GFP_ATOMIC);
if (!fnhe)
goto out_unlock;
@@ -3687,7 +3687,7 @@ static __net_initdata struct pernet_operations rt_genid_ops = {
static int __net_init ipv4_inetpeer_init(struct net *net)
{
- struct inet_peer_base *bp = kmalloc(sizeof(*bp), GFP_KERNEL);
+ struct inet_peer_base *bp = kmalloc_obj(*bp, GFP_KERNEL);
if (!bp)
return -ENOMEM;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 6ce03a9adb4a..f84d9a45cc9d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1077,8 +1077,8 @@ int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *copied,
if (tp->fastopen_req)
return -EALREADY; /* Another Fast Open is in progress */
- tp->fastopen_req = kzalloc(sizeof(struct tcp_fastopen_request),
- sk->sk_allocation);
+ tp->fastopen_req = kzalloc_obj(struct tcp_fastopen_request,
+ sk->sk_allocation);
if (unlikely(!tp->fastopen_req))
return -ENOBUFS;
tp->fastopen_req->data = msg;
diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c
index 34b8450829d0..4980caddb0fc 100644
--- a/net/ipv4/tcp_ao.c
+++ b/net/ipv4/tcp_ao.c
@@ -227,7 +227,7 @@ static struct tcp_ao_info *tcp_ao_alloc_info(gfp_t flags)
{
struct tcp_ao_info *ao;
- ao = kzalloc(sizeof(*ao), flags);
+ ao = kzalloc_obj(*ao, flags);
if (!ao)
return NULL;
INIT_HLIST_HEAD(&ao->head);
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index ca8a5cb8e569..c449a044895e 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -39,7 +39,7 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
struct sk_msg *tmp;
int i, ret = 0;
- tmp = kzalloc(sizeof(*tmp), __GFP_NOWARN | GFP_KERNEL);
+ tmp = kzalloc_obj(*tmp, __GFP_NOWARN | GFP_KERNEL);
if (unlikely(!tmp))
return -ENOMEM;
@@ -426,8 +426,8 @@ more_data:
msg->cork_bytes > msg->sg.size && !enospc) {
psock->cork_bytes = msg->cork_bytes - msg->sg.size;
if (!psock->cork) {
- psock->cork = kzalloc(sizeof(*psock->cork),
- GFP_ATOMIC | __GFP_NOWARN);
+ psock->cork = kzalloc_obj(*psock->cork,
+ GFP_ATOMIC | __GFP_NOWARN);
if (!psock->cork) {
sk_msg_free(sk, msg);
*copied = 0;
diff --git a/net/ipv4/tcp_cdg.c b/net/ipv4/tcp_cdg.c
index fbad6c35dee9..ceabfd690a29 100644
--- a/net/ipv4/tcp_cdg.c
+++ b/net/ipv4/tcp_cdg.c
@@ -378,8 +378,8 @@ static void tcp_cdg_init(struct sock *sk)
ca->gradients = NULL;
/* We silently fall back to window = 1 if allocation fails. */
if (window > 1)
- ca->gradients = kcalloc(window, sizeof(ca->gradients[0]),
- GFP_NOWAIT);
+ ca->gradients = kzalloc_objs(ca->gradients[0], window,
+ GFP_NOWAIT);
ca->rtt_seq = tp->snd_nxt;
ca->shadow_wnd = tcp_snd_cwnd(tp);
}
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index b30090cff3cf..b4309dc4b9c5 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -149,7 +149,7 @@ int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk,
struct fastopen_queue *q;
int err = 0;
- ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kmalloc_obj(*ctx, GFP_KERNEL);
if (!ctx) {
err = -ENOMEM;
goto out;
@@ -549,8 +549,8 @@ bool tcp_fastopen_defer_connect(struct sock *sk, int *err)
/* Alloc fastopen_req in order for FO option to be included
* in SYN
*/
- tp->fastopen_req = kzalloc(sizeof(*tp->fastopen_req),
- sk->sk_allocation);
+ tp->fastopen_req = kzalloc_obj(*tp->fastopen_req,
+ sk->sk_allocation);
if (tp->fastopen_req)
tp->fastopen_req->cookie = cookie;
else
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index e7b41abb82aa..65a7a5ea8eb7 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -7598,8 +7598,7 @@ static void tcp_reqsk_record_syn(const struct sock *sk,
mac_hdrlen = 0;
}
- saved_syn = kmalloc(struct_size(saved_syn, data, len),
- GFP_ATOMIC);
+ saved_syn = kmalloc_flex(*saved_syn, data, len, GFP_ATOMIC);
if (saved_syn) {
saved_syn->mac_hdrlen = mac_hdrlen;
saved_syn->network_hdrlen = skb_network_header_len(skb);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6264fc0b2be5..63a8b174cf99 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1354,7 +1354,7 @@ static int tcp_md5sig_info_add(struct sock *sk, gfp_t gfp)
struct tcp_sock *tp = tcp_sk(sk);
struct tcp_md5sig_info *md5sig;
- md5sig = kmalloc(sizeof(*md5sig), gfp);
+ md5sig = kmalloc_obj(*md5sig, gfp);
if (!md5sig)
return -ENOMEM;
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 45b6ecd16412..06b1d5d3b6df 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -197,7 +197,7 @@ static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
}
tm = oldest;
} else {
- tm = kzalloc(sizeof(*tm), GFP_ATOMIC);
+ tm = kzalloc_obj(*tm, GFP_ATOMIC);
if (!tm)
goto out_unlock;
}
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b96e47f1c8a2..5fcf81a833e8 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -3859,7 +3859,7 @@ static struct udp_table __net_init *udp_pernet_table_alloc(unsigned int hash_ent
unsigned int slot_size;
int i;
- udptable = kmalloc(sizeof(*udptable), GFP_KERNEL);
+ udptable = kmalloc_obj(*udptable, GFP_KERNEL);
if (!udptable)
goto out;
@@ -3972,8 +3972,8 @@ static int bpf_iter_udp_realloc_batch(struct bpf_udp_iter_state *iter,
{
union bpf_udp_iter_batch_item *new_batch;
- new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch),
- flags | __GFP_NOWARN);
+ new_batch = kvmalloc_objs(*new_batch, new_batch_sz,
+ flags | __GFP_NOWARN);
if (!new_batch)
return -ENOMEM;
diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
index 944b3cf25468..ae674e3ed9b8 100644
--- a/net/ipv4/udp_tunnel_nic.c
+++ b/net/ipv4/udp_tunnel_nic.c
@@ -753,7 +753,7 @@ udp_tunnel_nic_alloc(const struct udp_tunnel_nic_info *info,
struct udp_tunnel_nic *utn;
unsigned int i;
- utn = kzalloc(struct_size(utn, entries, n_tables), GFP_KERNEL);
+ utn = kzalloc_flex(*utn, entries, n_tables, GFP_KERNEL);
if (!utn)
return NULL;
utn->n_tables = n_tables;
@@ -761,8 +761,9 @@ udp_tunnel_nic_alloc(const struct udp_tunnel_nic_info *info,
mutex_init(&utn->lock);
for (i = 0; i < n_tables; i++) {
- utn->entries[i] = kcalloc(info->tables[i].n_entries,
- sizeof(*utn->entries[i]), GFP_KERNEL);
+ utn->entries[i] = kzalloc_objs(*utn->entries[i],
+ info->tables[i].n_entries,
+ GFP_KERNEL);
if (!utn->entries[i])
goto err_free_prev_entries;
}
@@ -820,7 +821,7 @@ static int udp_tunnel_nic_register(struct net_device *dev)
/* Create UDP tunnel state structures */
if (info->shared) {
- node = kzalloc(sizeof(*node), GFP_KERNEL);
+ node = kzalloc_obj(*node, GFP_KERNEL);
if (!node)
return -ENOMEM;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6db9cf9e2a50..5696ceb09dc7 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -355,12 +355,12 @@ static int snmp6_alloc_dev(struct inet6_dev *idev)
}
- idev->stats.icmpv6dev = kzalloc(sizeof(struct icmpv6_mib_device),
- GFP_KERNEL);
+ idev->stats.icmpv6dev = kzalloc_obj(struct icmpv6_mib_device,
+ GFP_KERNEL);
if (!idev->stats.icmpv6dev)
goto err_icmp;
- idev->stats.icmpv6msgdev = kzalloc(sizeof(struct icmpv6msg_mib_device),
- GFP_KERNEL_ACCOUNT);
+ idev->stats.icmpv6msgdev = kzalloc_obj(struct icmpv6msg_mib_device,
+ GFP_KERNEL_ACCOUNT);
if (!idev->stats.icmpv6msgdev)
goto err_icmpmsg;
@@ -385,7 +385,7 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
if (dev->mtu < IPV6_MIN_MTU && dev != blackhole_netdev)
return ERR_PTR(-EINVAL);
- ndev = kzalloc(sizeof(*ndev), GFP_KERNEL_ACCOUNT);
+ ndev = kzalloc_obj(*ndev, GFP_KERNEL_ACCOUNT);
if (!ndev)
return ERR_PTR(err);
@@ -1117,7 +1117,7 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
goto out;
}
- ifa = kzalloc(sizeof(*ifa), gfp_flags | __GFP_ACCOUNT);
+ ifa = kzalloc_obj(*ifa, gfp_flags | __GFP_ACCOUNT);
if (!ifa) {
err = -ENOBUFS;
goto out;
@@ -7398,9 +7398,8 @@ static int __net_init addrconf_init_net(struct net *net)
spin_lock_init(&net->ipv6.addrconf_hash_lock);
INIT_DEFERRABLE_WORK(&net->ipv6.addr_chk_work, addrconf_verify_work);
- net->ipv6.inet6_addr_lst = kcalloc(IN6_ADDR_HSIZE,
- sizeof(struct hlist_head),
- GFP_KERNEL);
+ net->ipv6.inet6_addr_lst = kzalloc_objs(struct hlist_head,
+ IN6_ADDR_HSIZE, GFP_KERNEL);
if (!net->ipv6.inet6_addr_lst)
goto err_alloc_addr;
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index 567efd626ab4..e3b6b9a3f02e 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -180,7 +180,7 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(const struct in6_addr *prefix,
break;
}
- newp = kmalloc(sizeof(*newp), GFP_KERNEL);
+ newp = kmalloc_obj(*newp, GFP_KERNEL);
if (!newp)
return ERR_PTR(-ENOMEM);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 69be0a67a140..25ff5148c926 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -921,8 +921,8 @@ static int __net_init ipv6_init_mibs(struct net *net)
net->mib.icmpv6_statistics = alloc_percpu(struct icmpv6_mib);
if (!net->mib.icmpv6_statistics)
goto err_icmp_mib;
- net->mib.icmpv6msg_statistics = kzalloc(sizeof(struct icmpv6msg_mib),
- GFP_KERNEL);
+ net->mib.icmpv6msg_statistics = kzalloc_obj(struct icmpv6msg_mib,
+ GFP_KERNEL);
if (!net->mib.icmpv6msg_statistics)
goto err_icmpmsg_mib;
return 0;
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 95372e0f1d21..7ad0c894f2fd 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -691,7 +691,7 @@ static int ah6_init_state(struct xfrm_state *x, struct netlink_ext_ack *extack)
goto error;
}
- ahp = kzalloc(sizeof(*ahp), GFP_KERNEL);
+ ahp = kzalloc_obj(*ahp, GFP_KERNEL);
if (!ahp)
return -ENOMEM;
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 52599584422b..67a42e01dfc3 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -279,7 +279,7 @@ static struct ifacaddr6 *aca_alloc(struct fib6_info *f6i,
{
struct ifacaddr6 *aca;
- aca = kzalloc(sizeof(*aca), GFP_ATOMIC);
+ aca = kzalloc_obj(*aca, GFP_ATOMIC);
if (!aca)
return NULL;
diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index 21f6ed126253..ff39220fef8a 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -133,9 +133,8 @@ static int __init calipso_cache_init(void)
{
u32 iter;
- calipso_cache = kcalloc(CALIPSO_CACHE_BUCKETS,
- sizeof(struct calipso_map_cache_bkt),
- GFP_KERNEL);
+ calipso_cache = kzalloc_objs(struct calipso_map_cache_bkt,
+ CALIPSO_CACHE_BUCKETS, GFP_KERNEL);
if (!calipso_cache)
return -ENOMEM;
@@ -275,7 +274,7 @@ static int calipso_cache_add(const unsigned char *calipso_ptr,
calipso_ptr_len = calipso_ptr[1];
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
return -ENOMEM;
entry->key = kmemdup(calipso_ptr + 2, calipso_ptr_len, GFP_ATOMIC);
diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c
index 1d41b2ab4884..c5ff34040175 100644
--- a/net/ipv6/ila/ila_xlat.c
+++ b/net/ipv6/ila/ila_xlat.c
@@ -220,7 +220,7 @@ static int ila_add_mapping(struct net *net, struct ila_xlat_params *xp)
return err;
}
- ila = kzalloc(sizeof(*ila), GFP_KERNEL);
+ ila = kzalloc_obj(*ila, GFP_KERNEL);
if (!ila)
return -ENOMEM;
@@ -509,7 +509,7 @@ int ila_xlat_nl_dump_start(struct netlink_callback *cb)
struct ila_net *ilan = net_generic(net, ila_net_id);
struct ila_dump_iter *iter;
- iter = kmalloc(sizeof(*iter), GFP_KERNEL);
+ iter = kmalloc_obj(*iter, GFP_KERNEL);
if (!iter)
return -ENOMEM;
diff --git a/net/ipv6/ioam6.c b/net/ipv6/ioam6.c
index 08b7ac8c99b7..b6c9e48891fe 100644
--- a/net/ipv6/ioam6.c
+++ b/net/ipv6/ioam6.c
@@ -127,7 +127,7 @@ static int ioam6_genl_addns(struct sk_buff *skb, struct genl_info *info)
goto out_unlock;
}
- ns = kzalloc(sizeof(*ns), GFP_KERNEL);
+ ns = kzalloc_obj(*ns, GFP_KERNEL);
if (!ns) {
err = -ENOMEM;
goto out_unlock;
@@ -245,7 +245,7 @@ static int ioam6_genl_dumpns_start(struct netlink_callback *cb)
struct rhashtable_iter *iter = (struct rhashtable_iter *)cb->args[0];
if (!iter) {
- iter = kmalloc(sizeof(*iter), GFP_KERNEL);
+ iter = kmalloc_obj(*iter, GFP_KERNEL);
if (!iter)
return -ENOMEM;
@@ -431,7 +431,7 @@ static int ioam6_genl_dumpsc_start(struct netlink_callback *cb)
struct rhashtable_iter *iter = (struct rhashtable_iter *)cb->args[0];
if (!iter) {
- iter = kmalloc(sizeof(*iter), GFP_KERNEL);
+ iter = kmalloc_obj(*iter, GFP_KERNEL);
if (!iter)
return -ENOMEM;
@@ -975,7 +975,7 @@ static int __net_init ioam6_net_init(struct net *net)
struct ioam6_pernet_data *nsdata;
int err = -ENOMEM;
- nsdata = kzalloc(sizeof(*nsdata), GFP_KERNEL);
+ nsdata = kzalloc_obj(*nsdata, GFP_KERNEL);
if (!nsdata)
goto out;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 56058e6de490..6a26d9448395 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -234,7 +234,7 @@ static struct fib6_table *fib6_alloc_table(struct net *net, u32 id)
{
struct fib6_table *table;
- table = kzalloc(sizeof(*table), GFP_ATOMIC);
+ table = kzalloc_obj(*table, GFP_ATOMIC);
if (table) {
table->tb6_id = id;
rcu_assign_pointer(table->tb6_root.leaf,
@@ -494,7 +494,7 @@ int fib6_tables_dump(struct net *net, struct notifier_block *nb,
unsigned int h;
int err = 0;
- w = kzalloc(sizeof(*w), GFP_ATOMIC);
+ w = kzalloc_obj(*w, GFP_ATOMIC);
if (!w)
return -ENOMEM;
@@ -659,7 +659,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
*
* 1. allocate and initialize walker.
*/
- w = kzalloc(sizeof(*w), GFP_ATOMIC);
+ w = kzalloc_obj(*w, GFP_ATOMIC);
if (!w) {
err = -ENOMEM;
goto unlock;
@@ -731,7 +731,7 @@ void fib6_metric_set(struct fib6_info *f6i, int metric, u32 val)
return;
if (f6i->fib6_metrics == &dst_default_metrics) {
- struct dst_metrics *p = kzalloc(sizeof(*p), GFP_ATOMIC);
+ struct dst_metrics *p = kzalloc_obj(*p, GFP_ATOMIC);
if (!p)
return;
@@ -2464,7 +2464,7 @@ static int __net_init fib6_net_init(struct net *net)
INIT_LIST_HEAD(&net->ipv6.fib6_walkers);
timer_setup(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, 0);
- net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL);
+ net->ipv6.rt6_stats = kzalloc_obj(*net->ipv6.rt6_stats, GFP_KERNEL);
if (!net->ipv6.rt6_stats)
goto out_notifier;
@@ -2477,8 +2477,8 @@ static int __net_init fib6_net_init(struct net *net)
spin_lock_init(&net->ipv6.fib_table_hash_lock);
- net->ipv6.fib6_main_tbl = kzalloc(sizeof(*net->ipv6.fib6_main_tbl),
- GFP_KERNEL);
+ net->ipv6.fib6_main_tbl = kzalloc_obj(*net->ipv6.fib6_main_tbl,
+ GFP_KERNEL);
if (!net->ipv6.fib6_main_tbl)
goto out_fib_table_hash;
@@ -2491,8 +2491,8 @@ static int __net_init fib6_net_init(struct net *net)
INIT_HLIST_HEAD(&net->ipv6.fib6_main_tbl->tb6_gc_hlist);
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
- net->ipv6.fib6_local_tbl = kzalloc(sizeof(*net->ipv6.fib6_local_tbl),
- GFP_KERNEL);
+ net->ipv6.fib6_local_tbl = kzalloc_obj(*net->ipv6.fib6_local_tbl,
+ GFP_KERNEL);
if (!net->ipv6.fib6_local_tbl)
goto out_fib6_main_tbl;
net->ipv6.fib6_local_tbl->tb6_id = RT6_TABLE_LOCAL;
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 60d0be47a9f3..f89e0af5a9ed 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -386,7 +386,7 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq,
goto done;
err = -ENOMEM;
- fl = kzalloc(sizeof(*fl), GFP_KERNEL);
+ fl = kzalloc_obj(*fl, GFP_KERNEL);
if (!fl)
goto done;
@@ -638,7 +638,7 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq,
if (!fl)
return err;
- sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL);
+ sfl1 = kmalloc_obj(*sfl1, GFP_KERNEL);
if (freq->flr_label) {
err = -EEXIST;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 769c39fed1f3..8e2a6b28cea7 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1359,7 +1359,7 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
if (WARN_ON(v6_cork->opt))
return -EINVAL;
- nopt = v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation);
+ nopt = v6_cork->opt = kzalloc_obj(*opt, sk->sk_allocation);
if (unlikely(!nopt))
return -ENOBUFS;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index d784a8644ff2..152388dc96ec 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -66,7 +66,7 @@ int ip6_ra_control(struct sock *sk, int sel)
if (sk->sk_type != SOCK_RAW || inet_sk(sk)->inet_num != IPPROTO_RAW)
return -ENOPROTOOPT;
- new_ra = (sel >= 0) ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
+ new_ra = (sel >= 0) ? kmalloc_obj(*new_ra, GFP_KERNEL) : NULL;
if (sel >= 0 && !new_ra)
return -ENOMEM;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 016b572e7d6f..f982f3b71435 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -740,7 +740,7 @@ static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
* for deleted items allows change reports to use common code with
* non-deleted or query-response MCA's.
*/
- pmc = kzalloc(sizeof(*pmc), GFP_KERNEL);
+ pmc = kzalloc_obj(*pmc, GFP_KERNEL);
if (!pmc)
return;
@@ -868,7 +868,7 @@ static struct ifmcaddr6 *mca_alloc(struct inet6_dev *idev,
mc_assert_locked(idev);
- mc = kzalloc(sizeof(*mc), GFP_KERNEL);
+ mc = kzalloc_obj(*mc, GFP_KERNEL);
if (!mc)
return NULL;
@@ -2415,7 +2415,7 @@ static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode,
psf_prev = psf;
}
if (!psf) {
- psf = kzalloc(sizeof(*psf), GFP_KERNEL);
+ psf = kzalloc_obj(*psf, GFP_KERNEL);
if (!psf)
return -ENOBUFS;
@@ -2500,7 +2500,7 @@ static int sf_setstate(struct ifmcaddr6 *pmc)
&psf->sf_addr))
break;
if (!dpsf) {
- dpsf = kmalloc(sizeof(*dpsf), GFP_KERNEL);
+ dpsf = kmalloc_obj(*dpsf, GFP_KERNEL);
if (!dpsf)
continue;
*dpsf = *psf;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c0350d97307e..dd50cf2bf6ef 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -684,14 +684,14 @@ static void rt6_probe(struct fib6_nh *fib6_nh)
time_after(jiffies,
neigh->updated +
READ_ONCE(idev->cnf.rtr_probe_interval))) {
- work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ work = kmalloc_obj(*work, GFP_ATOMIC);
if (work)
__neigh_set_probe_once(neigh);
}
write_unlock_bh(&neigh->lock);
} else if (time_after(jiffies, last_probe +
READ_ONCE(idev->cnf.rtr_probe_interval))) {
- work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ work = kmalloc_obj(*work, GFP_ATOMIC);
}
if (!work || cmpxchg(&fib6_nh->last_probe,
@@ -1723,8 +1723,8 @@ static int rt6_insert_exception(struct rt6_info *nrt,
bucket = rcu_dereference_protected(nh->rt6i_exception_bucket,
lockdep_is_held(&rt6_exception_lock));
if (!bucket) {
- bucket = kcalloc(FIB6_EXCEPTION_BUCKET_SIZE, sizeof(*bucket),
- GFP_ATOMIC);
+ bucket = kzalloc_objs(*bucket, FIB6_EXCEPTION_BUCKET_SIZE,
+ GFP_ATOMIC);
if (!bucket) {
err = -ENOMEM;
goto out;
@@ -1759,7 +1759,7 @@ static int rt6_insert_exception(struct rt6_info *nrt,
if (rt6_ex)
rt6_remove_exception(bucket, rt6_ex);
- rt6_ex = kzalloc(sizeof(*rt6_ex), GFP_ATOMIC);
+ rt6_ex = kzalloc_obj(*rt6_ex, GFP_ATOMIC);
if (!rt6_ex) {
err = -ENOMEM;
goto out;
@@ -5331,7 +5331,7 @@ static int ip6_route_info_append(struct list_head *rt6_nh_list,
return -EEXIST;
}
- nh = kzalloc(sizeof(*nh), GFP_KERNEL);
+ nh = kzalloc_obj(*nh, GFP_KERNEL);
if (!nh)
return -ENOMEM;
@@ -6778,7 +6778,7 @@ static struct pernet_operations ip6_route_net_ops = {
static int __net_init ipv6_inetpeer_init(struct net *net)
{
- struct inet_peer_base *bp = kmalloc(sizeof(*bp), GFP_KERNEL);
+ struct inet_peer_base *bp = kmalloc_obj(*bp, GFP_KERNEL);
if (!bp)
return -ENOMEM;
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index a5c4c629b788..b53c491079cd 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -202,7 +202,7 @@ static int seg6_genl_sethmac(struct sk_buff *skb, struct genl_info *info)
secret = (char *)nla_data(info->attrs[SEG6_ATTR_SECRET]);
- hinfo = kzalloc(sizeof(*hinfo), GFP_KERNEL);
+ hinfo = kzalloc_obj(*hinfo, GFP_KERNEL);
if (!hinfo) {
err = -ENOMEM;
goto out_unlock;
@@ -339,7 +339,7 @@ static int seg6_genl_dumphmac_start(struct netlink_callback *cb)
iter = (struct rhashtable_iter *)cb->args[0];
if (!iter) {
- iter = kmalloc(sizeof(*iter), GFP_KERNEL);
+ iter = kmalloc_obj(*iter, GFP_KERNEL);
if (!iter)
return -ENOMEM;
@@ -421,13 +421,13 @@ static int __net_init seg6_net_init(struct net *net)
{
struct seg6_pernet_data *sdata;
- sdata = kzalloc(sizeof(*sdata), GFP_KERNEL);
+ sdata = kzalloc_obj(*sdata, GFP_KERNEL);
if (!sdata)
return -ENOMEM;
mutex_init(&sdata->lock);
- sdata->tun_src = kzalloc(sizeof(*sdata->tun_src), GFP_KERNEL);
+ sdata->tun_src = kzalloc_obj(*sdata->tun_src, GFP_KERNEL);
if (!sdata->tun_src) {
kfree(sdata);
return -ENOMEM;
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 439c8a1c6625..ca7955831c28 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -323,7 +323,7 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u
* we try harder to allocate.
*/
kp = (cmax <= 1 || capable(CAP_NET_ADMIN)) ?
- kcalloc(cmax, sizeof(*kp), GFP_KERNEL_ACCOUNT | __GFP_NOWARN) :
+ kzalloc_objs(*kp, cmax, GFP_KERNEL_ACCOUNT | __GFP_NOWARN) :
NULL;
ca = min(t->prl_count, cmax);
@@ -334,8 +334,8 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u
* For root users, retry allocating enough memory for
* the answer.
*/
- kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC | __GFP_ACCOUNT |
- __GFP_NOWARN);
+ kp = kzalloc_objs(*kp, ca,
+ GFP_ATOMIC | __GFP_ACCOUNT | __GFP_NOWARN);
if (!kp) {
ret = -ENOMEM;
goto out;
@@ -394,7 +394,7 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
goto out;
}
- p = kzalloc(sizeof(struct ip_tunnel_prl_entry), GFP_KERNEL);
+ p = kzalloc_obj(struct ip_tunnel_prl_entry, GFP_KERNEL);
if (!p) {
err = -ENOBUFS;
goto out;
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 1e62fbc22cb7..6554d2cffc19 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1719,7 +1719,7 @@ static void iucv_callback_rx(struct iucv_path *path, struct iucv_message *msg)
goto out_unlock;
save_message:
- save_msg = kzalloc(sizeof(struct sock_msg_q), GFP_ATOMIC | GFP_DMA);
+ save_msg = kzalloc_obj(struct sock_msg_q, GFP_ATOMIC | GFP_DMA);
if (!save_msg)
goto out_unlock;
save_msg->path = path;
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index b43b1059eea8..0c3492c873ca 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -90,7 +90,7 @@ struct device *iucv_alloc_device(const struct attribute_group **attrs,
char buf[20];
int rc;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev)
goto out_error;
va_start(vargs, fmt);
@@ -378,7 +378,7 @@ static int iucv_query_maxconn(void)
void *param;
int ccode;
- param = kzalloc(sizeof(union iucv_param), GFP_KERNEL | GFP_DMA);
+ param = kzalloc_obj(union iucv_param, GFP_KERNEL | GFP_DMA);
if (!param)
return -ENOMEM;
ccode = __iucv_query_maxconn(param, &max_pathid);
@@ -1808,7 +1808,7 @@ static void iucv_external_interrupt(struct ext_code ext_code,
return;
}
BUG_ON(p->iptype < 0x01 || p->iptype > 0x09);
- work = kmalloc(sizeof(struct iucv_irq_list), GFP_ATOMIC);
+ work = kmalloc_obj(struct iucv_irq_list, GFP_ATOMIC);
if (!work) {
pr_warn("iucv_external_interrupt: out of memory\n");
return;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 571200433aa9..83c7697c679a 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1196,7 +1196,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
err = -ENOSYS;
goto out;
}
- x->calg = kmalloc(sizeof(*x->calg), GFP_KERNEL);
+ x->calg = kmalloc_obj(*x->calg, GFP_KERNEL);
if (!x->calg) {
err = -ENOMEM;
goto out;
@@ -1261,7 +1261,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
const struct sadb_x_nat_t_type* n_type;
struct xfrm_encap_tmpl *natt;
- x->encap = kzalloc(sizeof(*x->encap), GFP_KERNEL);
+ x->encap = kzalloc_obj(*x->encap, GFP_KERNEL);
if (!x->encap) {
err = -ENOMEM;
goto out;
@@ -1855,7 +1855,7 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms
mutex_unlock(&pfk->dump_lock);
return -EINVAL;
}
- filter = kmalloc(sizeof(*filter), GFP_KERNEL);
+ filter = kmalloc_obj(*filter, GFP_KERNEL);
if (filter == NULL) {
mutex_unlock(&pfk->dump_lock);
return -ENOMEM;
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index f9b0f666600f..1b84338f2a90 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -487,7 +487,7 @@ static int l2tp_session_collision_add(struct l2tp_net *pn,
/* First collision. Allocate list to manage the collided sessions
* and add the existing session to the list.
*/
- clist = kmalloc(sizeof(*clist), GFP_ATOMIC);
+ clist = kmalloc_obj(*clist, GFP_ATOMIC);
if (!clist)
return -ENOMEM;
@@ -1572,7 +1572,7 @@ int l2tp_tunnel_create(int fd, int version, u32 tunnel_id, u32 peer_tunnel_id,
if (cfg)
encap = cfg->encap;
- tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL);
+ tunnel = kzalloc_obj(*tunnel, GFP_KERNEL);
if (!tunnel) {
err = -ENOMEM;
goto err;
diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c
index 5cfaab7d0890..56ea3ed20581 100644
--- a/net/l2tp/l2tp_debugfs.c
+++ b/net/l2tp/l2tp_debugfs.c
@@ -269,7 +269,7 @@ static int l2tp_dfs_seq_open(struct inode *inode, struct file *file)
struct seq_file *seq;
int rc = -ENOMEM;
- pd = kzalloc(sizeof(*pd), GFP_KERNEL);
+ pd = kzalloc_obj(*pd, GFP_KERNEL);
if (!pd)
goto out;
diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index a0596e1f91da..670e0859a3e6 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -110,7 +110,7 @@ static struct lapb_cb *lapb_devtostruct(struct net_device *dev)
*/
static struct lapb_cb *lapb_create_cb(void)
{
- struct lapb_cb *lapb = kzalloc(sizeof(*lapb), GFP_ATOMIC);
+ struct lapb_cb *lapb = kzalloc_obj(*lapb, GFP_ATOMIC);
if (!lapb)
goto out;
diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c
index 4f16d9c88350..d73f5414d8ce 100644
--- a/net/llc/llc_core.c
+++ b/net/llc/llc_core.c
@@ -32,7 +32,7 @@ static DEFINE_SPINLOCK(llc_sap_list_lock);
*/
static struct llc_sap *llc_sap_alloc(void)
{
- struct llc_sap *sap = kzalloc(sizeof(*sap), GFP_ATOMIC);
+ struct llc_sap *sap = kzalloc_obj(*sap, GFP_ATOMIC);
int i;
if (sap) {
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c
index 7da909d78c68..e8670a46371c 100644
--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
@@ -395,7 +395,7 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
}
/* prepare A-MPDU MLME for Rx aggregation */
- tid_agg_rx = kzalloc(sizeof(*tid_agg_rx), GFP_KERNEL);
+ tid_agg_rx = kzalloc_obj(*tid_agg_rx, GFP_KERNEL);
if (!tid_agg_rx)
goto end;
@@ -411,7 +411,7 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
/* prepare reordering buffer */
tid_agg_rx->reorder_buf =
- kcalloc(buf_size, sizeof(struct sk_buff_head), GFP_KERNEL);
+ kzalloc_objs(struct sk_buff_head, buf_size, GFP_KERNEL);
tid_agg_rx->reorder_time =
kcalloc(buf_size, sizeof(unsigned long), GFP_KERNEL);
if (!tid_agg_rx->reorder_buf || !tid_agg_rx->reorder_time) {
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index d981b0fc57bf..93b47a7ba9c4 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -710,7 +710,7 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,
}
/* prepare A-MPDU MLME for Tx aggregation */
- tid_tx = kzalloc(sizeof(struct tid_ampdu_tx), GFP_ATOMIC);
+ tid_tx = kzalloc_obj(struct tid_ampdu_tx, GFP_ATOMIC);
if (!tid_tx) {
ret = -ENOMEM;
goto err_unlock_sta;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 5d04d7d550b0..d1adbc4984d1 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3940,9 +3940,8 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
new_beacon->mbssid_ies =
- kzalloc(struct_size(new_beacon->mbssid_ies,
- elem, beacon->mbssid_ies->cnt),
- GFP_KERNEL);
+ kzalloc_flex(*new_beacon->mbssid_ies, elem,
+ beacon->mbssid_ies->cnt, GFP_KERNEL);
if (!new_beacon->mbssid_ies) {
kfree(new_beacon);
return NULL;
@@ -3950,9 +3949,8 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
if (beacon->rnr_ies && beacon->rnr_ies->cnt) {
new_beacon->rnr_ies =
- kzalloc(struct_size(new_beacon->rnr_ies,
- elem, beacon->rnr_ies->cnt),
- GFP_KERNEL);
+ kzalloc_flex(*new_beacon->rnr_ies, elem,
+ beacon->rnr_ies->cnt, GFP_KERNEL);
if (!new_beacon->rnr_ies) {
kfree(new_beacon->mbssid_ies);
kfree(new_beacon);
@@ -4744,7 +4742,7 @@ static int ieee80211_set_qos_map(struct wiphy *wiphy,
struct mac80211_qos_map *new_qos_map, *old_qos_map;
if (qos_map) {
- new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
+ new_qos_map = kzalloc_obj(*new_qos_map, GFP_KERNEL);
if (!new_qos_map)
return -ENOMEM;
memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index d8c5f11afc15..60654b0b542d 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -1612,7 +1612,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,
lockdep_assert_wiphy(local->hw.wiphy);
- vif_chsw = kcalloc(n_vifs, sizeof(vif_chsw[0]), GFP_KERNEL);
+ vif_chsw = kzalloc_objs(vif_chsw[0], n_vifs, GFP_KERNEL);
if (!vif_chsw)
return -ENOMEM;
diff --git a/net/mac80211/led.c b/net/mac80211/led.c
index fabbffdd3ac2..f93fe928c4bc 100644
--- a/net/mac80211/led.c
+++ b/net/mac80211/led.c
@@ -298,7 +298,7 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
if (WARN_ON(local->tpt_led_trigger))
return NULL;
- tpt_trig = kzalloc(sizeof(struct tpt_led_trigger), GFP_KERNEL);
+ tpt_trig = kzalloc_obj(struct tpt_led_trigger, GFP_KERNEL);
if (!tpt_trig)
return NULL;
diff --git a/net/mac80211/link.c b/net/mac80211/link.c
index 17bf55dabd31..7102d113d89d 100644
--- a/net/mac80211/link.c
+++ b/net/mac80211/link.c
@@ -295,7 +295,7 @@ static int ieee80211_vif_update_links(struct ieee80211_sub_if_data *sdata,
/* allocate new link structures first */
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
- link = kzalloc(sizeof(*link), GFP_KERNEL);
+ link = kzalloc_obj(*link, GFP_KERNEL);
if (!link) {
ret = -ENOMEM;
goto free;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index bedc81956fbc..9825d7c70cbc 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1359,9 +1359,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_MONITOR);
- local->int_scan_req = kzalloc(struct_size(local->int_scan_req,
- channels, channels),
- GFP_KERNEL);
+ local->int_scan_req = kzalloc_flex(*local->int_scan_req, channels,
+ channels, GFP_KERNEL);
if (!local->int_scan_req)
return -ENOMEM;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 68901f1def0d..a7bd4dd9aa19 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -178,7 +178,7 @@ int mesh_rmc_init(struct ieee80211_sub_if_data *sdata)
{
int i;
- sdata->u.mesh.rmc = kmalloc(sizeof(struct mesh_rmc), GFP_KERNEL);
+ sdata->u.mesh.rmc = kmalloc_obj(struct mesh_rmc, GFP_KERNEL);
if (!sdata->u.mesh.rmc)
return -ENOMEM;
sdata->u.mesh.rmc->idx_mask = RMC_BUCKETS - 1;
@@ -1560,8 +1560,7 @@ int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
lockdep_assert_wiphy(sdata->local->hw.wiphy);
- tmp_csa_settings = kmalloc(sizeof(*tmp_csa_settings),
- GFP_ATOMIC);
+ tmp_csa_settings = kmalloc_obj(*tmp_csa_settings, GFP_ATOMIC);
if (!tmp_csa_settings)
return -ENOMEM;
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index a41b57bd11ff..98d5aaa36d00 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -1005,7 +1005,7 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags)
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
struct mesh_preq_queue *preq_node;
- preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC);
+ preq_node = kmalloc_obj(struct mesh_preq_queue, GFP_ATOMIC);
if (!preq_node) {
mhwmp_dbg(sdata, "could not allocate PREQ node\n");
return;
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 0319674be832..03171cf00855 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -405,7 +405,7 @@ struct mesh_path *mesh_path_new(struct ieee80211_sub_if_data *sdata,
{
struct mesh_path *new_mpath;
- new_mpath = kzalloc(sizeof(struct mesh_path), gfp_flags);
+ new_mpath = kzalloc_obj(struct mesh_path, gfp_flags);
if (!new_mpath)
return NULL;
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index e83582b2c377..c1d0808f2545 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -10839,7 +10839,7 @@ int ieee80211_mgd_assoc_ml_reconf(struct ieee80211_sub_if_data *sdata,
if (added_links) {
bool uapsd_supported;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index ae82533e3c02..00ef339f7de4 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -579,7 +579,7 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local,
if (!local->emulate_chanctx && !local->ops->remain_on_channel)
return -EOPNOTSUPP;
- roc = kzalloc(sizeof(*roc), GFP_KERNEL);
+ roc = kzalloc_obj(*roc, GFP_KERNEL);
if (!roc)
return -ENOMEM;
diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c
index 8260f6bdd5b2..2b3632c6008a 100644
--- a/net/mac80211/parse.c
+++ b/net/mac80211/parse.c
@@ -1048,8 +1048,8 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params)
if (WARN_ON(params->link_id >= 0 && params->bss))
return NULL;
- elems_parse = kzalloc(struct_size(elems_parse, scratch, scratch_len),
- GFP_ATOMIC);
+ elems_parse = kzalloc_flex(*elems_parse, scratch, scratch_len,
+ GFP_ATOMIC);
if (!elems_parse)
return NULL;
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index e441f8541603..3ae891be800b 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -163,7 +163,7 @@ int ieee80211_rate_control_register(const struct rate_control_ops *ops)
}
}
- alg = kzalloc(sizeof(*alg), GFP_KERNEL);
+ alg = kzalloc_obj(*alg, GFP_KERNEL);
if (alg == NULL) {
mutex_unlock(&rate_ctrl_mutex);
return -ENOMEM;
@@ -263,7 +263,7 @@ rate_control_alloc(const char *name, struct ieee80211_local *local)
{
struct rate_control_ref *ref;
- ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL);
+ ref = kmalloc_obj(struct rate_control_ref, GFP_KERNEL);
if (!ref)
return NULL;
ref->ops = ieee80211_rate_control_ops_get(name);
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index f66910013218..62745ca00e06 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -1553,7 +1553,7 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
int i = 0;
int max_rates = min_t(int, mp->hw->max_rates, IEEE80211_TX_RATE_TABLE_SIZE);
- rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
+ rates = kzalloc_obj(*rates, GFP_ATOMIC);
if (!rates)
return;
@@ -1862,7 +1862,7 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
max_rates = sband->n_bitrates;
}
- return kzalloc(sizeof(*mi), gfp);
+ return kzalloc_obj(*mi, gfp);
}
static void
@@ -1930,7 +1930,7 @@ minstrel_ht_alloc(struct ieee80211_hw *hw)
struct minstrel_priv *mp;
int i;
- mp = kzalloc(sizeof(struct minstrel_priv), GFP_ATOMIC);
+ mp = kzalloc_obj(struct minstrel_priv, GFP_ATOMIC);
if (!mp)
return NULL;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index a79ebeb43585..6abcf410a0ca 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -644,7 +644,7 @@ __sta_info_alloc(struct ieee80211_sub_if_data *sdata,
wiphy_work_init(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
#ifdef CONFIG_MAC80211_MESH
if (ieee80211_vif_is_mesh(&sdata->vif)) {
- sta->mesh = kzalloc(sizeof(*sta->mesh), gfp);
+ sta->mesh = kzalloc_obj(*sta->mesh, gfp);
if (!sta->mesh)
goto free;
sta->mesh->plink_sta = sta;
@@ -903,7 +903,7 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
goto out_cleanup;
}
- sinfo = kzalloc(sizeof(struct station_info), GFP_KERNEL);
+ sinfo = kzalloc_obj(struct station_info, GFP_KERNEL);
if (!sinfo) {
err = -ENOMEM;
goto out_cleanup;
@@ -1545,7 +1545,7 @@ static void __sta_info_destroy_part2(struct sta_info *sta, bool recalc)
}
}
- sinfo = kzalloc(sizeof(*sinfo), GFP_KERNEL);
+ sinfo = kzalloc_obj(*sinfo, GFP_KERNEL);
if (sinfo)
sta_set_sinfo(sta, sinfo, true);
@@ -3306,7 +3306,7 @@ int ieee80211_sta_allocate_link(struct sta_info *sta, unsigned int link_id)
sta->link[link_id]))
return -EBUSY;
- alloc = kzalloc(sizeof(*alloc), GFP_KERNEL);
+ alloc = kzalloc_obj(*alloc, GFP_KERNEL);
if (!alloc)
return -ENOMEM;
diff --git a/net/mac80211/tests/util.c b/net/mac80211/tests/util.c
index 9c2d63a5cd2b..cddc46eeb648 100644
--- a/net/mac80211/tests/util.c
+++ b/net/mac80211/tests/util.c
@@ -195,16 +195,16 @@ int t_sdata_init(struct kunit_resource *resource, void *ctx)
struct kunit *test = kunit_get_current_test();
struct t_sdata *t_sdata;
- t_sdata = kzalloc(sizeof(*t_sdata), GFP_KERNEL);
+ t_sdata = kzalloc_obj(*t_sdata, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, t_sdata);
resource->data = t_sdata;
resource->name = "sdata";
- t_sdata->sdata = kzalloc(sizeof(*t_sdata->sdata), GFP_KERNEL);
+ t_sdata->sdata = kzalloc_obj(*t_sdata->sdata, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, t_sdata->sdata);
- t_sdata->wiphy = kzalloc(sizeof(*t_sdata->wiphy), GFP_KERNEL);
+ t_sdata->wiphy = kzalloc_obj(*t_sdata->wiphy, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, t_sdata->wiphy);
strscpy(t_sdata->sdata->name, "kunit");
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 007f5a368d41..a3113e1d9829 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1611,8 +1611,7 @@ int ieee80211_txq_setup_flows(struct ieee80211_local *local)
local->cparams.target = MS2TIME(20);
local->cparams.ecn = true;
- local->cvars = kvcalloc(fq->flows_cnt, sizeof(local->cvars[0]),
- GFP_KERNEL);
+ local->cvars = kvzalloc_objs(local->cvars[0], fq->flows_cnt, GFP_KERNEL);
if (!local->cvars) {
spin_lock_bh(&fq->lock);
fq_reset(fq, fq_skb_free_func);
@@ -5549,8 +5548,7 @@ ieee80211_beacon_get_ap_ema_list(struct ieee80211_hw *hw,
if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt)
return NULL;
- ema = kzalloc(struct_size(ema, bcn, beacon->mbssid_ies->cnt),
- GFP_ATOMIC);
+ ema = kzalloc_flex(*ema, bcn, beacon->mbssid_ies->cnt, GFP_ATOMIC);
if (!ema)
return NULL;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index a5e09c0fa6b3..22efb399b5bc 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1742,9 +1742,8 @@ static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata)
if (WARN_ON(res))
return res;
- funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1,
- sizeof(*funcs),
- GFP_KERNEL);
+ funcs = kzalloc_objs(*funcs, sdata->local->hw.max_nan_de_entries + 1,
+ GFP_KERNEL);
if (!funcs)
return -ENOMEM;
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index ef7f23af043f..44ad05726db3 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -339,7 +339,7 @@ static int mac802154_associate(struct wpan_phy *wpan_phy,
if (coord->mode == IEEE802154_SHORT_ADDRESSING)
return -EINVAL;
- parent = kzalloc(sizeof(*parent), GFP_KERNEL);
+ parent = kzalloc_obj(*parent, GFP_KERNEL);
if (!parent)
return -ENOMEM;
diff --git a/net/mac802154/llsec.c b/net/mac802154/llsec.c
index f13b07ebfb98..0489f2515eb6 100644
--- a/net/mac802154/llsec.c
+++ b/net/mac802154/llsec.c
@@ -117,7 +117,7 @@ llsec_key_alloc(const struct ieee802154_llsec_key *template)
struct mac802154_llsec_key *key;
int i;
- key = kzalloc(sizeof(*key), GFP_KERNEL);
+ key = kzalloc_obj(*key, GFP_KERNEL);
if (!key)
return NULL;
@@ -241,7 +241,7 @@ int mac802154_llsec_key_add(struct mac802154_llsec *sec,
break;
}
- new = kzalloc(sizeof(*new), GFP_KERNEL);
+ new = kzalloc_obj(*new, GFP_KERNEL);
if (!new)
return -ENOMEM;
@@ -369,7 +369,7 @@ int mac802154_llsec_dev_add(struct mac802154_llsec *sec,
llsec_dev_find_long(sec, dev->hwaddr))
return -EEXIST;
- entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kmalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
@@ -441,7 +441,7 @@ int mac802154_llsec_devkey_add(struct mac802154_llsec *sec,
if (llsec_devkey_find(dev, &key->key_id))
return -EEXIST;
- devkey = kmalloc(sizeof(*devkey), GFP_KERNEL);
+ devkey = kmalloc_obj(*devkey, GFP_KERNEL);
if (!devkey)
return -ENOMEM;
@@ -500,7 +500,7 @@ int mac802154_llsec_seclevel_add(struct mac802154_llsec *sec,
if (llsec_find_seclevel(sec, sl))
return -EEXIST;
- entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kmalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
@@ -925,7 +925,7 @@ llsec_update_devkey_record(struct mac802154_llsec_device *dev,
if (!devkey) {
struct mac802154_llsec_device_key *next;
- next = kzalloc(sizeof(*devkey), GFP_ATOMIC);
+ next = kzalloc_obj(*devkey, GFP_ATOMIC);
if (!next)
return -ENOMEM;
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index aac359b5c71d..cd8f2a11920d 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -213,7 +213,7 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,
if (!mac802154_is_scanning(sdata->local))
goto fail;
- mac_pkt = kzalloc(sizeof(*mac_pkt), GFP_ATOMIC);
+ mac_pkt = kzalloc_obj(*mac_pkt, GFP_ATOMIC);
if (!mac_pkt)
goto fail;
@@ -227,7 +227,7 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,
case IEEE802154_FC_TYPE_MAC_CMD:
dev_dbg(&sdata->dev->dev, "MAC COMMAND received\n");
- mac_pkt = kzalloc(sizeof(*mac_pkt), GFP_ATOMIC);
+ mac_pkt = kzalloc_obj(*mac_pkt, GFP_ATOMIC);
if (!mac_pkt)
goto fail;
diff --git a/net/mac802154/scan.c b/net/mac802154/scan.c
index a6dab3cc3ad8..583178784c9b 100644
--- a/net/mac802154/scan.c
+++ b/net/mac802154/scan.c
@@ -798,7 +798,7 @@ int mac802154_process_association_req(struct ieee802154_sub_if_data *sdata,
goto unlock;
}
- child = kzalloc(sizeof(*child), GFP_KERNEL);
+ child = kzalloc_obj(*child, GFP_KERNEL);
if (!child) {
ret = -ENOMEM;
goto unlock;
diff --git a/net/mctp/device.c b/net/mctp/device.c
index 04c5570bacff..08f3d35fa45b 100644
--- a/net/mctp/device.c
+++ b/net/mctp/device.c
@@ -336,7 +336,7 @@ static struct mctp_dev *mctp_add_dev(struct net_device *dev)
ASSERT_RTNL();
- mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+ mdev = kzalloc_obj(*mdev, GFP_KERNEL);
if (!mdev)
return ERR_PTR(-ENOMEM);
diff --git a/net/mctp/neigh.c b/net/mctp/neigh.c
index fc85f0e69301..5894433535eb 100644
--- a/net/mctp/neigh.c
+++ b/net/mctp/neigh.c
@@ -40,7 +40,7 @@ static int mctp_neigh_add(struct mctp_dev *mdev, mctp_eid_t eid,
goto out;
}
- neigh = kzalloc(sizeof(*neigh), GFP_KERNEL);
+ neigh = kzalloc_obj(*neigh, GFP_KERNEL);
if (!neigh) {
rc = -ENOMEM;
goto out;
diff --git a/net/mctp/route.c b/net/mctp/route.c
index ecbbe4beb213..349fc650a805 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -227,7 +227,7 @@ static struct mctp_sk_key *mctp_key_alloc(struct mctp_sock *msk,
{
struct mctp_sk_key *key;
- key = kzalloc(sizeof(*key), gfp);
+ key = kzalloc_obj(*key, gfp);
if (!key)
return NULL;
@@ -675,7 +675,7 @@ static struct mctp_route *mctp_route_alloc(void)
{
struct mctp_route *rt;
- rt = kzalloc(sizeof(*rt), GFP_KERNEL);
+ rt = kzalloc_obj(*rt, GFP_KERNEL);
if (!rt)
return NULL;
diff --git a/net/mctp/test/utils.c b/net/mctp/test/utils.c
index 37f1ba62a2ab..922b2c353a4e 100644
--- a/net/mctp/test/utils.c
+++ b/net/mctp/test/utils.c
@@ -106,7 +106,7 @@ static struct mctp_test_route *mctp_route_test_alloc(void)
{
struct mctp_test_route *rt;
- rt = kzalloc(sizeof(*rt), GFP_KERNEL);
+ rt = kzalloc_obj(*rt, GFP_KERNEL);
if (!rt)
return NULL;
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 580aac112dd2..82d885b8478a 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1470,7 +1470,7 @@ static struct mpls_dev *mpls_add_dev(struct net_device *dev)
int err = -ENOMEM;
int i;
- mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+ mdev = kzalloc_obj(*mdev, GFP_KERNEL);
if (!mdev)
return ERR_PTR(err);
@@ -1977,7 +1977,7 @@ static int mpls_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh,
struct mpls_route_config *cfg;
int err;
- cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ cfg = kzalloc_obj(*cfg, GFP_KERNEL);
if (!cfg)
return -ENOMEM;
@@ -2002,7 +2002,7 @@ static int mpls_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
struct mpls_route_config *cfg;
int err;
- cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ cfg = kzalloc_obj(*cfg, GFP_KERNEL);
if (!cfg)
return -ENOMEM;
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index e2040c327af6..7298836469b3 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -388,7 +388,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
goto reset_timer;
}
- add_entry = kmalloc(sizeof(*add_entry), GFP_ATOMIC);
+ add_entry = kmalloc_obj(*add_entry, GFP_ATOMIC);
if (!add_entry)
return false;
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index f66129f1e649..7ef1d2bd26e4 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1842,7 +1842,7 @@ static struct mptcp_subflow_context *subflow_create_ctx(struct sock *sk,
struct inet_connection_sock *icsk = inet_csk(sk);
struct mptcp_subflow_context *ctx;
- ctx = kzalloc(sizeof(*ctx), priority);
+ ctx = kzalloc_obj(*ctx, priority);
if (!ctx)
return NULL;
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 446e4e3b9553..dec9812c3fbb 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -211,7 +211,7 @@ struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np, unsigned char id)
int index;
unsigned long flags;
- nc = kzalloc(sizeof(*nc), GFP_ATOMIC);
+ nc = kzalloc_obj(*nc, GFP_ATOMIC);
if (!nc)
return NULL;
@@ -285,7 +285,7 @@ struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp,
struct ncsi_package *np, *tmp;
unsigned long flags;
- np = kzalloc(sizeof(*np), GFP_ATOMIC);
+ np = kzalloc_obj(*np, GFP_ATOMIC);
if (!np)
return NULL;
@@ -1697,7 +1697,7 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
return -ENOSPC;
}
- vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
+ vlan = kzalloc_obj(*vlan, GFP_KERNEL);
if (!vlan)
return -ENOMEM;
@@ -1767,7 +1767,7 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
return nd;
/* Create NCSI device */
- ndp = kzalloc(sizeof(*ndp), GFP_ATOMIC);
+ ndp = kzalloc_obj(*ndp, GFP_ATOMIC);
if (!ndp)
return NULL;
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index cc20e6d56807..c3beef6155b6 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1077,7 +1077,7 @@ static int ip_set_create(struct sk_buff *skb, const struct nfnl_info *info,
/* First, and without any locks, allocate and initialize
* a normal base set structure.
*/
- set = kzalloc(sizeof(*set), GFP_KERNEL);
+ set = kzalloc_obj(*set, GFP_KERNEL);
if (!set)
return -ENOMEM;
spin_lock_init(&set->lock);
@@ -1135,7 +1135,7 @@ static int ip_set_create(struct sk_buff *skb, const struct nfnl_info *info,
/* Wraparound */
goto cleanup;
- list = kvcalloc(i, sizeof(struct ip_set *), GFP_KERNEL);
+ list = kvzalloc_objs(struct ip_set *, i, GFP_KERNEL);
if (!list)
goto cleanup;
/* nfnl mutex is held, both lists are valid */
@@ -2377,7 +2377,7 @@ ip_set_net_init(struct net *net)
if (inst->ip_set_max >= IPSET_INVALID_ID)
inst->ip_set_max = IPSET_INVALID_ID - 1;
- list = kvcalloc(inst->ip_set_max, sizeof(struct ip_set *), GFP_KERNEL);
+ list = kvzalloc_objs(struct ip_set *, inst->ip_set_max, GFP_KERNEL);
if (!list)
return -ENOMEM;
inst->is_deleted = false;
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 5e4453e9ef8e..181daa9c2019 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -998,7 +998,7 @@ resize:
/* Resize is in process and kernel side add, save values */
struct mtype_resize_ad *x;
- x = kzalloc(sizeof(struct mtype_resize_ad), GFP_ATOMIC);
+ x = kzalloc_obj(struct mtype_resize_ad, GFP_ATOMIC);
if (!x)
/* Don't bother */
goto out;
@@ -1086,8 +1086,7 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,
/* Resize is in process and kernel side del,
* save values
*/
- x = kzalloc(sizeof(struct mtype_resize_ad),
- GFP_ATOMIC);
+ x = kzalloc_obj(struct mtype_resize_ad, GFP_ATOMIC);
if (x) {
x->ad = IPSET_DEL;
memcpy(&x->d, value,
diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
index 13c7a08aa868..39165c014bd9 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -598,7 +598,7 @@ init_list_set(struct net *net, struct ip_set *set, u32 size)
{
struct list_set *map;
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (!map)
return false;
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 50cc492c7553..e05991ec49f3 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1510,8 +1510,8 @@ int __init ip_vs_conn_init(void)
*/
tab_array_size = array_size(ip_vs_conn_tab_size,
sizeof(*ip_vs_conn_tab));
- ip_vs_conn_tab = kvmalloc_array(ip_vs_conn_tab_size,
- sizeof(*ip_vs_conn_tab), GFP_KERNEL);
+ ip_vs_conn_tab = kvmalloc_objs(*ip_vs_conn_tab, ip_vs_conn_tab_size,
+ GFP_KERNEL);
if (!ip_vs_conn_tab)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 068702894377..d38867c52180 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -938,7 +938,7 @@ int ip_vs_stats_init_alloc(struct ip_vs_stats *s)
struct ip_vs_stats *ip_vs_stats_alloc(void)
{
- struct ip_vs_stats *s = kzalloc(sizeof(*s), GFP_KERNEL);
+ struct ip_vs_stats *s = kzalloc_obj(*s, GFP_KERNEL);
if (s && ip_vs_stats_init_alloc(s) >= 0)
return s;
@@ -1079,7 +1079,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
return -EINVAL;
}
- dest = kzalloc(sizeof(struct ip_vs_dest), GFP_KERNEL);
+ dest = kzalloc_obj(struct ip_vs_dest, GFP_KERNEL);
if (dest == NULL)
return -ENOMEM;
@@ -1421,7 +1421,7 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u,
ret_hooks = ret;
}
- svc = kzalloc(sizeof(struct ip_vs_service), GFP_KERNEL);
+ svc = kzalloc_obj(struct ip_vs_service, GFP_KERNEL);
if (svc == NULL) {
IP_VS_DBG(1, "%s(): no memory\n", __func__);
ret = -ENOMEM;
@@ -4439,7 +4439,7 @@ int __net_init ip_vs_control_net_init(struct netns_ipvs *ipvs)
INIT_DELAYED_WORK(&ipvs->est_reload_work, est_reload_work_handler);
/* procfs stats */
- ipvs->tot_stats = kzalloc(sizeof(*ipvs->tot_stats), GFP_KERNEL);
+ ipvs->tot_stats = kzalloc_obj(*ipvs->tot_stats, GFP_KERNEL);
if (!ipvs->tot_stats)
goto out;
if (ip_vs_stats_init_alloc(&ipvs->tot_stats->s) < 0)
diff --git a/net/netfilter/ipvs/ip_vs_dh.c b/net/netfilter/ipvs/ip_vs_dh.c
index bb7aca4601ff..ac1d6f5bfe8a 100644
--- a/net/netfilter/ipvs/ip_vs_dh.c
+++ b/net/netfilter/ipvs/ip_vs_dh.c
@@ -153,7 +153,7 @@ static int ip_vs_dh_init_svc(struct ip_vs_service *svc)
struct ip_vs_dh_state *s;
/* allocate the DH table for this service */
- s = kzalloc(sizeof(struct ip_vs_dh_state), GFP_KERNEL);
+ s = kzalloc_obj(struct ip_vs_dh_state, GFP_KERNEL);
if (s == NULL)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_est.c b/net/netfilter/ipvs/ip_vs_est.c
index 77f4f637ff67..06999a17519b 100644
--- a/net/netfilter/ipvs/ip_vs_est.c
+++ b/net/netfilter/ipvs/ip_vs_est.c
@@ -325,7 +325,7 @@ static int ip_vs_est_add_kthread(struct netns_ipvs *ipvs)
id = i;
}
- kd = kzalloc(sizeof(*kd), GFP_KERNEL);
+ kd = kzalloc_obj(*kd, GFP_KERNEL);
if (!kd)
goto out;
kd->ipvs = ipvs;
@@ -443,7 +443,7 @@ add_est:
td = rcu_dereference_protected(kd->ticks[row], 1);
if (!td) {
- td = kzalloc(sizeof(*td), GFP_KERNEL);
+ td = kzalloc_obj(*td, GFP_KERNEL);
if (!td) {
ret = -ENOMEM;
goto out;
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index e6c8ed0c92f6..36d91153712c 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -204,7 +204,7 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,
return en;
ip_vs_lblc_del(en);
}
- en = kmalloc(sizeof(*en), GFP_ATOMIC);
+ en = kmalloc_obj(*en, GFP_ATOMIC);
if (!en)
return NULL;
@@ -347,7 +347,7 @@ static int ip_vs_lblc_init_svc(struct ip_vs_service *svc)
/*
* Allocate the ip_vs_lblc_table for this service
*/
- tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
+ tbl = kmalloc_obj(*tbl, GFP_KERNEL);
if (tbl == NULL)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index a25cf7bb6185..eba6600decbe 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -107,7 +107,7 @@ static void ip_vs_dest_set_insert(struct ip_vs_dest_set *set,
}
}
- e = kmalloc(sizeof(*e), GFP_ATOMIC);
+ e = kmalloc_obj(*e, GFP_ATOMIC);
if (e == NULL)
return;
@@ -363,7 +363,7 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr,
en = ip_vs_lblcr_get(af, tbl, daddr);
if (!en) {
- en = kmalloc(sizeof(*en), GFP_ATOMIC);
+ en = kmalloc_obj(*en, GFP_ATOMIC);
if (!en)
return NULL;
@@ -510,7 +510,7 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
/*
* Allocate the ip_vs_lblcr_table for this service
*/
- tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
+ tbl = kmalloc_obj(*tbl, GFP_KERNEL);
if (tbl == NULL)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_mh.c b/net/netfilter/ipvs/ip_vs_mh.c
index f61f54004c9e..7f5be86bab4d 100644
--- a/net/netfilter/ipvs/ip_vs_mh.c
+++ b/net/netfilter/ipvs/ip_vs_mh.c
@@ -293,9 +293,8 @@ static int ip_vs_mh_reassign(struct ip_vs_mh_state *s,
return -EINVAL;
if (svc->num_dests >= 1) {
- s->dest_setup = kcalloc(svc->num_dests,
- sizeof(struct ip_vs_mh_dest_setup),
- GFP_KERNEL);
+ s->dest_setup = kzalloc_objs(struct ip_vs_mh_dest_setup,
+ svc->num_dests, GFP_KERNEL);
if (!s->dest_setup)
return -ENOMEM;
}
@@ -383,12 +382,12 @@ static int ip_vs_mh_init_svc(struct ip_vs_service *svc)
struct ip_vs_mh_state *s;
/* Allocate the MH table for this service */
- s = kzalloc(sizeof(*s), GFP_KERNEL);
+ s = kzalloc_obj(*s, GFP_KERNEL);
if (!s)
return -ENOMEM;
- s->lookup = kcalloc(IP_VS_MH_TAB_SIZE, sizeof(struct ip_vs_mh_lookup),
- GFP_KERNEL);
+ s->lookup = kzalloc_objs(struct ip_vs_mh_lookup, IP_VS_MH_TAB_SIZE,
+ GFP_KERNEL);
if (!s->lookup) {
kfree(s);
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_proto.c b/net/netfilter/ipvs/ip_vs_proto.c
index fd9dbca24c85..a62c1e8fc1da 100644
--- a/net/netfilter/ipvs/ip_vs_proto.c
+++ b/net/netfilter/ipvs/ip_vs_proto.c
@@ -66,7 +66,7 @@ register_ip_vs_proto_netns(struct netns_ipvs *ipvs, struct ip_vs_protocol *pp)
{
unsigned int hash = IP_VS_PROTO_HASH(pp->protocol);
struct ip_vs_proto_data *pd =
- kzalloc(sizeof(struct ip_vs_proto_data), GFP_KERNEL);
+ kzalloc_obj(struct ip_vs_proto_data, GFP_KERNEL);
if (!pd)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_sh.c b/net/netfilter/ipvs/ip_vs_sh.c
index 0e85e07e23b9..a4616433b445 100644
--- a/net/netfilter/ipvs/ip_vs_sh.c
+++ b/net/netfilter/ipvs/ip_vs_sh.c
@@ -229,7 +229,7 @@ static int ip_vs_sh_init_svc(struct ip_vs_service *svc)
struct ip_vs_sh_state *s;
/* allocate the SH table for this service */
- s = kzalloc(sizeof(struct ip_vs_sh_state), GFP_KERNEL);
+ s = kzalloc_obj(struct ip_vs_sh_state, GFP_KERNEL);
if (s == NULL)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index 54dd1514ac45..f83732777228 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -329,7 +329,7 @@ ip_vs_sync_buff_create(struct netns_ipvs *ipvs, unsigned int len)
{
struct ip_vs_sync_buff *sb;
- if (!(sb=kmalloc(sizeof(struct ip_vs_sync_buff), GFP_ATOMIC)))
+ if (!(sb=kmalloc_obj(struct ip_vs_sync_buff, GFP_ATOMIC)))
return NULL;
len = max_t(unsigned int, len + sizeof(struct ip_vs_sync_mesg),
@@ -417,7 +417,7 @@ ip_vs_sync_buff_create_v0(struct netns_ipvs *ipvs, unsigned int len)
struct ip_vs_sync_buff *sb;
struct ip_vs_sync_mesg_v0 *mesg;
- if (!(sb=kmalloc(sizeof(struct ip_vs_sync_buff), GFP_ATOMIC)))
+ if (!(sb=kmalloc_obj(struct ip_vs_sync_buff, GFP_ATOMIC)))
return NULL;
len = max_t(unsigned int, len + sizeof(struct ip_vs_sync_mesg_v0),
@@ -1827,7 +1827,7 @@ int start_sync_thread(struct netns_ipvs *ipvs, struct ipvs_sync_daemon_cfg *c,
struct ipvs_master_sync_state *ms;
result = -ENOMEM;
- ipvs->ms = kcalloc(count, sizeof(ipvs->ms[0]), GFP_KERNEL);
+ ipvs->ms = kzalloc_objs(ipvs->ms[0], count, GFP_KERNEL);
if (!ipvs->ms)
goto out;
ms = ipvs->ms;
@@ -1841,8 +1841,7 @@ int start_sync_thread(struct netns_ipvs *ipvs, struct ipvs_sync_daemon_cfg *c,
}
}
result = -ENOMEM;
- ti = kcalloc(count, sizeof(struct ip_vs_sync_thread_data),
- GFP_KERNEL);
+ ti = kzalloc_objs(struct ip_vs_sync_thread_data, count, GFP_KERNEL);
if (!ti)
goto out;
diff --git a/net/netfilter/ipvs/ip_vs_wrr.c b/net/netfilter/ipvs/ip_vs_wrr.c
index 99f09cbf2d9b..58c65af9830a 100644
--- a/net/netfilter/ipvs/ip_vs_wrr.c
+++ b/net/netfilter/ipvs/ip_vs_wrr.c
@@ -109,7 +109,7 @@ static int ip_vs_wrr_init_svc(struct ip_vs_service *svc)
/*
* Allocate the mark variable for WRR scheduling
*/
- mark = kmalloc(sizeof(struct ip_vs_wrr_mark), GFP_KERNEL);
+ mark = kmalloc_obj(struct ip_vs_wrr_mark, GFP_KERNEL);
if (mark == NULL)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 4389bfe3050d..3601eb86d025 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -57,7 +57,7 @@ enum {
static inline struct ip_vs_dest_dst *ip_vs_dest_dst_alloc(void)
{
- return kmalloc(sizeof(struct ip_vs_dest_dst), GFP_ATOMIC);
+ return kmalloc_obj(struct ip_vs_dest_dst, GFP_ATOMIC);
}
static inline void ip_vs_dest_dst_free(struct ip_vs_dest_dst *dest_dst)
diff --git a/net/netfilter/nf_bpf_link.c b/net/netfilter/nf_bpf_link.c
index 46e667a50d98..6f3a6411f4af 100644
--- a/net/netfilter/nf_bpf_link.c
+++ b/net/netfilter/nf_bpf_link.c
@@ -221,7 +221,7 @@ int bpf_nf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
if (err)
return err;
- link = kzalloc(sizeof(*link), GFP_USER);
+ link = kzalloc_obj(*link, GFP_USER);
if (!link)
return -ENOMEM;
diff --git a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c
index 14e62b3263cd..520781335fc8 100644
--- a/net/netfilter/nf_conncount.c
+++ b/net/netfilter/nf_conncount.c
@@ -632,7 +632,7 @@ struct nf_conncount_data *nf_conncount_init(struct net *net, unsigned int keylen
net_get_random_once(&conncount_rnd, sizeof(conncount_rnd));
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data, GFP_KERNEL);
if (!data)
return ERR_PTR(-ENOMEM);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index d1f8eb725d42..42da155ab028 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -536,7 +536,7 @@ struct nf_conn *nf_ct_tmpl_alloc(struct net *net,
if (tmpl != p)
tmpl->proto.tmpl_padto = (char *)tmpl - (char *)p;
} else {
- tmpl = kzalloc(sizeof(*tmpl), flags);
+ tmpl = kzalloc_obj(*tmpl, flags);
if (!tmpl)
return NULL;
}
@@ -2535,7 +2535,7 @@ void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls)
if (nr_slots > (INT_MAX / sizeof(struct hlist_nulls_head)))
return NULL;
- hash = kvcalloc(nr_slots, sizeof(struct hlist_nulls_head), GFP_KERNEL);
+ hash = kvzalloc_objs(struct hlist_nulls_head, nr_slots, GFP_KERNEL);
if (hash && nulls)
for (i = 0; i < nr_slots; i++)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 662f6bbfa805..cd1ab584fb2f 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -999,7 +999,7 @@ ctnetlink_alloc_filter(const struct nlattr * const cda[], u8 family)
return ERR_PTR(-EOPNOTSUPP);
#endif
- filter = kzalloc(sizeof(*filter), GFP_KERNEL);
+ filter = kzalloc_obj(*filter, GFP_KERNEL);
if (filter == NULL)
return ERR_PTR(-ENOMEM);
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
index b894bb7a97ad..94c19bc4edc5 100644
--- a/net/netfilter/nf_conntrack_proto_gre.c
+++ b/net/netfilter/nf_conntrack_proto_gre.c
@@ -108,7 +108,7 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
return -EEXIST;
}
- km = kmalloc(sizeof(*km), GFP_ATOMIC);
+ km = kmalloc_obj(*km, GFP_ATOMIC);
if (!km)
return -ENOMEM;
memcpy(&km->tuple, t, sizeof(*t));
diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c
index b1966b68c48a..c95a18ca178b 100644
--- a/net/netfilter/nf_flow_table_offload.c
+++ b/net/netfilter/nf_flow_table_offload.c
@@ -741,7 +741,7 @@ nf_flow_offload_rule_alloc(struct net *net,
struct nf_flow_rule *flow_rule;
int err = -ENOMEM;
- flow_rule = kzalloc(sizeof(*flow_rule), GFP_KERNEL);
+ flow_rule = kzalloc_obj(*flow_rule, GFP_KERNEL);
if (!flow_rule)
goto err_flow;
@@ -1022,7 +1022,7 @@ nf_flow_offload_work_alloc(struct nf_flowtable *flowtable,
if (test_and_set_bit(NF_FLOW_HW_PENDING, &flow->flags))
return NULL;
- offload = kmalloc(sizeof(struct flow_offload_work), GFP_ATOMIC);
+ offload = kmalloc_obj(struct flow_offload_work, GFP_ATOMIC);
if (!offload) {
clear_bit(NF_FLOW_HW_PENDING, &flow->flags);
return NULL;
diff --git a/net/netfilter/nf_flow_table_xdp.c b/net/netfilter/nf_flow_table_xdp.c
index e1252d042699..86ac65e9b579 100644
--- a/net/netfilter/nf_flow_table_xdp.c
+++ b/net/netfilter/nf_flow_table_xdp.c
@@ -54,7 +54,7 @@ static int nf_flowtable_by_dev_insert(struct nf_flowtable *ft,
unsigned long key = (unsigned long)dev;
struct flow_offload_xdp_ft *ft_elem;
- ft_elem = kzalloc(sizeof(*ft_elem), GFP_KERNEL_ACCOUNT);
+ ft_elem = kzalloc_obj(*ft_elem, GFP_KERNEL_ACCOUNT);
if (!ft_elem)
return -ENOMEM;
@@ -70,7 +70,7 @@ static int nf_flowtable_by_dev_insert(struct nf_flowtable *ft,
}
if (!elem) {
- elem = kzalloc(sizeof(*elem), GFP_KERNEL_ACCOUNT);
+ elem = kzalloc_obj(*elem, GFP_KERNEL_ACCOUNT);
if (!elem)
goto err_unlock;
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index 62cf6a30875e..f4d80654dfe6 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -317,7 +317,7 @@ EXPORT_SYMBOL_GPL(nf_log_buf_add);
struct nf_log_buf *nf_log_buf_open(void)
{
- struct nf_log_buf *m = kmalloc(sizeof(*m), GFP_ATOMIC);
+ struct nf_log_buf *m = kmalloc_obj(*m, GFP_ATOMIC);
if (unlikely(!m)) {
local_bh_disable();
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index e6b24586d2fe..b4053e5ee07f 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -1213,7 +1213,7 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops,
}
for (i = 0; i < ops_count; i++) {
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (priv) {
nat_ops[i].priv = priv;
continue;
diff --git a/net/netfilter/nf_nat_masquerade.c b/net/netfilter/nf_nat_masquerade.c
index 1a506b0c6511..a5a23c03fda9 100644
--- a/net/netfilter/nf_nat_masquerade.c
+++ b/net/netfilter/nf_nat_masquerade.c
@@ -115,7 +115,7 @@ static void nf_nat_masq_schedule(struct net *net, union nf_inet_addr *addr,
if (!try_module_get(THIS_MODULE))
goto err_module;
- w = kzalloc(sizeof(*w), gfp_flags);
+ w = kzalloc_obj(*w, gfp_flags);
if (w) {
/* We can overshoot MAX_MASQ_WORKER_COUNT, no big deal */
atomic_inc(&masq_worker_count);
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 0c5a4855b97d..6044f1ec6953 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1104,7 +1104,7 @@ __printf(2, 3) int nft_request_module(struct net *net, const char *fmt,
}
}
- req = kmalloc(sizeof(*req), GFP_KERNEL);
+ req = kmalloc_obj(*req, GFP_KERNEL);
if (!req)
return -ENOMEM;
@@ -1624,7 +1624,7 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
}
err = -ENOMEM;
- table = kzalloc(sizeof(*table), GFP_KERNEL_ACCOUNT);
+ table = kzalloc_obj(*table, GFP_KERNEL_ACCOUNT);
if (table == NULL)
goto err_kzalloc;
@@ -2348,7 +2348,7 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net,
struct nft_hook *hook;
int err;
- hook = kzalloc(sizeof(struct nft_hook), GFP_KERNEL_ACCOUNT);
+ hook = kzalloc_obj(struct nft_hook, GFP_KERNEL_ACCOUNT);
if (!hook)
return ERR_PTR(-ENOMEM);
@@ -2369,7 +2369,7 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net,
if (strncmp(dev->name, hook->ifname, hook->ifnamelen))
continue;
- ops = kzalloc(sizeof(struct nf_hook_ops), GFP_KERNEL_ACCOUNT);
+ ops = kzalloc_obj(struct nf_hook_ops, GFP_KERNEL_ACCOUNT);
if (!ops) {
err = -ENOMEM;
goto err_hook_free;
@@ -2716,7 +2716,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 policy,
if (err < 0)
return err;
- basechain = kzalloc(sizeof(*basechain), GFP_KERNEL_ACCOUNT);
+ basechain = kzalloc_obj(*basechain, GFP_KERNEL_ACCOUNT);
if (basechain == NULL) {
nft_chain_release_hook(&hook);
return -ENOMEM;
@@ -2748,7 +2748,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 policy,
if (flags & NFT_CHAIN_HW_OFFLOAD)
return -EOPNOTSUPP;
- chain = kzalloc(sizeof(*chain), GFP_KERNEL_ACCOUNT);
+ chain = kzalloc_obj(*chain, GFP_KERNEL_ACCOUNT);
if (chain == NULL)
return -ENOMEM;
@@ -4315,9 +4315,8 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
n = 0;
size = 0;
if (nla[NFTA_RULE_EXPRESSIONS]) {
- expr_info = kvmalloc_array(NFT_RULE_MAXEXPRS,
- sizeof(struct nft_expr_info),
- GFP_KERNEL);
+ expr_info = kvmalloc_objs(struct nft_expr_info,
+ NFT_RULE_MAXEXPRS, GFP_KERNEL);
if (!expr_info)
return -ENOMEM;
@@ -6929,7 +6928,7 @@ static int nft_setelem_catchall_insert(const struct net *net,
}
}
- catchall = kmalloc(sizeof(*catchall), GFP_KERNEL_ACCOUNT);
+ catchall = kmalloc_obj(*catchall, GFP_KERNEL_ACCOUNT);
if (!catchall)
return -ENOMEM;
@@ -8076,7 +8075,7 @@ static struct nft_object *nft_obj_init(const struct nft_ctx *ctx,
struct nft_object *obj;
int err = -ENOMEM;
- tb = kmalloc_array(type->maxattr + 1, sizeof(*tb), GFP_KERNEL);
+ tb = kmalloc_objs(*tb, type->maxattr + 1, GFP_KERNEL);
if (!tb)
goto err1;
@@ -9145,7 +9144,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb,
if (!nft_use_inc(&table->use))
return -EMFILE;
- flowtable = kzalloc(sizeof(*flowtable), GFP_KERNEL_ACCOUNT);
+ flowtable = kzalloc_obj(*flowtable, GFP_KERNEL_ACCOUNT);
if (!flowtable) {
err = -ENOMEM;
goto flowtable_alloc;
@@ -9465,7 +9464,7 @@ static int nf_tables_dump_flowtable_start(struct netlink_callback *cb)
struct nft_flowtable_filter *filter = NULL;
if (nla[NFTA_FLOWTABLE_TABLE]) {
- filter = kzalloc(sizeof(*filter), GFP_ATOMIC);
+ filter = kzalloc_obj(*filter, GFP_ATOMIC);
if (!filter)
return -ENOMEM;
@@ -9682,8 +9681,8 @@ static int nft_flowtable_event(unsigned long event, struct net_device *dev,
if (!match || (changename && ops))
continue;
- ops = kzalloc(sizeof(struct nf_hook_ops),
- GFP_KERNEL_ACCOUNT);
+ ops = kzalloc_obj(struct nf_hook_ops,
+ GFP_KERNEL_ACCOUNT);
if (!ops)
return 1;
@@ -10453,7 +10452,7 @@ struct nft_trans_gc *nft_trans_gc_alloc(struct nft_set *set,
struct net *net = read_pnet(&set->net);
struct nft_trans_gc *trans;
- trans = kzalloc(sizeof(*trans), gfp);
+ trans = kzalloc_obj(*trans, gfp);
if (!trans)
return NULL;
@@ -10689,7 +10688,7 @@ static int nf_tables_commit_audit_alloc(struct list_head *adl,
if (adp->table == table)
return 0;
}
- adp = kzalloc(sizeof(*adp), GFP_KERNEL);
+ adp = kzalloc_obj(*adp, GFP_KERNEL);
if (!adp)
return -ENOMEM;
adp->table = table;
diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index fd30e205de84..42f11cb0c0f5 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -11,7 +11,7 @@ static struct nft_flow_rule *nft_flow_rule_alloc(int num_actions)
{
struct nft_flow_rule *flow;
- flow = kzalloc(sizeof(struct nft_flow_rule), GFP_KERNEL);
+ flow = kzalloc_obj(struct nft_flow_rule, GFP_KERNEL);
if (!flow)
return NULL;
@@ -111,7 +111,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net,
expr = nft_expr_first(rule);
- ctx = kzalloc(sizeof(struct nft_offload_ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(struct nft_offload_ctx, GFP_KERNEL);
if (!ctx) {
err = -ENOMEM;
goto err_out;
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 811d02b4c4f7..39c3d54de9f6 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -325,7 +325,7 @@ static int nfnl_err_add(struct list_head *list, struct nlmsghdr *nlh, int err,
{
struct nfnl_err *nfnl_err;
- nfnl_err = kmalloc(sizeof(struct nfnl_err), GFP_KERNEL);
+ nfnl_err = kmalloc_obj(struct nfnl_err, GFP_KERNEL);
if (nfnl_err == NULL)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index 505f46a32173..bd3d960a1adb 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -260,7 +260,7 @@ static int nfnl_acct_start(struct netlink_callback *cb)
if (!tb[NFACCT_FILTER_MASK] || !tb[NFACCT_FILTER_VALUE])
return -EINVAL;
- filter = kzalloc(sizeof(struct nfacct_filter), GFP_KERNEL);
+ filter = kzalloc_obj(struct nfacct_filter, GFP_KERNEL);
if (!filter)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index 97248963a7d3..1a3d333e45dd 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -192,9 +192,8 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper,
if (class_max > NF_CT_MAX_EXPECT_CLASSES)
return -EOVERFLOW;
- expect_policy = kcalloc(class_max,
- sizeof(struct nf_conntrack_expect_policy),
- GFP_KERNEL);
+ expect_policy = kzalloc_objs(struct nf_conntrack_expect_policy,
+ class_max, GFP_KERNEL);
if (expect_policy == NULL)
return -ENOMEM;
@@ -228,7 +227,7 @@ nfnl_cthelper_create(const struct nlattr * const tb[],
if (!tb[NFCTH_TUPLE] || !tb[NFCTH_POLICY] || !tb[NFCTH_PRIV_DATA_LEN])
return -EINVAL;
- nfcth = kzalloc(sizeof(*nfcth), GFP_KERNEL);
+ nfcth = kzalloc_obj(*nfcth, GFP_KERNEL);
if (nfcth == NULL)
return -ENOMEM;
helper = &nfcth->helper;
@@ -323,8 +322,8 @@ static int nfnl_cthelper_update_policy_all(struct nlattr *tb[],
struct nf_conntrack_expect_policy *policy;
int i, ret = 0;
- new_policy = kmalloc_array(helper->expect_class_max + 1,
- sizeof(*new_policy), GFP_KERNEL);
+ new_policy = kmalloc_objs(*new_policy, helper->expect_class_max + 1,
+ GFP_KERNEL);
if (!new_policy)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 38d75484e531..6b91f9d3161a 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -74,8 +74,7 @@ ctnl_timeout_parse_policy(void *timeout,
struct nlattr **tb;
int ret = 0;
- tb = kcalloc(l4proto->ctnl_timeout.nlattr_max + 1, sizeof(*tb),
- GFP_KERNEL);
+ tb = kzalloc_objs(*tb, l4proto->ctnl_timeout.nlattr_max + 1, GFP_KERNEL);
if (!tb)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_hook.c b/net/netfilter/nfnetlink_hook.c
index 92d869317cba..c2a572d86853 100644
--- a/net/netfilter/nfnetlink_hook.c
+++ b/net/netfilter/nfnetlink_hook.c
@@ -408,7 +408,7 @@ static int nfnl_hook_dump_start(struct netlink_callback *cb)
if (head && IS_ERR(head))
return PTR_ERR(head);
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index bfcb9cd335bf..b35a90955e2e 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -179,7 +179,7 @@ instance_create(struct net *net, u_int16_t group_num,
goto out_unlock;
}
- inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
+ inst = kzalloc_obj(*inst, GFP_ATOMIC);
if (!inst) {
err = -ENOMEM;
goto out_unlock;
diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c
index c0fc431991e8..1ba43e562a5e 100644
--- a/net/netfilter/nfnetlink_osf.c
+++ b/net/netfilter/nfnetlink_osf.c
@@ -323,7 +323,7 @@ static int nfnl_osf_add_callback(struct sk_buff *skb,
!memchr(f->version, 0, MAXGENRELEN))
return -EINVAL;
- kf = kmalloc(sizeof(struct nf_osf_finger), GFP_KERNEL);
+ kf = kmalloc_obj(struct nf_osf_finger, GFP_KERNEL);
if (!kf)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index f1c8049861a6..7f5248b5f1ee 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -178,7 +178,7 @@ instance_create(struct nfnl_queue_net *q, u_int16_t queue_num, u32 portid)
unsigned int h;
int err;
- inst = kzalloc(sizeof(*inst), GFP_KERNEL_ACCOUNT);
+ inst = kzalloc_obj(*inst, GFP_KERNEL_ACCOUNT);
if (!inst)
return ERR_PTR(-ENOMEM);
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 08f620311b03..27cc983a7cdf 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -815,7 +815,7 @@ nft_match_select_ops(const struct nft_ctx *ctx,
goto err;
}
- ops = kzalloc(sizeof(struct nft_expr_ops), GFP_KERNEL_ACCOUNT);
+ ops = kzalloc_obj(struct nft_expr_ops, GFP_KERNEL_ACCOUNT);
if (!ops) {
err = -ENOMEM;
goto err;
@@ -905,7 +905,7 @@ nft_target_select_ops(const struct nft_ctx *ctx,
goto err;
}
- ops = kzalloc(sizeof(struct nft_expr_ops), GFP_KERNEL_ACCOUNT);
+ ops = kzalloc_obj(struct nft_expr_ops, GFP_KERNEL_ACCOUNT);
if (!ops) {
err = -ENOMEM;
goto err;
diff --git a/net/netfilter/nft_connlimit.c b/net/netfilter/nft_connlimit.c
index 657764774a2d..43357f99eb00 100644
--- a/net/netfilter/nft_connlimit.c
+++ b/net/netfilter/nft_connlimit.c
@@ -71,7 +71,7 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx,
invert = true;
}
- priv->list = kmalloc(sizeof(*priv->list), GFP_KERNEL_ACCOUNT);
+ priv->list = kmalloc_obj(*priv->list, GFP_KERNEL_ACCOUNT);
if (!priv->list)
return -ENOMEM;
@@ -220,7 +220,7 @@ static int nft_connlimit_clone(struct nft_expr *dst, const struct nft_expr *src,
struct nft_connlimit *priv_dst = nft_expr_priv(dst);
struct nft_connlimit *priv_src = nft_expr_priv(src);
- priv_dst->list = kmalloc(sizeof(*priv_dst->list), gfp);
+ priv_dst->list = kmalloc_obj(*priv_dst->list, gfp);
if (!priv_dst->list)
return -ENOMEM;
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index 6f2ae7cad731..8d7f6c8e8aad 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -894,8 +894,7 @@ nft_ct_timeout_parse_policy(void *timeouts,
struct nlattr **tb;
int ret = 0;
- tb = kcalloc(l4proto->ctnl_timeout.nlattr_max + 1, sizeof(*tb),
- GFP_KERNEL);
+ tb = kzalloc_objs(*tb, l4proto->ctnl_timeout.nlattr_max + 1, GFP_KERNEL);
if (!tb)
return -ENOMEM;
diff --git a/net/netfilter/nft_last.c b/net/netfilter/nft_last.c
index de1b6066bfa8..20706be12807 100644
--- a/net/netfilter/nft_last.c
+++ b/net/netfilter/nft_last.c
@@ -30,7 +30,7 @@ static int nft_last_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
u64 last_jiffies;
int err;
- last = kzalloc(sizeof(*last), GFP_KERNEL_ACCOUNT);
+ last = kzalloc_obj(*last, GFP_KERNEL_ACCOUNT);
if (!last)
return -ENOMEM;
@@ -107,7 +107,7 @@ static int nft_last_clone(struct nft_expr *dst, const struct nft_expr *src, gfp_
struct nft_last_priv *priv_dst = nft_expr_priv(dst);
struct nft_last_priv *priv_src = nft_expr_priv(src);
- priv_dst->last = kzalloc(sizeof(*priv_dst->last), gfp);
+ priv_dst->last = kzalloc_obj(*priv_dst->last, gfp);
if (!priv_dst->last)
return -ENOMEM;
diff --git a/net/netfilter/nft_limit.c b/net/netfilter/nft_limit.c
index 21d26b79b460..f3b1f791942b 100644
--- a/net/netfilter/nft_limit.c
+++ b/net/netfilter/nft_limit.c
@@ -110,7 +110,7 @@ static int nft_limit_init(struct nft_limit_priv *priv,
invert = true;
}
- priv->limit = kmalloc(sizeof(*priv->limit), GFP_KERNEL_ACCOUNT);
+ priv->limit = kmalloc_obj(*priv->limit, GFP_KERNEL_ACCOUNT);
if (!priv->limit)
return -ENOMEM;
@@ -158,7 +158,7 @@ static int nft_limit_clone(struct nft_limit_priv *priv_dst,
priv_dst->burst = priv_src->burst;
priv_dst->invert = priv_src->invert;
- priv_dst->limit = kmalloc(sizeof(*priv_dst->limit), gfp);
+ priv_dst->limit = kmalloc_obj(*priv_dst->limit, gfp);
if (!priv_dst->limit)
return -ENOMEM;
diff --git a/net/netfilter/nft_numgen.c b/net/netfilter/nft_numgen.c
index bd058babfc82..0a39e51ec9b7 100644
--- a/net/netfilter/nft_numgen.c
+++ b/net/netfilter/nft_numgen.c
@@ -66,7 +66,7 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,
if (priv->offset + priv->modulus - 1 < priv->offset)
return -EOVERFLOW;
- priv->counter = kmalloc(sizeof(*priv->counter), GFP_KERNEL_ACCOUNT);
+ priv->counter = kmalloc_obj(*priv->counter, GFP_KERNEL_ACCOUNT);
if (!priv->counter)
return -ENOMEM;
diff --git a/net/netfilter/nft_quota.c b/net/netfilter/nft_quota.c
index cb6c0e04ff67..2390a993aed9 100644
--- a/net/netfilter/nft_quota.c
+++ b/net/netfilter/nft_quota.c
@@ -96,7 +96,7 @@ static int nft_quota_do_init(const struct nlattr * const tb[],
return -EOPNOTSUPP;
}
- priv->consumed = kmalloc(sizeof(*priv->consumed), GFP_KERNEL_ACCOUNT);
+ priv->consumed = kmalloc_obj(*priv->consumed, GFP_KERNEL_ACCOUNT);
if (!priv->consumed)
return -ENOMEM;
@@ -248,7 +248,7 @@ static int nft_quota_clone(struct nft_expr *dst, const struct nft_expr *src, gfp
priv_dst->quota = priv_src->quota;
priv_dst->flags = priv_src->flags;
- priv_dst->consumed = kmalloc(sizeof(*priv_dst->consumed), gfp);
+ priv_dst->consumed = kmalloc_obj(*priv_dst->consumed, gfp);
if (!priv_dst->consumed)
return -ENOMEM;
diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
index 18e1903b1d3d..6341b5bcb4cf 100644
--- a/net/netfilter/nft_set_pipapo.c
+++ b/net/netfilter/nft_set_pipapo.c
@@ -652,7 +652,7 @@ static int pipapo_realloc_mt(struct nft_pipapo_field *f,
if (rules_alloc > (INT_MAX / sizeof(*new_mt)))
return -ENOMEM;
- new_mt = kvmalloc_array(rules_alloc, sizeof(*new_mt), GFP_KERNEL_ACCOUNT);
+ new_mt = kvmalloc_objs(*new_mt, rules_alloc, GFP_KERNEL_ACCOUNT);
if (!new_mt)
return -ENOMEM;
@@ -1413,7 +1413,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
struct nft_pipapo_match *new;
int i;
- new = kmalloc(struct_size(new, f, old->field_count), GFP_KERNEL_ACCOUNT);
+ new = kmalloc_flex(*new, f, old->field_count, GFP_KERNEL_ACCOUNT);
if (!new)
return NULL;
@@ -1460,9 +1460,8 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
if (src->rules_alloc > (INT_MAX / sizeof(*src->mt)))
goto out_mt;
- dst->mt = kvmalloc_array(src->rules_alloc,
- sizeof(*src->mt),
- GFP_KERNEL_ACCOUNT);
+ dst->mt = kvmalloc_objs(*src->mt, src->rules_alloc,
+ GFP_KERNEL_ACCOUNT);
if (!dst->mt)
goto out_mt;
@@ -2237,7 +2236,7 @@ static int nft_pipapo_init(const struct nft_set *set,
if (field_count > NFT_PIPAPO_MAX_FIELDS)
return -EINVAL;
- m = kmalloc(struct_size(m, f, field_count), GFP_KERNEL);
+ m = kmalloc_flex(*m, f, field_count, GFP_KERNEL);
if (!m)
return -ENOMEM;
diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
index 644d4b916705..3f02e4478216 100644
--- a/net/netfilter/nft_set_rbtree.c
+++ b/net/netfilter/nft_set_rbtree.c
@@ -586,8 +586,8 @@ static int nft_array_intervals_alloc(struct nft_array *array, u32 max_intervals)
{
struct nft_array_interval *intervals;
- intervals = kvcalloc(max_intervals, sizeof(struct nft_array_interval),
- GFP_KERNEL_ACCOUNT);
+ intervals = kvzalloc_objs(struct nft_array_interval, max_intervals,
+ GFP_KERNEL_ACCOUNT);
if (!intervals)
return -ENOMEM;
@@ -604,7 +604,7 @@ static struct nft_array *nft_array_alloc(u32 max_intervals)
{
struct nft_array *array;
- array = kzalloc(sizeof(*array), GFP_KERNEL_ACCOUNT);
+ array = kzalloc_obj(*array, GFP_KERNEL_ACCOUNT);
if (!array)
return NULL;
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 48105ea3df15..f5d720c9ee32 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1742,7 +1742,7 @@ xt_hook_ops_alloc(const struct xt_table *table, nf_hookfn *fn)
if (!num_hooks)
return ERR_PTR(-EINVAL);
- ops = kcalloc(num_hooks, sizeof(*ops), GFP_KERNEL);
+ ops = kzalloc_objs(*ops, num_hooks, GFP_KERNEL);
if (ops == NULL)
return ERR_PTR(-ENOMEM);
@@ -1775,7 +1775,7 @@ int xt_register_template(const struct xt_table *table,
}
ret = -ENOMEM;
- t = kzalloc(sizeof(*t), GFP_KERNEL);
+ t = kzalloc_obj(*t, GFP_KERNEL);
if (!t)
goto out_unlock;
@@ -1993,7 +1993,7 @@ static int __init xt_init(void)
}
}
- xt = kcalloc(NFPROTO_NUMPROTO, sizeof(struct xt_af), GFP_KERNEL);
+ xt = kzalloc_objs(struct xt_af, NFPROTO_NUMPROTO, GFP_KERNEL);
if (!xt)
return -ENOMEM;
diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
index d73957592c9d..746abeee6775 100644
--- a/net/netfilter/xt_IDLETIMER.c
+++ b/net/netfilter/xt_IDLETIMER.c
@@ -135,7 +135,7 @@ static int idletimer_tg_create(struct idletimer_tg_info *info)
{
int ret;
- info->timer = kzalloc(sizeof(*info->timer), GFP_KERNEL);
+ info->timer = kzalloc_obj(*info->timer, GFP_KERNEL);
if (!info->timer) {
ret = -ENOMEM;
goto out;
@@ -184,7 +184,7 @@ static int idletimer_tg_create_v1(struct idletimer_tg_info_v1 *info)
{
int ret;
- info->timer = kmalloc(sizeof(*info->timer), GFP_KERNEL);
+ info->timer = kmalloc_obj(*info->timer, GFP_KERNEL);
if (!info->timer) {
ret = -ENOMEM;
goto out;
diff --git a/net/netfilter/xt_LED.c b/net/netfilter/xt_LED.c
index 90dcf088071a..6b21810e1b97 100644
--- a/net/netfilter/xt_LED.c
+++ b/net/netfilter/xt_LED.c
@@ -111,7 +111,7 @@ static int led_tg_check(const struct xt_tgchk_param *par)
}
err = -ENOMEM;
- ledinternal = kzalloc(sizeof(struct xt_led_info_internal), GFP_KERNEL);
+ ledinternal = kzalloc_obj(struct xt_led_info_internal, GFP_KERNEL);
if (!ledinternal)
goto exit_mutex_only;
diff --git a/net/netfilter/xt_RATEEST.c b/net/netfilter/xt_RATEEST.c
index 4f49cfc27831..d75b1e101a5b 100644
--- a/net/netfilter/xt_RATEEST.c
+++ b/net/netfilter/xt_RATEEST.c
@@ -139,7 +139,7 @@ static int xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
}
ret = -ENOMEM;
- est = kzalloc(sizeof(*est), GFP_KERNEL);
+ est = kzalloc_obj(*est, GFP_KERNEL);
if (!est)
goto err1;
diff --git a/net/netfilter/xt_TEE.c b/net/netfilter/xt_TEE.c
index a5ebd5640457..c6044ea31d16 100644
--- a/net/netfilter/xt_TEE.c
+++ b/net/netfilter/xt_TEE.c
@@ -106,7 +106,7 @@ static int tee_tg_check(const struct xt_tgchk_param *par)
if (info->oif[sizeof(info->oif)-1] != '\0')
return -EINVAL;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 3b507694e81e..64ed12a32906 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -293,7 +293,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
if (size < 16)
size = 16;
}
- hinfo = kvmalloc(struct_size(hinfo, hash, size), GFP_KERNEL);
+ hinfo = kvmalloc_flex(*hinfo, hash, size, GFP_KERNEL);
if (hinfo == NULL)
return -ENOMEM;
*out_hinfo = hinfo;
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c
index 8b4fd27857f2..203f8bb28132 100644
--- a/net/netfilter/xt_limit.c
+++ b/net/netfilter/xt_limit.c
@@ -115,7 +115,7 @@ static int limit_mt_check(const struct xt_mtchk_param *par)
return -ERANGE;
}
- priv = kmalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kmalloc_obj(*priv, GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
diff --git a/net/netfilter/xt_quota.c b/net/netfilter/xt_quota.c
index 4452cc93b990..7952a4ef4c51 100644
--- a/net/netfilter/xt_quota.c
+++ b/net/netfilter/xt_quota.c
@@ -50,7 +50,7 @@ static int quota_mt_check(const struct xt_mtchk_param *par)
if (q->flags & ~XT_QUOTA_MASK)
return -EINVAL;
- q->master = kmalloc(sizeof(*q->master), GFP_KERNEL);
+ q->master = kmalloc_obj(*q->master, GFP_KERNEL);
if (q->master == NULL)
return -ENOMEM;
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 588a5e6ad899..c9a1cc591171 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -188,7 +188,7 @@ recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr,
}
nstamps_max += 1;
- e = kmalloc(struct_size(e, stamps, nstamps_max), GFP_ATOMIC);
+ e = kmalloc_flex(*e, stamps, nstamps_max, GFP_ATOMIC);
if (e == NULL)
return NULL;
memcpy(&e->addr, addr, sizeof(e->addr));
@@ -391,7 +391,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
goto out;
}
- t = kvzalloc(struct_size(t, iphash, ip_list_hash_size), GFP_KERNEL);
+ t = kvzalloc_flex(*t, iphash, ip_list_hash_size, GFP_KERNEL);
if (t == NULL) {
ret = -ENOMEM;
goto out;
diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
index b26c1dcfc27b..e80ddc317ca5 100644
--- a/net/netfilter/xt_statistic.c
+++ b/net/netfilter/xt_statistic.c
@@ -58,7 +58,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
info->flags & ~XT_STATISTIC_MASK)
return -EINVAL;
- info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
+ info->master = kzalloc_obj(*info->master, GFP_KERNEL);
if (info->master == NULL)
return -ENOMEM;
atomic_set(&info->master->count, info->u.nth.count);
diff --git a/net/netlabel/netlabel_calipso.c b/net/netlabel/netlabel_calipso.c
index a07c2216d28b..fae0bee5c065 100644
--- a/net/netlabel/netlabel_calipso.c
+++ b/net/netlabel/netlabel_calipso.c
@@ -95,7 +95,7 @@ static int netlbl_calipso_add_pass(struct genl_info *info,
int ret_val;
struct calipso_doi *doi_def = NULL;
- doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL);
+ doi_def = kmalloc_obj(*doi_def, GFP_KERNEL);
if (!doi_def)
return -ENOMEM;
doi_def->type = CALIPSO_MAP_PASS;
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index fa08ee75ac06..526f3dc3e67a 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -139,10 +139,10 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
NULL) != 0)
return -EINVAL;
- doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL);
+ doi_def = kmalloc_obj(*doi_def, GFP_KERNEL);
if (doi_def == NULL)
return -ENOMEM;
- doi_def->map.std = kzalloc(sizeof(*doi_def->map.std), GFP_KERNEL);
+ doi_def->map.std = kzalloc_obj(*doi_def->map.std, GFP_KERNEL);
if (doi_def->map.std == NULL) {
kfree(doi_def);
return -ENOMEM;
@@ -332,7 +332,7 @@ static int netlbl_cipsov4_add_pass(struct genl_info *info,
if (!info->attrs[NLBL_CIPSOV4_A_TAGLST])
return -EINVAL;
- doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL);
+ doi_def = kmalloc_obj(*doi_def, GFP_KERNEL);
if (doi_def == NULL)
return -ENOMEM;
doi_def->type = CIPSO_V4_MAP_PASS;
@@ -371,7 +371,7 @@ static int netlbl_cipsov4_add_local(struct genl_info *info,
if (!info->attrs[NLBL_CIPSOV4_A_TAGLST])
return -EINVAL;
- doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL);
+ doi_def = kmalloc_obj(*doi_def, GFP_KERNEL);
if (doi_def == NULL)
return -ENOMEM;
doi_def->type = CIPSO_V4_MAP_LOCAL;
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index 8158a25972b4..fc014849d6b3 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -367,13 +367,11 @@ int __init netlbl_domhsh_init(u32 size)
if (size == 0)
return -EINVAL;
- hsh_tbl = kmalloc(sizeof(*hsh_tbl), GFP_KERNEL);
+ hsh_tbl = kmalloc_obj(*hsh_tbl, GFP_KERNEL);
if (hsh_tbl == NULL)
return -ENOMEM;
hsh_tbl->size = 1 << size;
- hsh_tbl->tbl = kcalloc(hsh_tbl->size,
- sizeof(struct list_head),
- GFP_KERNEL);
+ hsh_tbl->tbl = kzalloc_objs(struct list_head, hsh_tbl->size, GFP_KERNEL);
if (hsh_tbl->tbl == NULL) {
kfree(hsh_tbl);
return -ENOMEM;
@@ -453,7 +451,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
ret_val = -EINVAL;
goto add_return;
}
- entry_b = kzalloc(sizeof(*entry_b), GFP_ATOMIC);
+ entry_b = kzalloc_obj(*entry_b, GFP_ATOMIC);
if (entry_b == NULL) {
ret_val = -ENOMEM;
goto add_return;
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 33b77084a4e5..3583fa63dd01 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -104,7 +104,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
struct netlbl_domaddr4_map *map4 = NULL;
struct netlbl_domaddr6_map *map6 = NULL;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (entry == NULL)
return -ENOMEM;
if (domain != NULL) {
@@ -117,7 +117,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
if (addr == NULL && mask == NULL)
entry->def.type = NETLBL_NLTYPE_UNLABELED;
else if (addr != NULL && mask != NULL) {
- addrmap = kzalloc(sizeof(*addrmap), GFP_ATOMIC);
+ addrmap = kzalloc_obj(*addrmap, GFP_ATOMIC);
if (addrmap == NULL)
goto cfg_unlbl_map_add_failure;
INIT_LIST_HEAD(&addrmap->list4);
@@ -127,7 +127,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
case AF_INET: {
const struct in_addr *addr4 = addr;
const struct in_addr *mask4 = mask;
- map4 = kzalloc(sizeof(*map4), GFP_ATOMIC);
+ map4 = kzalloc_obj(*map4, GFP_ATOMIC);
if (map4 == NULL)
goto cfg_unlbl_map_add_failure;
map4->def.type = NETLBL_NLTYPE_UNLABELED;
@@ -144,7 +144,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
case AF_INET6: {
const struct in6_addr *addr6 = addr;
const struct in6_addr *mask6 = mask;
- map6 = kzalloc(sizeof(*map6), GFP_ATOMIC);
+ map6 = kzalloc_obj(*map6, GFP_ATOMIC);
if (map6 == NULL)
goto cfg_unlbl_map_add_failure;
map6->def.type = NETLBL_NLTYPE_UNLABELED;
@@ -336,7 +336,7 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
if (doi_def == NULL)
return -ENOENT;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (entry == NULL)
goto out_entry;
entry->family = AF_INET;
@@ -350,13 +350,13 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
entry->def.cipso = doi_def;
entry->def.type = NETLBL_NLTYPE_CIPSOV4;
} else if (addr != NULL && mask != NULL) {
- addrmap = kzalloc(sizeof(*addrmap), GFP_ATOMIC);
+ addrmap = kzalloc_obj(*addrmap, GFP_ATOMIC);
if (addrmap == NULL)
goto out_addrmap;
INIT_LIST_HEAD(&addrmap->list4);
INIT_LIST_HEAD(&addrmap->list6);
- addrinfo = kzalloc(sizeof(*addrinfo), GFP_ATOMIC);
+ addrinfo = kzalloc_obj(*addrinfo, GFP_ATOMIC);
if (addrinfo == NULL)
goto out_addrinfo;
addrinfo->def.cipso = doi_def;
@@ -462,7 +462,7 @@ int netlbl_cfg_calipso_map_add(u32 doi,
if (doi_def == NULL)
return -ENOENT;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (entry == NULL)
goto out_entry;
entry->family = AF_INET6;
@@ -476,13 +476,13 @@ int netlbl_cfg_calipso_map_add(u32 doi,
entry->def.calipso = doi_def;
entry->def.type = NETLBL_NLTYPE_CALIPSO;
} else if (addr != NULL && mask != NULL) {
- addrmap = kzalloc(sizeof(*addrmap), GFP_ATOMIC);
+ addrmap = kzalloc_obj(*addrmap, GFP_ATOMIC);
if (addrmap == NULL)
goto out_addrmap;
INIT_LIST_HEAD(&addrmap->list4);
INIT_LIST_HEAD(&addrmap->list6);
- addrinfo = kzalloc(sizeof(*addrinfo), GFP_ATOMIC);
+ addrinfo = kzalloc_obj(*addrinfo, GFP_ATOMIC);
if (addrinfo == NULL)
goto out_addrinfo;
addrinfo->def.calipso = doi_def;
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 079fe72a6384..13f45fbff824 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -84,7 +84,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
struct calipso_doi *calipso = NULL;
#endif
u32 tmp_val;
- struct netlbl_dom_map *entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ struct netlbl_dom_map *entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
@@ -148,7 +148,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
struct in_addr *mask;
struct netlbl_domaddr4_map *map;
- addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
+ addrmap = kzalloc_obj(*addrmap, GFP_KERNEL);
if (addrmap == NULL) {
ret_val = -ENOMEM;
goto add_doi_put_def;
@@ -169,7 +169,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]);
mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]);
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (map == NULL) {
ret_val = -ENOMEM;
goto add_free_addrmap;
@@ -195,7 +195,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
struct in6_addr *mask;
struct netlbl_domaddr6_map *map;
- addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
+ addrmap = kzalloc_obj(*addrmap, GFP_KERNEL);
if (addrmap == NULL) {
ret_val = -ENOMEM;
goto add_doi_put_def;
@@ -216,7 +216,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]);
mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]);
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (map == NULL) {
ret_val = -ENOMEM;
goto add_free_addrmap;
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index dfda9ea61971..ab68324c08d9 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -236,7 +236,7 @@ static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
int ret_val;
struct netlbl_unlhsh_addr4 *entry;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (entry == NULL)
return -ENOMEM;
@@ -276,7 +276,7 @@ static int netlbl_unlhsh_add_addr6(struct netlbl_unlhsh_iface *iface,
int ret_val;
struct netlbl_unlhsh_addr6 *entry;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (entry == NULL)
return -ENOMEM;
@@ -314,7 +314,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_add_iface(int ifindex)
u32 bkt;
struct netlbl_unlhsh_iface *iface;
- iface = kzalloc(sizeof(*iface), GFP_ATOMIC);
+ iface = kzalloc_obj(*iface, GFP_ATOMIC);
if (iface == NULL)
return NULL;
@@ -1413,13 +1413,11 @@ int __init netlbl_unlabel_init(u32 size)
if (size == 0)
return -EINVAL;
- hsh_tbl = kmalloc(sizeof(*hsh_tbl), GFP_KERNEL);
+ hsh_tbl = kmalloc_obj(*hsh_tbl, GFP_KERNEL);
if (hsh_tbl == NULL)
return -ENOMEM;
hsh_tbl->size = 1 << size;
- hsh_tbl->tbl = kcalloc(hsh_tbl->size,
- sizeof(struct list_head),
- GFP_KERNEL);
+ hsh_tbl->tbl = kzalloc_objs(struct list_head, hsh_tbl->size, GFP_KERNEL);
if (hsh_tbl->tbl == NULL) {
kfree(hsh_tbl);
return -ENOMEM;
@@ -1534,7 +1532,7 @@ int __init netlbl_unlabel_defconf(void)
audit_info.loginuid = GLOBAL_ROOT_UID;
audit_info.sessionid = 0;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (entry == NULL)
return -ENOMEM;
entry->family = AF_UNSPEC;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 8e5151f0c6e4..2d91b8b8ba9a 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2927,7 +2927,7 @@ static int __init netlink_proto_init(void)
BUILD_BUG_ON(sizeof(struct netlink_skb_parms) > sizeof_field(struct sk_buff, cb));
- nl_table = kcalloc(MAX_LINKS, sizeof(*nl_table), GFP_KERNEL);
+ nl_table = kzalloc_objs(*nl_table, MAX_LINKS, GFP_KERNEL);
if (!nl_table)
goto panic;
diff --git a/net/netlink/diag.c b/net/netlink/diag.c
index b8e58132e8af..25e930a64d07 100644
--- a/net/netlink/diag.c
+++ b/net/netlink/diag.c
@@ -107,7 +107,7 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
num--;
if (!hti) {
- hti = kmalloc(sizeof(*hti), GFP_KERNEL);
+ hti = kmalloc_obj(*hti, GFP_KERNEL);
if (!hti)
return -ENOMEM;
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 978c129c6095..ac1fdf7d7327 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -659,7 +659,7 @@ static int genl_sk_privs_alloc(struct genl_family *family)
if (!family->sock_priv_size)
return 0;
- family->sock_privs = kzalloc(sizeof(*family->sock_privs), GFP_KERNEL);
+ family->sock_privs = kzalloc_obj(*family->sock_privs, GFP_KERNEL);
if (!family->sock_privs)
return -ENOMEM;
xa_init(family->sock_privs);
@@ -912,7 +912,7 @@ EXPORT_SYMBOL(genlmsg_put);
static struct genl_dumpit_info *genl_dumpit_info_alloc(void)
{
- return kmalloc(sizeof(struct genl_dumpit_info), GFP_KERNEL);
+ return kmalloc_obj(struct genl_dumpit_info, GFP_KERNEL);
}
static void genl_dumpit_info_free(const struct genl_dumpit_info *info)
@@ -937,8 +937,7 @@ genl_family_rcv_msg_attrs_parse(const struct genl_family *family,
if (!ops->maxattr)
return NULL;
- attrbuf = kmalloc_array(ops->maxattr + 1,
- sizeof(struct nlattr *), GFP_KERNEL);
+ attrbuf = kmalloc_objs(struct nlattr *, ops->maxattr + 1, GFP_KERNEL);
if (!attrbuf)
return ERR_PTR(-ENOMEM);
@@ -1591,7 +1590,7 @@ static int ctrl_dumppolicy_start(struct netlink_callback *cb)
return 0;
}
- ctx->op_iter = kmalloc(sizeof(*ctx->op_iter), GFP_KERNEL);
+ ctx->op_iter = kmalloc_obj(*ctx->op_iter, GFP_KERNEL);
if (!ctx->op_iter)
return -ENOMEM;
diff --git a/net/netlink/policy.c b/net/netlink/policy.c
index 99458da6be32..a3e818c7c0cf 100644
--- a/net/netlink/policy.c
+++ b/net/netlink/policy.c
@@ -102,8 +102,8 @@ static struct netlink_policy_dump_state *alloc_state(void)
{
struct netlink_policy_dump_state *state;
- state = kzalloc(struct_size(state, policies, INITIAL_POLICIES_ALLOC),
- GFP_KERNEL);
+ state = kzalloc_flex(*state, policies, INITIAL_POLICIES_ALLOC,
+ GFP_KERNEL);
if (!state)
return ERR_PTR(-ENOMEM);
state->n_alloc = INITIAL_POLICIES_ALLOC;
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 5ed1a71ceec1..d7090dad8113 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1401,7 +1401,7 @@ static int __init nr_proto_init(void)
goto unregister_proto;
}
- dev_nr = kcalloc(nr_ndevs, sizeof(struct net_device *), GFP_KERNEL);
+ dev_nr = kzalloc_objs(struct net_device *, nr_ndevs, GFP_KERNEL);
if (!dev_nr) {
pr_err("NET/ROM: %s - unable to allocate device array\n",
__func__);
diff --git a/net/nfc/core.c b/net/nfc/core.c
index f50e5bab35d8..c39d00b2a0d7 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -879,7 +879,7 @@ int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type)
if (se)
return -EALREADY;
- se = kzalloc(sizeof(struct nfc_se), GFP_KERNEL);
+ se = kzalloc_obj(struct nfc_se, GFP_KERNEL);
if (!se)
return -ENOMEM;
@@ -1062,7 +1062,7 @@ struct nfc_dev *nfc_allocate_device(const struct nfc_ops *ops,
if (!supported_protocols)
return NULL;
- dev = kzalloc(sizeof(struct nfc_dev), GFP_KERNEL);
+ dev = kzalloc_obj(struct nfc_dev, GFP_KERNEL);
if (!dev)
return NULL;
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index dae378f1d52b..be9a048b583b 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -231,7 +231,7 @@ int digital_send_cmd(struct nfc_digital_dev *ddev, u8 cmd_type,
{
struct digital_cmd *cmd;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+ cmd = kzalloc_obj(*cmd, GFP_KERNEL);
if (!cmd)
return -ENOMEM;
@@ -279,7 +279,7 @@ static int digital_tg_listen_mdaa(struct nfc_digital_dev *ddev, u8 rf_tech)
struct digital_tg_mdaa_params *params;
int rc;
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ params = kzalloc_obj(*params, GFP_KERNEL);
if (!params)
return -ENOMEM;
@@ -706,7 +706,7 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
struct digital_data_exch *data_exch;
int rc;
- data_exch = kzalloc(sizeof(*data_exch), GFP_KERNEL);
+ data_exch = kzalloc_obj(*data_exch, GFP_KERNEL);
if (!data_exch)
return -ENOMEM;
@@ -762,7 +762,7 @@ struct nfc_digital_dev *nfc_digital_allocate_device(const struct nfc_digital_ops
!ops->switch_rf || (ops->tg_listen_md && !ops->tg_get_rf_tech))
return NULL;
- ddev = kzalloc(sizeof(*ddev), GFP_KERNEL);
+ ddev = kzalloc_obj(*ddev, GFP_KERNEL);
if (!ddev)
return NULL;
diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c
index 3adf4589852a..df2bfb4734c5 100644
--- a/net/nfc/digital_technology.c
+++ b/net/nfc/digital_technology.c
@@ -490,7 +490,7 @@ static void digital_in_recv_sens_res(struct nfc_digital_dev *ddev, void *arg,
goto exit;
}
- target = kzalloc(sizeof(struct nfc_target), GFP_KERNEL);
+ target = kzalloc_obj(struct nfc_target, GFP_KERNEL);
if (!target) {
rc = -ENOMEM;
goto exit;
@@ -688,7 +688,7 @@ static void digital_in_recv_sensb_res(struct nfc_digital_dev *ddev, void *arg,
else
ddev->target_fsc = digital_ats_fsc[fsci];
- target = kzalloc(sizeof(struct nfc_target), GFP_KERNEL);
+ target = kzalloc_obj(struct nfc_target, GFP_KERNEL);
if (!target) {
rc = -ENOMEM;
goto exit;
@@ -863,7 +863,7 @@ static void digital_in_recv_iso15693_inv_res(struct nfc_digital_dev *ddev,
goto out_free_skb;
}
- target = kzalloc(sizeof(*target), GFP_KERNEL);
+ target = kzalloc_obj(*target, GFP_KERNEL);
if (!target) {
rc = -ENOMEM;
goto out_free_skb;
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 8618d57c23da..10bcd9d2576a 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -291,7 +291,7 @@ int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate)
pr_debug("from gate %d\n", gate);
- targets = kzalloc(sizeof(struct nfc_target), GFP_KERNEL);
+ targets = kzalloc_obj(struct nfc_target, GFP_KERNEL);
if (targets == NULL)
return -ENOMEM;
@@ -964,7 +964,7 @@ struct nfc_hci_dev *nfc_hci_allocate_device(const struct nfc_hci_ops *ops,
if (protocols == 0)
return NULL;
- hdev = kzalloc(sizeof(struct nfc_hci_dev), GFP_KERNEL);
+ hdev = kzalloc_obj(struct nfc_hci_dev, GFP_KERNEL);
if (hdev == NULL)
return NULL;
diff --git a/net/nfc/hci/hcp.c b/net/nfc/hci/hcp.c
index 4902f5064098..903fb134cd80 100644
--- a/net/nfc/hci/hcp.c
+++ b/net/nfc/hci/hcp.c
@@ -30,7 +30,7 @@ int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
int hci_len, err;
bool firstfrag = true;
- cmd = kzalloc(sizeof(struct hci_msg), GFP_KERNEL);
+ cmd = kzalloc_obj(struct hci_msg, GFP_KERNEL);
if (cmd == NULL)
return -ENOMEM;
diff --git a/net/nfc/hci/llc.c b/net/nfc/hci/llc.c
index e6cf4eb06b46..12d7940c6217 100644
--- a/net/nfc/hci/llc.c
+++ b/net/nfc/hci/llc.c
@@ -49,7 +49,7 @@ int nfc_llc_register(const char *name, const struct nfc_llc_ops *ops)
{
struct nfc_llc_engine *llc_engine;
- llc_engine = kzalloc(sizeof(struct nfc_llc_engine), GFP_KERNEL);
+ llc_engine = kzalloc_obj(struct nfc_llc_engine, GFP_KERNEL);
if (llc_engine == NULL)
return -ENOMEM;
@@ -90,7 +90,7 @@ struct nfc_llc *nfc_llc_allocate(const char *name, struct nfc_hci_dev *hdev,
if (llc_engine == NULL)
return NULL;
- llc = kzalloc(sizeof(struct nfc_llc), GFP_KERNEL);
+ llc = kzalloc_obj(struct nfc_llc, GFP_KERNEL);
if (llc == NULL)
return NULL;
diff --git a/net/nfc/hci/llc_nop.c b/net/nfc/hci/llc_nop.c
index a58716f16954..eb940330fd5d 100644
--- a/net/nfc/hci/llc_nop.c
+++ b/net/nfc/hci/llc_nop.c
@@ -28,7 +28,7 @@ static void *llc_nop_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
*rx_headroom = 0;
*rx_tailroom = 0;
- llc_nop = kzalloc(sizeof(struct llc_nop), GFP_KERNEL);
+ llc_nop = kzalloc_obj(struct llc_nop, GFP_KERNEL);
if (llc_nop == NULL)
return NULL;
diff --git a/net/nfc/hci/llc_shdlc.c b/net/nfc/hci/llc_shdlc.c
index 08c8aa1530d8..7e0d84c29cb1 100644
--- a/net/nfc/hci/llc_shdlc.c
+++ b/net/nfc/hci/llc_shdlc.c
@@ -728,7 +728,7 @@ static void *llc_shdlc_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv,
*rx_headroom = SHDLC_LLC_HEAD_ROOM;
*rx_tailroom = 0;
- shdlc = kzalloc(sizeof(struct llc_shdlc), GFP_KERNEL);
+ shdlc = kzalloc_obj(struct llc_shdlc, GFP_KERNEL);
if (shdlc == NULL)
return NULL;
diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c
index b652323bc2c1..90f68199ecca 100644
--- a/net/nfc/llcp_commands.c
+++ b/net/nfc/llcp_commands.c
@@ -108,7 +108,7 @@ struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdres_tlv(u8 tid, u8 sap)
struct nfc_llcp_sdp_tlv *sdres;
u8 value[2];
- sdres = kzalloc(sizeof(struct nfc_llcp_sdp_tlv), GFP_KERNEL);
+ sdres = kzalloc_obj(struct nfc_llcp_sdp_tlv, GFP_KERNEL);
if (sdres == NULL)
return NULL;
@@ -141,7 +141,7 @@ struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, const char *uri,
if (WARN_ON_ONCE(uri_len > U8_MAX - 4))
return NULL;
- sdreq = kzalloc(sizeof(struct nfc_llcp_sdp_tlv), GFP_KERNEL);
+ sdreq = kzalloc_obj(struct nfc_llcp_sdp_tlv, GFP_KERNEL);
if (sdreq == NULL)
return NULL;
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index 444a3774c8e8..98f0c3281281 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -1621,7 +1621,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
{
struct nfc_llcp_local *local;
- local = kzalloc(sizeof(struct nfc_llcp_local), GFP_KERNEL);
+ local = kzalloc_obj(struct nfc_llcp_local, GFP_KERNEL);
if (local == NULL)
return -ENOMEM;
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index e419e020a70a..dc17ed8be242 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -1171,7 +1171,7 @@ struct nci_dev *nci_allocate_device(const struct nci_ops *ops,
if (!supported_protocols)
return NULL;
- ndev = kzalloc(sizeof(struct nci_dev), GFP_KERNEL);
+ ndev = kzalloc_obj(struct nci_dev, GFP_KERNEL);
if (!ndev)
return NULL;
diff --git a/net/nfc/nci/hci.c b/net/nfc/nci/hci.c
index 082ab66f120b..cd3e87b2dd3e 100644
--- a/net/nfc/nci/hci.c
+++ b/net/nfc/nci/hci.c
@@ -777,7 +777,7 @@ struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev)
{
struct nci_hci_dev *hdev;
- hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
+ hdev = kzalloc_obj(*hdev, GFP_KERNEL);
if (!hdev)
return NULL;
diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index aab107727f18..25dc2868fd27 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -113,7 +113,7 @@ static int nci_uart_set_driver(struct tty_struct *tty, unsigned int driver)
if (!nci_uart_drivers[driver])
return -ENOENT;
- nu = kzalloc(sizeof(*nu), GFP_KERNEL);
+ nu = kzalloc_obj(*nu, GFP_KERNEL);
if (!nu)
return -ENOMEM;
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index a18e2c503da6..a69322721c31 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -604,7 +604,7 @@ static int nfc_genl_dump_devices(struct sk_buff *skb,
if (!iter) {
first_call = true;
- iter = kmalloc(sizeof(struct class_dev_iter), GFP_KERNEL);
+ iter = kmalloc_obj(struct class_dev_iter, GFP_KERNEL);
if (!iter)
return -ENOMEM;
cb->args[0] = (long) iter;
@@ -1370,7 +1370,7 @@ static int nfc_genl_dump_ses(struct sk_buff *skb,
if (!iter) {
first_call = true;
- iter = kmalloc(sizeof(struct class_dev_iter), GFP_KERNEL);
+ iter = kmalloc_obj(struct class_dev_iter, GFP_KERNEL);
if (!iter)
return -ENOMEM;
cb->args[0] = (long) iter;
@@ -1541,7 +1541,7 @@ static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
apdu = nla_data(info->attrs[NFC_ATTR_SE_APDU]);
- ctx = kzalloc(sizeof(struct se_io_ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(struct se_io_ctx, GFP_KERNEL);
if (!ctx) {
rc = -ENOMEM;
goto put_dev;
@@ -1875,7 +1875,7 @@ static int nfc_genl_rcv_nl_event(struct notifier_block *this,
pr_debug("NETLINK_URELEASE event from id %d\n", n->portid);
- w = kmalloc(sizeof(*w), GFP_ATOMIC);
+ w = kmalloc_obj(*w, GFP_ATOMIC);
if (w) {
INIT_WORK(&w->w, nfc_urelease_event_work);
w->portid = n->portid;
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index a0811e1fba65..8051e3127d2c 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1586,15 +1586,15 @@ static int ovs_ct_limit_init(struct net *net, struct ovs_net *ovs_net)
{
int i, err;
- ovs_net->ct_limit_info = kmalloc(sizeof(*ovs_net->ct_limit_info),
- GFP_KERNEL);
+ ovs_net->ct_limit_info = kmalloc_obj(*ovs_net->ct_limit_info,
+ GFP_KERNEL);
if (!ovs_net->ct_limit_info)
return -ENOMEM;
ovs_net->ct_limit_info->default_limit = OVS_CT_LIMIT_DEFAULT;
ovs_net->ct_limit_info->limits =
- kmalloc_array(CT_LIMIT_HASH_BUCKETS, sizeof(struct hlist_head),
- GFP_KERNEL);
+ kmalloc_objs(struct hlist_head, CT_LIMIT_HASH_BUCKETS,
+ GFP_KERNEL);
if (!ovs_net->ct_limit_info->limits) {
kfree(ovs_net->ct_limit_info);
return -ENOMEM;
@@ -1688,8 +1688,7 @@ static int ovs_ct_limit_set_zone_limit(struct nlattr *nla_zone_limit,
} else {
struct ovs_ct_limit *ct_limit;
- ct_limit = kmalloc(sizeof(*ct_limit),
- GFP_KERNEL_ACCOUNT);
+ ct_limit = kmalloc_obj(*ct_limit, GFP_KERNEL_ACCOUNT);
if (!ct_limit)
return -ENOMEM;
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index d5b6e2002bc1..b4fb83c3c0f9 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1029,7 +1029,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
}
/* Extract key. */
- key = kzalloc(sizeof(*key), GFP_KERNEL);
+ key = kzalloc_obj(*key, GFP_KERNEL);
if (!key) {
error = -ENOMEM;
goto err_kfree_flow;
@@ -1797,9 +1797,8 @@ static int ovs_dp_vport_init(struct datapath *dp)
{
int i;
- dp->ports = kmalloc_array(DP_VPORT_HASH_BUCKETS,
- sizeof(struct hlist_head),
- GFP_KERNEL);
+ dp->ports = kmalloc_objs(struct hlist_head, DP_VPORT_HASH_BUCKETS,
+ GFP_KERNEL);
if (!dp->ports)
return -ENOMEM;
@@ -1828,7 +1827,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
return -ENOMEM;
err = -ENOMEM;
- dp = kzalloc(sizeof(*dp), GFP_KERNEL);
+ dp = kzalloc_obj(*dp, GFP_KERNEL);
if (dp == NULL)
goto err_destroy_reply;
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 2d536901309e..54fd208a1a68 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -1890,7 +1890,7 @@ int ovs_nla_get_identifier(struct sw_flow_id *sfid, const struct nlattr *ufid,
return 0;
/* If UFID was not provided, use unmasked key. */
- new_key = kmalloc(sizeof(*new_key), GFP_KERNEL);
+ new_key = kmalloc_obj(*new_key, GFP_KERNEL);
if (!new_key)
return -ENOMEM;
memcpy(new_key, key, sizeof(*key));
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index ffc72a741a50..b75236aa4414 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -150,14 +150,13 @@ static void __table_instance_destroy(struct table_instance *ti)
static struct table_instance *table_instance_alloc(int new_size)
{
- struct table_instance *ti = kmalloc(sizeof(*ti), GFP_KERNEL);
+ struct table_instance *ti = kmalloc_obj(*ti, GFP_KERNEL);
int i;
if (!ti)
return NULL;
- ti->buckets = kvmalloc_array(new_size, sizeof(struct hlist_head),
- GFP_KERNEL);
+ ti->buckets = kvmalloc_objs(struct hlist_head, new_size, GFP_KERNEL);
if (!ti->buckets) {
kfree(ti);
return NULL;
@@ -367,7 +366,7 @@ static struct mask_cache *tbl_mask_cache_alloc(u32 size)
(size * sizeof(struct mask_cache_entry)) > PCPU_MIN_UNIT_SIZE)
return NULL;
- new = kzalloc(sizeof(*new), GFP_KERNEL);
+ new = kzalloc_obj(*new, GFP_KERNEL);
if (!new)
return NULL;
@@ -965,7 +964,7 @@ static struct sw_flow_mask *mask_alloc(void)
{
struct sw_flow_mask *mask;
- mask = kmalloc(sizeof(*mask), GFP_KERNEL);
+ mask = kmalloc_obj(*mask, GFP_KERNEL);
if (mask)
mask->ref_count = 1;
@@ -1110,8 +1109,7 @@ void ovs_flow_masks_rebalance(struct flow_table *table)
int i;
/* Build array of all current entries with use counters. */
- masks_and_count = kmalloc_array(ma->max, sizeof(*masks_and_count),
- GFP_KERNEL);
+ masks_and_count = kmalloc_objs(*masks_and_count, ma->max, GFP_KERNEL);
if (!masks_and_count)
return;
diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index cc08e0403909..0c2db78bb71e 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -69,7 +69,7 @@ static struct dp_meter_instance *dp_meter_instance_alloc(const u32 size)
{
struct dp_meter_instance *ti;
- ti = kvzalloc(struct_size(ti, dp_meters, size), GFP_KERNEL);
+ ti = kvzalloc_flex(*ti, dp_meters, size, GFP_KERNEL);
if (!ti)
return NULL;
@@ -341,7 +341,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
return ERR_PTR(-EINVAL);
/* Allocate and set up the meter before locking anything. */
- meter = kzalloc(struct_size(meter, bands, n_bands), GFP_KERNEL_ACCOUNT);
+ meter = kzalloc_flex(*meter, bands, n_bands, GFP_KERNEL_ACCOUNT);
if (!meter)
return ERR_PTR(-ENOMEM);
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index f0ce8ce1dce0..4b83512cbc65 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -34,8 +34,8 @@ static struct hlist_head *dev_table;
*/
int ovs_vport_init(void)
{
- dev_table = kcalloc(VPORT_HASH_BUCKETS, sizeof(struct hlist_head),
- GFP_KERNEL);
+ dev_table = kzalloc_objs(struct hlist_head, VPORT_HASH_BUCKETS,
+ GFP_KERNEL);
if (!dev_table)
return -ENOMEM;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index a1005359085a..a78c5122a3d7 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1711,7 +1711,7 @@ static int fanout_add(struct sock *sk, struct fanout_args *args)
if (type == PACKET_FANOUT_ROLLOVER ||
(type_flags & PACKET_FANOUT_FLAG_ROLLOVER)) {
err = -ENOMEM;
- rollover = kzalloc(sizeof(*rollover), GFP_KERNEL);
+ rollover = kzalloc_obj(*rollover, GFP_KERNEL);
if (!rollover)
goto out;
atomic_long_set(&rollover->num, 0);
@@ -1754,8 +1754,8 @@ static int fanout_add(struct sock *sk, struct fanout_args *args)
/* legacy PACKET_FANOUT_MAX */
args->max_num_members = 256;
err = -ENOMEM;
- match = kvzalloc(struct_size(match, arr, args->max_num_members),
- GFP_KERNEL);
+ match = kvzalloc_flex(*match, arr, args->max_num_members,
+ GFP_KERNEL);
if (!match)
goto out;
write_pnet(&match->net, sock_net(sk));
@@ -3693,7 +3693,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq)
goto done;
err = -ENOBUFS;
- i = kmalloc(sizeof(*i), GFP_KERNEL);
+ i = kmalloc_obj(*i, GFP_KERNEL);
if (i == NULL)
goto done;
@@ -4390,7 +4390,7 @@ static struct pgv *alloc_pg_vec(struct tpacket_req *req, int order)
struct pgv *pg_vec;
int i;
- pg_vec = kcalloc(block_nr, sizeof(struct pgv), GFP_KERNEL | __GFP_NOWARN);
+ pg_vec = kzalloc_objs(struct pgv, block_nr, GFP_KERNEL | __GFP_NOWARN);
if (unlikely(!pg_vec))
goto out;
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 5c36bae37b8f..86325b7fc1b6 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -48,7 +48,7 @@ struct phonet_device_list *phonet_device_list(struct net *net)
static struct phonet_device *__phonet_device_alloc(struct net_device *dev)
{
struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev));
- struct phonet_device *pnd = kmalloc(sizeof(*pnd), GFP_ATOMIC);
+ struct phonet_device *pnd = kmalloc_obj(*pnd, GFP_ATOMIC);
if (pnd == NULL)
return NULL;
pnd->netdev = dev;
diff --git a/net/psample/psample.c b/net/psample/psample.c
index 25f92ba0840c..7763662036fb 100644
--- a/net/psample/psample.c
+++ b/net/psample/psample.c
@@ -143,7 +143,7 @@ static struct psample_group *psample_group_create(struct net *net,
{
struct psample_group *group;
- group = kzalloc(sizeof(*group), GFP_ATOMIC);
+ group = kzalloc_obj(*group, GFP_ATOMIC);
if (!group)
return NULL;
diff --git a/net/psp/psp_main.c b/net/psp/psp_main.c
index a8534124f626..08decafee7a6 100644
--- a/net/psp/psp_main.c
+++ b/net/psp/psp_main.c
@@ -64,7 +64,7 @@ psp_dev_create(struct net_device *netdev,
!psd_ops->get_stats))
return ERR_PTR(-EINVAL);
- psd = kzalloc(sizeof(*psd), GFP_KERNEL);
+ psd = kzalloc_obj(*psd, GFP_KERNEL);
if (!psd)
return ERR_PTR(-ENOMEM);
diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
index f785672b7df6..a85b0ed88842 100644
--- a/net/psp/psp_sock.c
+++ b/net/psp/psp_sock.c
@@ -50,8 +50,8 @@ struct psp_assoc *psp_assoc_create(struct psp_dev *psd)
lockdep_assert_held(&psd->lock);
- pas = kzalloc(struct_size(pas, drv_data, psd->caps->assoc_drv_spc),
- GFP_KERNEL_ACCOUNT);
+ pas = kzalloc_flex(*pas, drv_data, psd->caps->assoc_drv_spc,
+ GFP_KERNEL_ACCOUNT);
if (!pas)
return NULL;
diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c
index dab839f61ee9..70e7a210fd42 100644
--- a/net/qrtr/af_qrtr.c
+++ b/net/qrtr/af_qrtr.c
@@ -271,7 +271,7 @@ static int qrtr_tx_wait(struct qrtr_node *node, int dest_node, int dest_port,
mutex_lock(&node->qrtr_tx_lock);
flow = radix_tree_lookup(&node->qrtr_tx_flow, key);
if (!flow) {
- flow = kzalloc(sizeof(*flow), GFP_KERNEL);
+ flow = kzalloc_obj(*flow, GFP_KERNEL);
if (flow) {
init_waitqueue_head(&flow->resume_tx);
if (radix_tree_insert(&node->qrtr_tx_flow, key, flow)) {
@@ -589,7 +589,7 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid)
if (!ep || !ep->xmit)
return -EINVAL;
- node = kzalloc(sizeof(*node), GFP_KERNEL);
+ node = kzalloc_obj(*node, GFP_KERNEL);
if (!node)
return -ENOMEM;
diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c
index bfcc1a453f23..36b5c1990bf5 100644
--- a/net/qrtr/ns.c
+++ b/net/qrtr/ns.c
@@ -78,7 +78,7 @@ static struct qrtr_node *node_get(unsigned int node_id)
return node;
/* If node didn't exist, allocate and insert it to the tree */
- node = kzalloc(sizeof(*node), GFP_KERNEL);
+ node = kzalloc_obj(*node, GFP_KERNEL);
if (!node)
return NULL;
@@ -229,7 +229,7 @@ static struct qrtr_server *server_add(unsigned int service,
if (!service || !port)
return NULL;
- srv = kzalloc(sizeof(*srv), GFP_KERNEL);
+ srv = kzalloc_obj(*srv, GFP_KERNEL);
if (!srv)
return NULL;
@@ -534,7 +534,7 @@ static int ctrl_cmd_new_lookup(struct sockaddr_qrtr *from,
if (from->sq_node != qrtr_ns.local_node)
return -EINVAL;
- lookup = kzalloc(sizeof(*lookup), GFP_KERNEL);
+ lookup = kzalloc_obj(*lookup, GFP_KERNEL);
if (!lookup)
return -ENOMEM;
diff --git a/net/qrtr/tun.c b/net/qrtr/tun.c
index 304b41fea5ab..9ad17a773593 100644
--- a/net/qrtr/tun.c
+++ b/net/qrtr/tun.c
@@ -33,7 +33,7 @@ static int qrtr_tun_open(struct inode *inode, struct file *filp)
struct qrtr_tun *tun;
int ret;
- tun = kzalloc(sizeof(*tun), GFP_KERNEL);
+ tun = kzalloc_obj(*tun, GFP_KERNEL);
if (!tun)
return -ENOMEM;
diff --git a/net/rds/cong.c b/net/rds/cong.c
index ac1f120c10f9..e7f019c3a625 100644
--- a/net/rds/cong.c
+++ b/net/rds/cong.c
@@ -143,7 +143,7 @@ static struct rds_cong_map *rds_cong_from_addr(const struct in6_addr *addr)
unsigned long i;
unsigned long flags;
- map = kzalloc(sizeof(struct rds_cong_map), GFP_KERNEL);
+ map = kzalloc_obj(struct rds_cong_map, GFP_KERNEL);
if (!map)
return NULL;
diff --git a/net/rds/connection.c b/net/rds/connection.c
index 185f73b01694..e23fd9a628ac 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -197,7 +197,7 @@ static struct rds_connection *__rds_conn_create(struct net *net,
conn = ERR_PTR(-ENOMEM);
goto out;
}
- conn->c_path = kcalloc(npaths, sizeof(struct rds_conn_path), gfp);
+ conn->c_path = kzalloc_objs(struct rds_conn_path, npaths, gfp);
if (!conn->c_path) {
kmem_cache_free(rds_conn_slab, conn);
conn = ERR_PTR(-ENOMEM);
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 9826fe7f9d00..8457ec7c3ab8 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -172,9 +172,8 @@ static int rds_ib_add_one(struct ib_device *device)
rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom;
rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom;
- rds_ibdev->vector_load = kcalloc(device->num_comp_vectors,
- sizeof(int),
- GFP_KERNEL);
+ rds_ibdev->vector_load = kzalloc_objs(int, device->num_comp_vectors,
+ GFP_KERNEL);
if (!rds_ibdev->vector_load) {
pr_err("RDS/IB: %s failed to allocate vector memory\n",
__func__);
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 26b069e1999d..0c64c504f79d 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -1203,7 +1203,7 @@ int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp)
int ret;
/* XXX too lazy? */
- ic = kzalloc(sizeof(struct rds_ib_connection), gfp);
+ ic = kzalloc_obj(struct rds_ib_connection, gfp);
if (!ic)
return -ENOMEM;
diff --git a/net/rds/ib_rdma.c b/net/rds/ib_rdma.c
index 6585164c7059..651f658a6a0a 100644
--- a/net/rds/ib_rdma.c
+++ b/net/rds/ib_rdma.c
@@ -67,7 +67,7 @@ static int rds_ib_add_ipaddr(struct rds_ib_device *rds_ibdev, __be32 ipaddr)
{
struct rds_ib_ipaddr *i_ipaddr;
- i_ipaddr = kmalloc(sizeof *i_ipaddr, GFP_KERNEL);
+ i_ipaddr = kmalloc_obj(*i_ipaddr, GFP_KERNEL);
if (!i_ipaddr)
return -ENOMEM;
@@ -585,7 +585,7 @@ void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
if (key_ret)
*key_ret = ib_mr->rkey;
- ibmr = kzalloc(sizeof(*ibmr), GFP_KERNEL);
+ ibmr = kzalloc_obj(*ibmr, GFP_KERNEL);
if (!ibmr) {
ib_dereg_mr(ib_mr);
ret = -ENOMEM;
@@ -641,7 +641,7 @@ struct rds_ib_mr_pool *rds_ib_create_mr_pool(struct rds_ib_device *rds_ibdev,
{
struct rds_ib_mr_pool *pool;
- pool = kzalloc(sizeof(*pool), GFP_KERNEL);
+ pool = kzalloc_obj(*pool, GFP_KERNEL);
if (!pool)
return ERR_PTR(-ENOMEM);
diff --git a/net/rds/info.c b/net/rds/info.c
index b6b46a8214a0..696e957c41a9 100644
--- a/net/rds/info.c
+++ b/net/rds/info.c
@@ -187,7 +187,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,
nr_pages = (PAGE_ALIGN(start + len) - (start & PAGE_MASK))
>> PAGE_SHIFT;
- pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL);
+ pages = kmalloc_objs(struct page *, nr_pages, GFP_KERNEL);
if (!pages) {
ret = -ENOMEM;
goto out;
diff --git a/net/rds/loop.c b/net/rds/loop.c
index 1d73ad79c847..ac9295a766b1 100644
--- a/net/rds/loop.c
+++ b/net/rds/loop.c
@@ -137,7 +137,7 @@ static int rds_loop_conn_alloc(struct rds_connection *conn, gfp_t gfp)
struct rds_loop_connection *lc;
unsigned long flags;
- lc = kzalloc(sizeof(struct rds_loop_connection), gfp);
+ lc = kzalloc_obj(struct rds_loop_connection, gfp);
if (!lc)
return -ENOMEM;
diff --git a/net/rds/message.c b/net/rds/message.c
index 54fd000806ea..e367ca4f4f31 100644
--- a/net/rds/message.c
+++ b/net/rds/message.c
@@ -415,7 +415,7 @@ static int rds_message_zcopy_from_user(struct rds_message *rm, struct iov_iter *
*/
sg = rm->data.op_sg;
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
INIT_LIST_HEAD(&info->rs_zcookie_next);
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 00dbcd4d28e6..0015531aff05 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -228,13 +228,13 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
args->vec.addr, args->vec.bytes, nr_pages);
/* XXX clamp nr_pages to limit the size of this alloc? */
- pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
+ pages = kzalloc_objs(struct page *, nr_pages, GFP_KERNEL);
if (!pages) {
ret = -ENOMEM;
goto out;
}
- mr = kzalloc(sizeof(struct rds_mr), GFP_KERNEL);
+ mr = kzalloc_obj(struct rds_mr, GFP_KERNEL);
if (!mr) {
ret = -ENOMEM;
goto out;
@@ -269,7 +269,7 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
goto out;
} else {
nents = ret;
- sg = kmalloc_array(nents, sizeof(*sg), GFP_KERNEL);
+ sg = kmalloc_objs(*sg, nents, GFP_KERNEL);
if (!sg) {
ret = -ENOMEM;
goto out;
@@ -571,9 +571,7 @@ int rds_rdma_extra_size(struct rds_rdma_args *args,
if (args->nr_local > UIO_MAXIOV)
return -EMSGSIZE;
- iov->iov = kcalloc(args->nr_local,
- sizeof(struct rds_iovec),
- GFP_KERNEL);
+ iov->iov = kzalloc_objs(struct rds_iovec, args->nr_local, GFP_KERNEL);
if (!iov->iov)
return -ENOMEM;
@@ -654,7 +652,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
goto out_ret;
}
- pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
+ pages = kzalloc_objs(struct page *, nr_pages, GFP_KERNEL);
if (!pages) {
ret = -ENOMEM;
goto out_ret;
@@ -681,7 +679,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
* would have to use GFP_ATOMIC there, and don't want to deal
* with failed allocations.
*/
- op->op_notifier = kmalloc(sizeof(struct rds_notifier), GFP_KERNEL);
+ op->op_notifier = kmalloc_obj(struct rds_notifier, GFP_KERNEL);
if (!op->op_notifier) {
ret = -ENOMEM;
goto out_pages;
@@ -730,8 +728,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
ret = -EOPNOTSUPP;
goto out_pages;
}
- local_odp_mr =
- kzalloc(sizeof(*local_odp_mr), GFP_KERNEL);
+ local_odp_mr = kzalloc_obj(*local_odp_mr, GFP_KERNEL);
if (!local_odp_mr) {
ret = -ENOMEM;
goto out_pages;
@@ -937,7 +934,8 @@ int rds_cmsg_atomic(struct rds_sock *rs, struct rds_message *rm,
* would have to use GFP_ATOMIC there, and don't want to deal
* with failed allocations.
*/
- rm->atomic.op_notifier = kmalloc(sizeof(*rm->atomic.op_notifier), GFP_KERNEL);
+ rm->atomic.op_notifier = kmalloc_obj(*rm->atomic.op_notifier,
+ GFP_KERNEL);
if (!rm->atomic.op_notifier) {
ret = -ENOMEM;
goto err;
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 7d3e82e4c2fc..0f64aa4797f7 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -279,7 +279,7 @@ static void rfkill_send_events(struct rfkill *rfkill, enum rfkill_operation op)
struct rfkill_int_event *ev;
list_for_each_entry(data, &rfkill_fds, list) {
- ev = kzalloc(sizeof(*ev), GFP_KERNEL);
+ ev = kzalloc_obj(*ev, GFP_KERNEL);
if (!ev)
continue;
rfkill_fill_event(&ev->ev, rfkill, op);
@@ -1165,7 +1165,7 @@ static int rfkill_fop_open(struct inode *inode, struct file *file)
struct rfkill *rfkill;
struct rfkill_int_event *ev, *tmp;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -1182,7 +1182,7 @@ static int rfkill_fop_open(struct inode *inode, struct file *file)
*/
list_for_each_entry(rfkill, &rfkill_list, node) {
- ev = kzalloc(sizeof(*ev), GFP_KERNEL);
+ ev = kzalloc_obj(*ev, GFP_KERNEL);
if (!ev)
goto free;
rfkill_sync(rfkill);
diff --git a/net/rfkill/input.c b/net/rfkill/input.c
index 53d286b10843..2be6d13ba6ba 100644
--- a/net/rfkill/input.c
+++ b/net/rfkill/input.c
@@ -221,7 +221,7 @@ static int rfkill_connect(struct input_handler *handler, struct input_dev *dev,
struct input_handle *handle;
int error;
- handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
+ handle = kzalloc_obj(struct input_handle, GFP_KERNEL);
if (!handle)
return -ENOMEM;
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index c0f5a515a8ce..83c62af80d7c 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1571,8 +1571,7 @@ static int __init rose_proto_init(void)
rose_callsign = null_ax25_address;
- dev_rose = kcalloc(rose_ndevs, sizeof(struct net_device *),
- GFP_KERNEL);
+ dev_rose = kzalloc_objs(struct net_device *, rose_ndevs, GFP_KERNEL);
if (dev_rose == NULL) {
printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
rc = -ENOMEM;
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index a1e9b05ef6f5..4330df1b1b59 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -82,7 +82,7 @@ static int __must_check rose_add_node(struct rose_route_struct *rose_route,
}
if (rose_neigh == NULL) {
- rose_neigh = kmalloc(sizeof(*rose_neigh), GFP_ATOMIC);
+ rose_neigh = kmalloc_obj(*rose_neigh, GFP_ATOMIC);
if (rose_neigh == NULL) {
res = -ENOMEM;
goto out;
@@ -106,7 +106,7 @@ static int __must_check rose_add_node(struct rose_route_struct *rose_route,
if (rose_route->ndigis != 0) {
rose_neigh->digipeat =
- kmalloc(sizeof(ax25_digi), GFP_ATOMIC);
+ kmalloc_obj(ax25_digi, GFP_ATOMIC);
if (rose_neigh->digipeat == NULL) {
kfree(rose_neigh);
res = -ENOMEM;
@@ -148,7 +148,7 @@ static int __must_check rose_add_node(struct rose_route_struct *rose_route,
}
/* create new node */
- rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC);
+ rose_node = kmalloc_obj(*rose_node, GFP_ATOMIC);
if (rose_node == NULL) {
res = -ENOMEM;
goto out;
@@ -368,7 +368,7 @@ void rose_add_loopback_neigh(void)
{
struct rose_neigh *sn;
- rose_loopback_neigh = kmalloc(sizeof(struct rose_neigh), GFP_KERNEL);
+ rose_loopback_neigh = kmalloc_obj(struct rose_neigh, GFP_KERNEL);
if (!rose_loopback_neigh)
return;
sn = rose_loopback_neigh;
@@ -417,7 +417,7 @@ int rose_add_loopback_node(const rose_address *address)
if (rose_node != NULL)
goto out;
- if ((rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC)) == NULL) {
+ if ((rose_node = kmalloc_obj(*rose_node, GFP_ATOMIC)) == NULL) {
err = -ENOMEM;
goto out;
}
@@ -1055,7 +1055,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
goto put_neigh;
}
- if ((rose_route = kmalloc(sizeof(*rose_route), GFP_ATOMIC)) == NULL) {
+ if ((rose_route = kmalloc_obj(*rose_route, GFP_ATOMIC)) == NULL) {
rose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 120);
goto put_neigh;
}
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index 00982a030744..ee2d1319e69a 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -164,7 +164,7 @@ int rxrpc_service_prealloc(struct rxrpc_sock *rx, gfp_t gfp)
struct rxrpc_backlog *b = rx->backlog;
if (!b) {
- b = kzalloc(sizeof(struct rxrpc_backlog), gfp);
+ b = kzalloc_obj(struct rxrpc_backlog, gfp);
if (!b)
return -ENOMEM;
rx->backlog = b;
diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c
index 63bbcc567f59..9b757798dedd 100644
--- a/net/rxrpc/conn_client.c
+++ b/net/rxrpc/conn_client.c
@@ -76,7 +76,7 @@ static struct rxrpc_bundle *rxrpc_alloc_bundle(struct rxrpc_call *call,
static atomic_t rxrpc_bundle_id;
struct rxrpc_bundle *bundle;
- bundle = kzalloc(sizeof(*bundle), gfp);
+ bundle = kzalloc_obj(*bundle, gfp);
if (bundle) {
bundle->local = call->local;
bundle->peer = rxrpc_get_peer(call->peer, rxrpc_peer_get_bundle);
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 37340becb224..0ece717db0f8 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -59,7 +59,7 @@ struct rxrpc_connection *rxrpc_alloc_connection(struct rxrpc_net *rxnet,
_enter("");
- conn = kzalloc(sizeof(struct rxrpc_connection), gfp);
+ conn = kzalloc_obj(struct rxrpc_connection, gfp);
if (conn) {
INIT_LIST_HEAD(&conn->cache_link);
timer_setup(&conn->timer, &rxrpc_connection_timer, 0);
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index 9fdc1f031c9d..cd65bff97a8e 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -75,7 +75,7 @@ static int rxrpc_preparse_xdr_rxkad(struct key_preparsed_payload *prep,
prep->quotalen = datalen + plen;
plen -= sizeof(*token);
- token = kzalloc(sizeof(*token), GFP_KERNEL);
+ token = kzalloc_obj(*token, GFP_KERNEL);
if (!token)
return -ENOMEM;
@@ -202,7 +202,7 @@ static int rxrpc_preparse_xdr_yfs_rxgk(struct key_preparsed_payload *prep,
prep->quotalen = datalen + plen;
plen -= sizeof(*token);
- token = kzalloc(sizeof(*token), GFP_KERNEL);
+ token = kzalloc_obj(*token, GFP_KERNEL);
if (!token)
goto nomem;
@@ -500,7 +500,7 @@ static int rxrpc_preparse(struct key_preparsed_payload *prep)
prep->quotalen = plen + sizeof(*token);
ret = -ENOMEM;
- token = kzalloc(sizeof(*token), GFP_KERNEL);
+ token = kzalloc_obj(*token, GFP_KERNEL);
if (!token)
goto error;
token->kad = kzalloc(plen, GFP_KERNEL);
diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index a74a4b43904f..6f799b26d4d5 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -112,7 +112,7 @@ static struct rxrpc_local *rxrpc_alloc_local(struct net *net,
struct rxrpc_local *local;
u32 tmp;
- local = kzalloc(sizeof(struct rxrpc_local), GFP_KERNEL);
+ local = kzalloc_obj(struct rxrpc_local, GFP_KERNEL);
if (local) {
refcount_set(&local->ref, 1);
atomic_set(&local->active_users, 1);
diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index 366431b0736c..fa9a406e1168 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -226,7 +226,7 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp,
_enter("");
- peer = kzalloc(sizeof(struct rxrpc_peer), gfp);
+ peer = kzalloc_obj(struct rxrpc_peer, gfp);
if (peer) {
refcount_set(&peer->ref, 1);
peer->local = rxrpc_get_local(local, rxrpc_local_get_peer);
diff --git a/net/rxrpc/rxgk.c b/net/rxrpc/rxgk.c
index 43cbf9efd89f..f9f5a2dc62ed 100644
--- a/net/rxrpc/rxgk.c
+++ b/net/rxrpc/rxgk.c
@@ -351,7 +351,7 @@ static int rxgk_secure_packet_integrity(const struct rxrpc_call *call,
_enter("");
- hdr = kzalloc(sizeof(*hdr), GFP_NOFS);
+ hdr = kzalloc_obj(*hdr, GFP_NOFS);
if (!hdr)
goto error_gk;
@@ -483,7 +483,7 @@ static int rxgk_verify_packet_integrity(struct rxrpc_call *call,
crypto_krb5_where_is_the_data(gk->krb5, KRB5_CHECKSUM_MODE,
&data_offset, &data_len);
- hdr = kzalloc(sizeof(*hdr), GFP_NOFS);
+ hdr = kzalloc_obj(*hdr, GFP_NOFS);
if (!hdr)
goto put_gk;
diff --git a/net/rxrpc/rxgk_kdf.c b/net/rxrpc/rxgk_kdf.c
index b4db5aa30e5b..6011fa7cf221 100644
--- a/net/rxrpc/rxgk_kdf.c
+++ b/net/rxrpc/rxgk_kdf.c
@@ -213,7 +213,7 @@ struct rxgk_context *rxgk_generate_transport_key(struct rxrpc_connection *conn,
_enter("");
- gk = kzalloc(sizeof(*gk), GFP_KERNEL);
+ gk = kzalloc_obj(*gk, GFP_KERNEL);
if (!gk)
return ERR_PTR(-ENOMEM);
refcount_set(&gk->usage, 1);
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index a756855a0a62..e923d6829008 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -511,7 +511,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
if (nsg <= 4) {
nsg = 4;
} else {
- sg = kmalloc_array(nsg, sizeof(*sg), GFP_NOIO);
+ sg = kmalloc_objs(*sg, nsg, GFP_NOIO);
if (!sg)
return -ENOMEM;
}
@@ -1139,7 +1139,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn,
}
ret = -ENOMEM;
- response = kzalloc(sizeof(struct rxkad_response), GFP_NOFS);
+ response = kzalloc_obj(struct rxkad_response, GFP_NOFS);
if (!response)
goto temporary_error;
diff --git a/net/rxrpc/rxperf.c b/net/rxrpc/rxperf.c
index 98ea76fae70f..1345ffffb109 100644
--- a/net/rxrpc/rxperf.c
+++ b/net/rxrpc/rxperf.c
@@ -151,7 +151,7 @@ static void rxperf_charge_preallocation(struct work_struct *work)
struct rxperf_call *call;
for (;;) {
- call = kzalloc(sizeof(*call), GFP_KERNEL);
+ call = kzalloc_obj(*call, GFP_KERNEL);
if (!call)
break;
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index ebbb78b842de..04f9c5f2dc24 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -282,7 +282,7 @@ static int rxrpc_alloc_txqueue(struct sock *sk, struct rxrpc_call *call)
{
struct rxrpc_txqueue *tq;
- tq = kzalloc(sizeof(*tq), sk->sk_allocation);
+ tq = kzalloc_obj(*tq, sk->sk_allocation);
if (!tq)
return -ENOMEM;
diff --git a/net/rxrpc/txbuf.c b/net/rxrpc/txbuf.c
index 29767038691a..55ef7a04852e 100644
--- a/net/rxrpc/txbuf.c
+++ b/net/rxrpc/txbuf.c
@@ -23,7 +23,7 @@ struct rxrpc_txbuf *rxrpc_alloc_data_txbuf(struct rxrpc_call *call, size_t data_
size_t total, doff, jsize = sizeof(struct rxrpc_jumbo_header);
void *buf;
- txb = kzalloc(sizeof(*txb), gfp);
+ txb = kzalloc_obj(*txb, gfp);
if (!txb)
return NULL;
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index e1ab0faeb811..389874842982 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -985,7 +985,7 @@ static int tcf_pernet_add_id_list(unsigned int id)
}
}
- id_ptr = kzalloc(sizeof(*id_ptr), GFP_KERNEL);
+ id_ptr = kzalloc_obj(*id_ptr, GFP_KERNEL);
if (!id_ptr) {
ret = -ENOMEM;
goto err_out;
@@ -1272,7 +1272,7 @@ errout:
static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb)
{
- struct tc_cookie *c = kzalloc(sizeof(*c), GFP_KERNEL);
+ struct tc_cookie *c = kzalloc_obj(*c, GFP_KERNEL);
if (!c)
return NULL;
diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c
index 26ba8c2d20ab..19eea8daa6b5 100644
--- a/net/sched/act_connmark.c
+++ b/net/sched/act_connmark.c
@@ -121,7 +121,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla,
if (!tb[TCA_CONNMARK_PARMS])
return -EINVAL;
- nparms = kzalloc(sizeof(*nparms), GFP_KERNEL);
+ nparms = kzalloc_obj(*nparms, GFP_KERNEL);
if (!nparms)
return -ENOMEM;
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
index 0939e6b2ba4d..1cd3336eeeea 100644
--- a/net/sched/act_csum.c
+++ b/net/sched/act_csum.c
@@ -93,7 +93,7 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
p = to_tcf_csum(*a);
- params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
+ params_new = kzalloc_obj(*params_new, GFP_KERNEL);
if (unlikely(!params_new)) {
err = -ENOMEM;
goto put_chain;
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 81d488655793..5f45bec69c50 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -332,7 +332,7 @@ static int tcf_ct_flow_table_get(struct net *net, struct tcf_ct_params *params)
if (ct_ft && refcount_inc_not_zero(&ct_ft->ref))
goto out_unlock;
- ct_ft = kzalloc(sizeof(*ct_ft), GFP_KERNEL);
+ ct_ft = kzalloc_obj(*ct_ft, GFP_KERNEL);
if (!ct_ft)
goto err_alloc;
refcount_set(&ct_ft->ref, 1);
@@ -1397,7 +1397,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,
c = to_ct(*a);
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ params = kzalloc_obj(*params, GFP_KERNEL);
if (unlikely(!params)) {
err = -ENOMEM;
goto cleanup;
diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c
index d2c750bab1d3..00e303a01241 100644
--- a/net/sched/act_ctinfo.c
+++ b/net/sched/act_ctinfo.c
@@ -236,7 +236,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
ci = to_ctinfo(*a);
- cp_new = kzalloc(sizeof(*cp_new), GFP_KERNEL);
+ cp_new = kzalloc_obj(*cp_new, GFP_KERNEL);
if (unlikely(!cp_new)) {
err = -ENOMEM;
goto put_chain;
diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
index c1f75f272757..686eaed81b81 100644
--- a/net/sched/act_gate.c
+++ b/net/sched/act_gate.c
@@ -243,7 +243,7 @@ static int parse_gate_list(struct nlattr *list_attr,
continue;
}
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry) {
NL_SET_ERR_MSG(extack, "Not enough memory for entry");
err = -ENOMEM;
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 8e8f6af731d5..6895834a929c 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -299,7 +299,7 @@ static int __add_metainfo(const struct tcf_meta_ops *ops,
struct tcf_meta_info *mi = NULL;
int ret = 0;
- mi = kzalloc(sizeof(*mi), atomic ? GFP_ATOMIC : GFP_KERNEL);
+ mi = kzalloc_obj(*mi, atomic ? GFP_ATOMIC : GFP_KERNEL);
if (!mi)
return -ENOMEM;
@@ -520,7 +520,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
if (parm->flags & ~IFE_ENCODE)
return -EINVAL;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (!p)
return -ENOMEM;
diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c
index 6654011dcd2b..30c915d43432 100644
--- a/net/sched/act_mpls.c
+++ b/net/sched/act_mpls.c
@@ -279,7 +279,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,
m = to_mpls(*a);
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (!p) {
err = -ENOMEM;
goto put_chain;
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index 26241d80ebe0..7ca2af5a10c3 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -81,7 +81,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
if (err < 0)
goto release_idr;
- nparm = kzalloc(sizeof(*nparm), GFP_KERNEL);
+ nparm = kzalloc_obj(*nparm, GFP_KERNEL);
if (!nparm) {
err = -ENOMEM;
goto release_idr;
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index 4b65901397a8..fb960a05cbc8 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -51,7 +51,7 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
if (!nla)
return NULL;
- keys_ex = kcalloc(n, sizeof(*k), GFP_KERNEL);
+ keys_ex = kzalloc_objs(*k, n, GFP_KERNEL);
if (!keys_ex)
return ERR_PTR(-ENOMEM);
@@ -223,7 +223,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
goto out_release;
}
- nparms = kzalloc(sizeof(*nparms), GFP_KERNEL);
+ nparms = kzalloc_obj(*nparms, GFP_KERNEL);
if (!nparms) {
ret = -ENOMEM;
goto out_release;
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 0e1c61183379..4778c3ebd5db 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -151,7 +151,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla,
goto failure;
}
- new = kzalloc(sizeof(*new), GFP_KERNEL);
+ new = kzalloc_obj(*new, GFP_KERNEL);
if (unlikely(!new)) {
err = -ENOMEM;
goto failure;
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index 5450c1293eb5..e3764d9862ad 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -242,7 +242,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
if (err < 0)
goto release_idr;
- params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
+ params_new = kzalloc_obj(*params_new, GFP_KERNEL);
if (unlikely(!params_new)) {
err = -ENOMEM;
goto put_chain;
diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c
index a9e0c1326e2a..2eaf82dc2179 100644
--- a/net/sched/act_skbmod.c
+++ b/net/sched/act_skbmod.c
@@ -185,7 +185,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla,
d = to_skbmod(*a);
- p = kzalloc(sizeof(struct tcf_skbmod_params), GFP_KERNEL);
+ p = kzalloc_obj(struct tcf_skbmod_params, GFP_KERNEL);
if (unlikely(!p)) {
err = -ENOMEM;
goto put_chain;
diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c
index a74621797d69..51ac783f7d6c 100644
--- a/net/sched/act_vlan.c
+++ b/net/sched/act_vlan.c
@@ -233,7 +233,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
v = to_vlan(*a);
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (!p) {
err = -ENOMEM;
goto put_chain;
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index ebca4b926dcf..22e8527657af 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -84,7 +84,7 @@ tcf_exts_miss_cookie_base_alloc(struct tcf_exts *exts, struct tcf_proto *tp,
if (WARN_ON(!handle || !tp->ops->get_exts))
return -EINVAL;
- n = kzalloc(sizeof(*n), GFP_KERNEL);
+ n = kzalloc_obj(*n, GFP_KERNEL);
if (!n)
return -ENOMEM;
@@ -377,7 +377,7 @@ static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol,
struct tcf_proto *tp;
int err;
- tp = kzalloc(sizeof(*tp), GFP_KERNEL);
+ tp = kzalloc_obj(*tp, GFP_KERNEL);
if (!tp)
return ERR_PTR(-ENOBUFS);
@@ -502,7 +502,7 @@ static struct tcf_chain *tcf_chain_create(struct tcf_block *block,
ASSERT_BLOCK_LOCKED(block);
- chain = kzalloc(sizeof(*chain), GFP_KERNEL);
+ chain = kzalloc_obj(*chain, GFP_KERNEL);
if (!chain)
return NULL;
list_add_tail_rcu(&chain->list, &block->chain_list);
@@ -918,7 +918,7 @@ tcf_chain0_head_change_cb_add(struct tcf_block *block,
struct tcf_filter_chain_list_item *item;
struct tcf_chain *chain0;
- item = kmalloc(sizeof(*item), GFP_KERNEL);
+ item = kmalloc_obj(*item, GFP_KERNEL);
if (!item) {
NL_SET_ERR_MSG(extack, "Memory allocation for head change callback item failed");
return -ENOMEM;
@@ -1016,7 +1016,7 @@ static struct tcf_block *tcf_block_create(struct net *net, struct Qdisc *q,
{
struct tcf_block *block;
- block = kzalloc(sizeof(*block), GFP_KERNEL);
+ block = kzalloc_obj(*block, GFP_KERNEL);
if (!block) {
NL_SET_ERR_MSG(extack, "Memory allocation for block failed");
return ERR_PTR(-ENOMEM);
@@ -1428,7 +1428,7 @@ static int tcf_block_owner_add(struct tcf_block *block,
{
struct tcf_block_owner_item *item;
- item = kmalloc(sizeof(*item), GFP_KERNEL);
+ item = kmalloc_obj(*item, GFP_KERNEL);
if (!item)
return -ENOMEM;
item->q = q;
@@ -3341,8 +3341,8 @@ int tcf_exts_init_ex(struct tcf_exts *exts, struct net *net, int action,
* This reference might be taken later from tcf_exts_get_net().
*/
exts->net = net;
- exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *),
- GFP_KERNEL);
+ exts->actions = kzalloc_objs(struct tc_action *, TCA_ACT_MAX_PRIO,
+ GFP_KERNEL);
if (!exts->actions)
return -ENOMEM;
#endif
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index ecfaa4f9a04e..5479fd5341b2 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -77,7 +77,7 @@ static int basic_init(struct tcf_proto *tp)
{
struct basic_head *head;
- head = kzalloc(sizeof(*head), GFP_KERNEL);
+ head = kzalloc_obj(*head, GFP_KERNEL);
if (head == NULL)
return -ENOBUFS;
INIT_LIST_HEAD(&head->flist);
@@ -193,7 +193,7 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
return -EINVAL;
}
- fnew = kzalloc(sizeof(*fnew), GFP_KERNEL);
+ fnew = kzalloc_obj(*fnew, GFP_KERNEL);
if (!fnew)
return -ENOBUFS;
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index a32754a2658b..f42b89ba10a8 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -242,7 +242,7 @@ static int cls_bpf_init(struct tcf_proto *tp)
{
struct cls_bpf_head *head;
- head = kzalloc(sizeof(*head), GFP_KERNEL);
+ head = kzalloc_obj(*head, GFP_KERNEL);
if (head == NULL)
return -ENOBUFS;
@@ -427,7 +427,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
if (ret < 0)
return ret;
- prog = kzalloc(sizeof(*prog), GFP_KERNEL);
+ prog = kzalloc_obj(*prog, GFP_KERNEL);
if (!prog)
return -ENOBUFS;
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 424252982d6a..d177b1cfde60 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -95,7 +95,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
if (head && handle != head->handle)
return -ENOENT;
- new = kzalloc(sizeof(*head), GFP_KERNEL);
+ new = kzalloc_obj(*head, GFP_KERNEL);
if (!new)
return -ENOBUFS;
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index 5693b41b093f..83d837c4bced 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -433,7 +433,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
return -EOPNOTSUPP;
}
- fnew = kzalloc(sizeof(*fnew), GFP_KERNEL);
+ fnew = kzalloc_obj(*fnew, GFP_KERNEL);
if (!fnew)
return -ENOBUFS;
@@ -583,7 +583,7 @@ static int flow_init(struct tcf_proto *tp)
{
struct flow_head *head;
- head = kzalloc(sizeof(*head), GFP_KERNEL);
+ head = kzalloc_obj(*head, GFP_KERNEL);
if (head == NULL)
return -ENOBUFS;
INIT_LIST_HEAD(&head->filters);
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 7669371c1354..3c930039bacb 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -363,7 +363,7 @@ static int fl_init(struct tcf_proto *tp)
{
struct cls_fl_head *head;
- head = kzalloc(sizeof(*head), GFP_KERNEL);
+ head = kzalloc_obj(*head, GFP_KERNEL);
if (!head)
return -ENOBUFS;
@@ -2237,7 +2237,7 @@ static struct fl_flow_mask *fl_create_new_mask(struct cls_fl_head *head,
struct fl_flow_mask *newmask;
int err;
- newmask = kzalloc(sizeof(*newmask), GFP_KERNEL);
+ newmask = kzalloc_obj(*newmask, GFP_KERNEL);
if (!newmask)
return ERR_PTR(-ENOMEM);
@@ -2376,13 +2376,13 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
goto errout_fold;
}
- mask = kzalloc(sizeof(struct fl_flow_mask), GFP_KERNEL);
+ mask = kzalloc_obj(struct fl_flow_mask, GFP_KERNEL);
if (!mask) {
err = -ENOBUFS;
goto errout_fold;
}
- tb = kcalloc(TCA_FLOWER_MAX + 1, sizeof(struct nlattr *), GFP_KERNEL);
+ tb = kzalloc_objs(struct nlattr *, TCA_FLOWER_MAX + 1, GFP_KERNEL);
if (!tb) {
err = -ENOBUFS;
goto errout_mask_alloc;
@@ -2398,7 +2398,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
goto errout_tb;
}
- fnew = kzalloc(sizeof(*fnew), GFP_KERNEL);
+ fnew = kzalloc_obj(*fnew, GFP_KERNEL);
if (!fnew) {
err = -ENOBUFS;
goto errout_tb;
@@ -2815,7 +2815,7 @@ static void *fl_tmplt_create(struct net *net, struct tcf_chain *chain,
if (!tca_opts)
return ERR_PTR(-EINVAL);
- tb = kcalloc(TCA_FLOWER_MAX + 1, sizeof(struct nlattr *), GFP_KERNEL);
+ tb = kzalloc_objs(struct nlattr *, TCA_FLOWER_MAX + 1, GFP_KERNEL);
if (!tb)
return ERR_PTR(-ENOBUFS);
err = nla_parse_nested_deprecated(tb, TCA_FLOWER_MAX,
@@ -2823,7 +2823,7 @@ static void *fl_tmplt_create(struct net *net, struct tcf_chain *chain,
if (err)
goto errout_tb;
- tmplt = kzalloc(sizeof(*tmplt), GFP_KERNEL);
+ tmplt = kzalloc_obj(*tmplt, GFP_KERNEL);
if (!tmplt) {
err = -ENOMEM;
goto errout_tb;
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index cdddc8695228..8eb3bea06e3b 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -262,7 +262,7 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
if (f->id != handle && handle)
return -EINVAL;
- fnew = kzalloc(sizeof(struct fw_filter), GFP_KERNEL);
+ fnew = kzalloc_obj(struct fw_filter, GFP_KERNEL);
if (!fnew)
return -ENOBUFS;
@@ -308,7 +308,7 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
if (tb[TCA_FW_MASK])
mask = nla_get_u32(tb[TCA_FW_MASK]);
- head = kzalloc(sizeof(*head), GFP_KERNEL);
+ head = kzalloc_obj(*head, GFP_KERNEL);
if (!head)
return -ENOBUFS;
head->mask = mask;
@@ -316,7 +316,7 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
rcu_assign_pointer(tp->root, head);
}
- f = kzalloc(sizeof(struct fw_filter), GFP_KERNEL);
+ f = kzalloc_obj(struct fw_filter, GFP_KERNEL);
if (f == NULL)
return -ENOBUFS;
diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index f03bf5da39ee..e78b6da59782 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -189,7 +189,7 @@ static int mall_change(struct net *net, struct sk_buff *in_skb,
return -EINVAL;
}
- new = kzalloc(sizeof(*new), GFP_KERNEL);
+ new = kzalloc_obj(*new, GFP_KERNEL);
if (!new)
return -ENOBUFS;
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index b9c58c040c30..6e16819ba91f 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -244,7 +244,7 @@ static int route4_init(struct tcf_proto *tp)
{
struct route4_head *head;
- head = kzalloc(sizeof(struct route4_head), GFP_KERNEL);
+ head = kzalloc_obj(struct route4_head, GFP_KERNEL);
if (head == NULL)
return -ENOBUFS;
@@ -438,7 +438,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
h1 = to_hash(nhandle);
b = rtnl_dereference(head->table[h1]);
if (!b) {
- b = kzalloc(sizeof(struct route4_bucket), GFP_KERNEL);
+ b = kzalloc_obj(struct route4_bucket, GFP_KERNEL);
if (b == NULL)
return -ENOBUFS;
@@ -507,7 +507,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
return -EINVAL;
err = -ENOBUFS;
- f = kzalloc(sizeof(struct route4_filter), GFP_KERNEL);
+ f = kzalloc_obj(struct route4_filter, GFP_KERNEL);
if (!f)
goto errout;
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 58e849c0acf4..2bdc14c5e533 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -364,7 +364,7 @@ static int u32_init(struct tcf_proto *tp)
void *key = tc_u_common_ptr(tp);
struct tc_u_common *tp_c = tc_u_common_find(key);
- root_ht = kzalloc(struct_size(root_ht, ht, 1), GFP_KERNEL);
+ root_ht = kzalloc_flex(*root_ht, ht, 1, GFP_KERNEL);
if (root_ht == NULL)
return -ENOBUFS;
@@ -375,7 +375,7 @@ static int u32_init(struct tcf_proto *tp)
idr_init(&root_ht->handle_idr);
if (tp_c == NULL) {
- tp_c = kzalloc(sizeof(*tp_c), GFP_KERNEL);
+ tp_c = kzalloc_obj(*tp_c, GFP_KERNEL);
if (tp_c == NULL) {
kfree(root_ht);
return -ENOBUFS;
@@ -825,7 +825,7 @@ static struct tc_u_knode *u32_init_knode(struct net *net, struct tcf_proto *tp,
struct tc_u32_sel *s = &n->sel;
struct tc_u_knode *new;
- new = kzalloc(struct_size(new, sel.keys, s->nkeys), GFP_KERNEL);
+ new = kzalloc_flex(*new, sel.keys, s->nkeys, GFP_KERNEL);
if (!new)
return NULL;
@@ -974,7 +974,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
NL_SET_ERR_MSG_MOD(extack, "Divisor can only be used on a hash table");
return -EINVAL;
}
- ht = kzalloc(struct_size(ht, ht, divisor + 1), GFP_KERNEL);
+ ht = kzalloc_flex(*ht, ht, divisor + 1, GFP_KERNEL);
if (ht == NULL)
return -ENOBUFS;
if (handle == 0) {
@@ -1104,7 +1104,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
goto erridr;
}
- n = kzalloc(struct_size(n, sel.keys, s->nkeys), GFP_KERNEL);
+ n = kzalloc_flex(*n, sel.keys, s->nkeys, GFP_KERNEL);
if (n == NULL) {
err = -ENOBUFS;
goto erridr;
@@ -1417,7 +1417,7 @@ static int u32_dump(struct net *net, struct tcf_proto *tp, void *fh,
goto nla_put_failure;
}
#ifdef CONFIG_CLS_U32_PERF
- gpf = kzalloc(struct_size(gpf, kcnts, n->sel.nkeys), GFP_KERNEL);
+ gpf = kzalloc_flex(*gpf, kcnts, n->sel.nkeys, GFP_KERNEL);
if (!gpf)
goto nla_put_failure;
@@ -1480,9 +1480,8 @@ static int __init init_u32(void)
#ifdef CONFIG_NET_CLS_ACT
pr_info(" Actions configured\n");
#endif
- tc_u_common_hash = kvmalloc_array(U32_HASH_SIZE,
- sizeof(struct hlist_head),
- GFP_KERNEL);
+ tc_u_common_hash = kvmalloc_objs(struct hlist_head, U32_HASH_SIZE,
+ GFP_KERNEL);
if (!tc_u_common_hash)
return -ENOMEM;
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index 3f2e707a11d1..bc47af8a45c6 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -927,7 +927,7 @@ static int em_meta_change(struct net *net, void *data, int len,
TCF_META_ID(hdr->right.kind) > TCF_META_ID_MAX)
goto errout;
- meta = kzalloc(sizeof(*meta), GFP_KERNEL);
+ meta = kzalloc_obj(*meta, GFP_KERNEL);
if (meta == NULL) {
err = -ENOMEM;
goto errout;
diff --git a/net/sched/em_text.c b/net/sched/em_text.c
index 692e2be1793e..a69889159537 100644
--- a/net/sched/em_text.c
+++ b/net/sched/em_text.c
@@ -84,7 +84,7 @@ retry:
return -EAGAIN;
}
- tm = kmalloc(sizeof(*tm), GFP_KERNEL);
+ tm = kmalloc_obj(*tm, GFP_KERNEL);
if (tm == NULL) {
textsearch_destroy(ts_conf);
return -ENOBUFS;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 443c116e8663..bcf82bbc60fd 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -437,7 +437,7 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r,
}
}
- rtab = kmalloc(sizeof(*rtab), GFP_KERNEL);
+ rtab = kmalloc_obj(*rtab, GFP_KERNEL);
if (rtab) {
rtab->rate = *r;
rtab->refcnt = 1;
@@ -530,7 +530,7 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt,
return ERR_PTR(-EINVAL);
}
- stab = kmalloc(struct_size(stab, data, tsize), GFP_KERNEL);
+ stab = kmalloc_flex(*stab, data, tsize, GFP_KERNEL);
if (!stab)
return ERR_PTR(-ENOMEM);
@@ -668,7 +668,7 @@ static struct hlist_head *qdisc_class_hash_alloc(unsigned int n)
struct hlist_head *h;
unsigned int i;
- h = kvmalloc_array(n, sizeof(struct hlist_head), GFP_KERNEL);
+ h = kvmalloc_objs(struct hlist_head, n, GFP_KERNEL);
if (h != NULL) {
for (i = 0; i < n; i++)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index d2bbd5654d5b..7c7a068513e7 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -2849,8 +2849,8 @@ static int cake_init(struct Qdisc *sch, struct nlattr *opt,
for (i = 1; i <= CAKE_QUEUES; i++)
quantum_div[i] = 65535 / i;
- qd->tins = kvcalloc(CAKE_MAX_TINS, sizeof(struct cake_tin_data),
- GFP_KERNEL);
+ qd->tins = kvzalloc_objs(struct cake_tin_data, CAKE_MAX_TINS,
+ GFP_KERNEL);
if (!qd->tins)
return -ENOMEM;
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index 59e7bdf5063e..8d2dd1c4f3dc 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -370,7 +370,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt,
if (mask != q->tab_mask) {
struct sk_buff **ntab;
- ntab = kvcalloc(mask + 1, sizeof(struct sk_buff *), GFP_KERNEL);
+ ntab = kvzalloc_objs(struct sk_buff *, mask + 1, GFP_KERNEL);
if (!ntab)
return -ENOMEM;
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
index 9b6d79bd8737..80d845dfbe80 100644
--- a/net/sched/sch_drr.c
+++ b/net/sched/sch_drr.c
@@ -105,7 +105,7 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
return 0;
}
- cl = kzalloc(sizeof(struct drr_class), GFP_KERNEL);
+ cl = kzalloc_obj(struct drr_class, GFP_KERNEL);
if (cl == NULL)
return -ENOBUFS;
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index dc187c7f06b1..16cd38a179e5 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -496,9 +496,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
goto init_failure;
if (!q->flows) {
- q->flows = kvcalloc(q->flows_cnt,
- sizeof(struct fq_codel_flow),
- GFP_KERNEL);
+ q->flows = kvzalloc_objs(struct fq_codel_flow, q->flows_cnt,
+ GFP_KERNEL);
if (!q->flows) {
err = -ENOMEM;
goto init_failure;
diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
index 7b96bc3ff891..8784f89619d0 100644
--- a/net/sched/sch_fq_pie.c
+++ b/net/sched/sch_fq_pie.c
@@ -448,8 +448,7 @@ static int fq_pie_init(struct Qdisc *sch, struct nlattr *opt,
if (err)
goto init_failure;
- q->flows = kvcalloc(q->flows_cnt, sizeof(struct fq_pie_flow),
- GFP_KERNEL);
+ q->flows = kvzalloc_objs(struct fq_pie_flow, q->flows_cnt, GFP_KERNEL);
if (!q->flows) {
err = -ENOMEM;
goto init_failure;
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index 532fde548b88..ec4c8513e617 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -359,7 +359,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch)
unsigned int i;
int ret;
- hw_stats = kzalloc(sizeof(*hw_stats), GFP_KERNEL);
+ hw_stats = kzalloc_obj(*hw_stats, GFP_KERNEL);
if (!hw_stats)
return -ENOMEM;
@@ -700,7 +700,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt,
prio = ctl->prio;
}
- prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
+ prealloc = kzalloc_obj(*prealloc, GFP_KERNEL);
sch_tree_lock(sch);
err = gred_change_vq(sch, ctl->DP, ctl, prio, stab, max_P, &prealloc,
@@ -757,7 +757,7 @@ static int gred_init(struct Qdisc *sch, struct nlattr *opt,
* psched_mtu(qdisc_dev(sch));
if (qdisc_dev(sch)->netdev_ops->ndo_setup_tc) {
- table->opt = kzalloc(sizeof(*table->opt), GFP_KERNEL);
+ table->opt = kzalloc_obj(*table->opt, GFP_KERNEL);
if (!table->opt)
return -ENOMEM;
}
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index d8fd35da32a7..3f08daae26d8 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1025,7 +1025,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
if (rsc == NULL && fsc == NULL)
return -EINVAL;
- cl = kzalloc(sizeof(struct hfsc_class), GFP_KERNEL);
+ cl = kzalloc_obj(struct hfsc_class, GFP_KERNEL);
if (cl == NULL)
return -ENOBUFS;
diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c
index 2d4855e28a28..a386c40b67da 100644
--- a/net/sched/sch_hhf.c
+++ b/net/sched/sch_hhf.c
@@ -230,7 +230,7 @@ static struct hh_flow_state *alloc_new_hh(struct list_head *head,
return NULL;
}
/* Create new entry. */
- flow = kzalloc(sizeof(struct hh_flow_state), GFP_ATOMIC);
+ flow = kzalloc_obj(struct hh_flow_state, GFP_ATOMIC);
if (!flow)
return NULL;
@@ -604,8 +604,8 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt,
if (!q->hh_flows) {
/* Initialize heavy-hitter flow table. */
- q->hh_flows = kvcalloc(HH_FLOWS_CNT, sizeof(struct list_head),
- GFP_KERNEL);
+ q->hh_flows = kvzalloc_objs(struct list_head, HH_FLOWS_CNT,
+ GFP_KERNEL);
if (!q->hh_flows)
return -ENOMEM;
for (i = 0; i < HH_FLOWS_CNT; i++)
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index b5e40c51655a..7b34e40d4bd2 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1095,9 +1095,9 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt,
}
q->num_direct_qdiscs = dev->real_num_tx_queues;
- q->direct_qdiscs = kcalloc(q->num_direct_qdiscs,
- sizeof(*q->direct_qdiscs),
- GFP_KERNEL);
+ q->direct_qdiscs = kzalloc_objs(*q->direct_qdiscs,
+ q->num_direct_qdiscs,
+ GFP_KERNEL);
if (!q->direct_qdiscs)
return -ENOMEM;
}
@@ -1845,7 +1845,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
goto failure;
}
err = -ENOBUFS;
- cl = kzalloc(sizeof(*cl), GFP_KERNEL);
+ cl = kzalloc_obj(*cl, GFP_KERNEL);
if (!cl)
goto failure;
diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c
index bb94cd577943..4dd8379c97b6 100644
--- a/net/sched/sch_mq.c
+++ b/net/sched/sch_mq.c
@@ -82,8 +82,8 @@ int mq_init_common(struct Qdisc *sch, struct nlattr *opt,
return -EOPNOTSUPP;
/* pre-allocate qdiscs, attachment can't fail */
- priv->qdiscs = kcalloc(dev->num_tx_queues, sizeof(priv->qdiscs[0]),
- GFP_KERNEL);
+ priv->qdiscs = kzalloc_objs(priv->qdiscs[0], dev->num_tx_queues,
+ GFP_KERNEL);
if (!priv->qdiscs)
return -ENOMEM;
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index f3e5ef9a9592..ddb18e97bb91 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -388,8 +388,8 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt,
}
/* pre-allocate qdisc, attachment can't fail */
- priv->qdiscs = kcalloc(dev->num_tx_queues, sizeof(priv->qdiscs[0]),
- GFP_KERNEL);
+ priv->qdiscs = kzalloc_objs(priv->qdiscs[0], dev->num_tx_queues,
+ GFP_KERNEL);
if (!priv->qdiscs)
return -ENOMEM;
diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
index 06e03f5cd7ce..e61e53e3711f 100644
--- a/net/sched/sch_multiq.c
+++ b/net/sched/sch_multiq.c
@@ -249,7 +249,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt,
q->max_bands = qdisc_dev(sch)->num_tx_queues;
- q->queues = kcalloc(q->max_bands, sizeof(struct Qdisc *), GFP_KERNEL);
+ q->queues = kzalloc_objs(struct Qdisc *, q->max_bands, GFP_KERNEL);
if (!q->queues)
return -ENOBUFS;
for (i = 0; i < q->max_bands; i++)
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 32a5f3304046..334d2f93ae89 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -814,7 +814,7 @@ static int get_dist_table(struct disttable **tbl, const struct nlattr *attr)
if (!n || n > NETEM_DIST_MAX)
return -EINVAL;
- d = kvmalloc(struct_size(d, table, n), GFP_KERNEL);
+ d = kvmalloc_flex(*d, table, n, GFP_KERNEL);
if (!d)
return -ENOMEM;
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index e7778413e72f..6eb71d3f03dd 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -392,7 +392,7 @@ static int qfq_change_agg(struct Qdisc *sch, struct qfq_class *cl, u32 weight,
new_agg = qfq_find_agg(q, lmax, weight);
if (new_agg == NULL) { /* create new aggregate */
- new_agg = kzalloc(sizeof(*new_agg), GFP_ATOMIC);
+ new_agg = kzalloc_obj(*new_agg, GFP_ATOMIC);
if (new_agg == NULL)
return -ENOBUFS;
qfq_init_agg(q, new_agg, lmax, weight);
@@ -476,7 +476,7 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
}
/* create and init new class */
- cl = kzalloc(sizeof(struct qfq_class), GFP_KERNEL);
+ cl = kzalloc_obj(struct qfq_class, GFP_KERNEL);
if (cl == NULL)
return -ENOBUFS;
@@ -508,7 +508,7 @@ set_change_agg:
new_agg = qfq_find_agg(q, lmax, weight);
if (new_agg == NULL) { /* create new aggregate */
sch_tree_unlock(sch);
- new_agg = kzalloc(sizeof(*new_agg), GFP_KERNEL);
+ new_agg = kzalloc_obj(*new_agg, GFP_KERNEL);
if (new_agg == NULL) {
err = -ENOBUFS;
gen_kill_estimator(&cl->rate_est);
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 96eb2f122973..31ee70314431 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -668,7 +668,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,
ctl_v1->Wlog, ctl_v1->Scell_log, NULL))
return -EINVAL;
if (ctl_v1 && ctl_v1->qth_min) {
- p = kmalloc(sizeof(*p), GFP_KERNEL);
+ p = kmalloc_obj(*p, GFP_KERNEL);
if (!p)
return -ENOMEM;
}
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 300d577b3286..31e59e875932 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1103,7 +1103,7 @@ static int parse_sched_list(struct taprio_sched *q, struct nlattr *list,
continue;
}
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry) {
NL_SET_ERR_MSG(extack, "Not enough memory for entry");
return -ENOMEM;
@@ -1376,8 +1376,8 @@ static struct tc_taprio_qopt_offload *taprio_offload_alloc(int num_entries)
{
struct __tc_taprio_qopt_offload *__offload;
- __offload = kzalloc(struct_size(__offload, offload.entries, num_entries),
- GFP_KERNEL);
+ __offload = kzalloc_flex(*__offload, offload.entries, num_entries,
+ GFP_KERNEL);
if (!__offload)
return NULL;
@@ -1870,7 +1870,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
if (err)
return err;
- new_admin = kzalloc(sizeof(*new_admin), GFP_KERNEL);
+ new_admin = kzalloc_obj(*new_admin, GFP_KERNEL);
if (!new_admin) {
NL_SET_ERR_MSG(extack, "Not enough memory for a new schedule");
return -ENOMEM;
@@ -2091,8 +2091,7 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
return -EOPNOTSUPP;
}
- q->qdiscs = kcalloc(dev->num_tx_queues, sizeof(q->qdiscs[0]),
- GFP_KERNEL);
+ q->qdiscs = kzalloc_objs(q->qdiscs[0], dev->num_tx_queues, GFP_KERNEL);
if (!q->qdiscs)
return -ENOMEM;
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 5793d71852b8..62d3cc155809 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -289,7 +289,7 @@ struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep,
{
struct sctp_association *asoc;
- asoc = kzalloc(sizeof(*asoc), gfp);
+ asoc = kzalloc_obj(*asoc, gfp);
if (!asoc)
goto fail;
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 82aad477590e..be9782760f50 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -82,7 +82,7 @@ struct sctp_shared_key *sctp_auth_shkey_create(__u16 key_id, gfp_t gfp)
struct sctp_shared_key *new;
/* Allocate the shared key container */
- new = kzalloc(sizeof(struct sctp_shared_key), gfp);
+ new = kzalloc_obj(struct sctp_shared_key, gfp);
if (!new)
return NULL;
@@ -931,8 +931,8 @@ int sctp_auth_init(struct sctp_endpoint *ep, gfp_t gfp)
if (!ep->auth_hmacs_list) {
struct sctp_hmac_algo_param *auth_hmacs;
- auth_hmacs = kzalloc(struct_size(auth_hmacs, hmac_ids,
- SCTP_AUTH_NUM_HMACS), gfp);
+ auth_hmacs = kzalloc_flex(*auth_hmacs, hmac_ids,
+ SCTP_AUTH_NUM_HMACS, gfp);
if (!auth_hmacs)
goto nomem;
/* Initialize the HMACS parameter.
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index 6b95d3ba8fe1..75e3e61d494e 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -147,7 +147,7 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
struct sctp_sockaddr_entry *addr;
/* Add the address to the bind address list. */
- addr = kzalloc(sizeof(*addr), gfp);
+ addr = kzalloc_obj(*addr, gfp);
if (!addr)
return -ENOMEM;
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index c655b571ca01..5b889e89e9f2 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -47,7 +47,7 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg)
static struct sctp_datamsg *sctp_datamsg_new(gfp_t gfp)
{
struct sctp_datamsg *msg;
- msg = kmalloc(sizeof(struct sctp_datamsg), gfp);
+ msg = kmalloc_obj(struct sctp_datamsg, gfp);
if (msg) {
sctp_datamsg_init(msg);
SCTP_DBG_OBJCNT_INC(datamsg);
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 31e989dfe846..8d342b514142 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -135,7 +135,7 @@ struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, gfp_t gfp)
struct sctp_endpoint *ep;
/* Build a local endpoint. */
- ep = kzalloc(sizeof(*ep), gfp);
+ ep = kzalloc_obj(*ep, gfp);
if (!ep)
goto fail;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 531cb0690007..53a5c027f8e3 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -83,7 +83,7 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
switch (ev) {
case NETDEV_UP:
- addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
+ addr = kzalloc_obj(*addr, GFP_ATOMIC);
if (addr) {
addr->a.v6.sin6_family = AF_INET6;
addr->a.v6.sin6_addr = ifa->addr;
@@ -471,7 +471,7 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,
read_lock_bh(&in6_dev->lock);
list_for_each_entry(ifp, &in6_dev->addr_list, if_list) {
/* Add the address to the local list. */
- addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
+ addr = kzalloc_obj(*addr, GFP_ATOMIC);
if (addr) {
addr->a.v6.sin6_family = AF_INET6;
addr->a.v6.sin6_addr = ifp->addr;
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2c3398f75d76..0723cbdbc366 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -86,7 +86,7 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
in_dev_for_each_ifa_rcu(ifa, in_dev) {
/* Add the address to the local list. */
- addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
+ addr = kzalloc_obj(*addr, GFP_ATOMIC);
if (addr) {
addr->a.v4.sin_family = AF_INET;
addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
@@ -774,7 +774,7 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
switch (ev) {
case NETDEV_UP:
- addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
+ addr = kzalloc_obj(*addr, GFP_ATOMIC);
if (addr) {
addr->a.v4.sin_family = AF_INET;
addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
@@ -1538,7 +1538,7 @@ static __init int sctp_init(void)
/* Allocate and initialize the endpoint hash table. */
sctp_ep_hashsize = 64;
sctp_ep_hashtable =
- kmalloc_array(64, sizeof(struct sctp_hashbucket), GFP_KERNEL);
+ kmalloc_objs(struct sctp_hashbucket, 64, GFP_KERNEL);
if (!sctp_ep_hashtable) {
pr_err("Failed endpoint_hash alloc\n");
status = -ENOMEM;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 2493a5b1fa3c..05fb00c9c335 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -828,7 +828,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
if (asoc->asconf_addr_del_pending)
continue;
asoc->asconf_addr_del_pending =
- kzalloc(sizeof(union sctp_addr), GFP_ATOMIC);
+ kzalloc_obj(union sctp_addr, GFP_ATOMIC);
if (asoc->asconf_addr_del_pending == NULL) {
retval = -ENOMEM;
goto out;
diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 0615e4426341..03636bed60ff 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -166,7 +166,7 @@ int sctp_stream_init_ext(struct sctp_stream *stream, __u16 sid)
struct sctp_stream_out_ext *soute;
int ret;
- soute = kzalloc(sizeof(*soute), GFP_KERNEL);
+ soute = kzalloc_obj(*soute, GFP_KERNEL);
if (!soute)
return -ENOMEM;
SCTP_SO(stream, sid)->ext = soute;
diff --git a/net/sctp/stream_sched_prio.c b/net/sctp/stream_sched_prio.c
index fb6c55e5615d..bd4f98db2822 100644
--- a/net/sctp/stream_sched_prio.c
+++ b/net/sctp/stream_sched_prio.c
@@ -42,7 +42,7 @@ static struct sctp_stream_priorities *sctp_sched_prio_new_head(
{
struct sctp_stream_priorities *p;
- p = kmalloc(sizeof(*p), gfp);
+ p = kmalloc_obj(*p, gfp);
if (!p)
return NULL;
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 0c56d9673cc1..6ea55b9fbde4 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -92,7 +92,7 @@ struct sctp_transport *sctp_transport_new(struct net *net,
{
struct sctp_transport *transport;
- transport = kzalloc(sizeof(*transport), gfp);
+ transport = kzalloc_obj(*transport, gfp);
if (!transport)
return NULL;
diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index 7101a48bce54..ca7a6167702d 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -272,7 +272,7 @@ net_shaper_hierarchy_setup(struct net_shaper_binding *binding)
if (hierarchy)
return hierarchy;
- hierarchy = kmalloc(sizeof(*hierarchy), GFP_KERNEL);
+ hierarchy = kmalloc_obj(*hierarchy, GFP_KERNEL);
if (!hierarchy)
return NULL;
@@ -329,7 +329,7 @@ static int net_shaper_pre_insert(struct net_shaper_binding *binding,
id_allocated = true;
}
- cur = kzalloc(sizeof(*cur), GFP_KERNEL);
+ cur = kzalloc_obj(*cur, GFP_KERNEL);
if (!cur) {
ret = -ENOMEM;
goto free_id;
@@ -1033,8 +1033,7 @@ static int net_shaper_pre_del_node(struct net_shaper_binding *binding,
return -EINVAL;
}
- leaves = kcalloc(shaper->leaves, sizeof(struct net_shaper),
- GFP_KERNEL);
+ leaves = kzalloc_objs(struct net_shaper, shaper->leaves, GFP_KERNEL);
if (!leaves)
return -ENOMEM;
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index d8201eb3ac5f..242101f269c3 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1195,7 +1195,7 @@ void smc_fill_gid_list(struct smc_link_group *lgr,
memset(gidlist, 0, sizeof(*gidlist));
memcpy(gidlist->list[gidlist->len++], known_gid, SMC_GID_SIZE);
- alt_ini = kzalloc(sizeof(*alt_ini), GFP_KERNEL);
+ alt_ini = kzalloc_obj(*alt_ini, GFP_KERNEL);
if (!alt_ini)
goto out;
@@ -1522,7 +1522,7 @@ static int __smc_connect(struct smc_sock *smc)
return smc_connect_decline_fallback(smc, SMC_CLC_DECL_IPSEC,
version);
- ini = kzalloc(sizeof(*ini), GFP_KERNEL);
+ ini = kzalloc_obj(*ini, GFP_KERNEL);
if (!ini)
return smc_connect_decline_fallback(smc, SMC_CLC_DECL_MEM,
version);
@@ -2470,7 +2470,7 @@ static void smc_listen_work(struct work_struct *work)
/* do inband token exchange -
* wait for and receive SMC Proposal CLC message
*/
- buf = kzalloc(sizeof(*buf), GFP_KERNEL);
+ buf = kzalloc_obj(*buf, GFP_KERNEL);
if (!buf) {
rc = SMC_CLC_DECL_MEM;
goto out_decl;
@@ -2490,7 +2490,7 @@ static void smc_listen_work(struct work_struct *work)
goto out_decl;
}
- ini = kzalloc(sizeof(*ini), GFP_KERNEL);
+ ini = kzalloc_obj(*ini, GFP_KERNEL);
if (!ini) {
rc = SMC_CLC_DECL_MEM;
goto out_decl;
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index 87c87edadde7..992fd2b9f05f 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -88,7 +88,7 @@ static int smc_clc_ueid_add(char *ueid)
return -EINVAL;
/* add a new ueid entry to the ueid table if there isn't one */
- new_ueid = kzalloc(sizeof(*new_ueid), GFP_KERNEL);
+ new_ueid = kzalloc_obj(*new_ueid, GFP_KERNEL);
if (!new_ueid)
return -ENOMEM;
memcpy(new_ueid->eid, ueid, SMC_MAX_EID_LEN);
@@ -861,7 +861,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
struct kvec vec[8];
struct msghdr msg;
- pclc = kzalloc(sizeof(*pclc), GFP_KERNEL);
+ pclc = kzalloc_obj(*pclc, GFP_KERNEL);
if (!pclc)
return -ENOMEM;
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index e4eabc83719e..50d01a573042 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -905,7 +905,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
}
}
- lgr = kzalloc(sizeof(*lgr), GFP_KERNEL);
+ lgr = kzalloc_obj(*lgr, GFP_KERNEL);
if (!lgr) {
rc = SMC_CLC_DECL_MEM;
goto ism_put_vlan;
@@ -2320,7 +2320,7 @@ static struct smc_buf_desc *smcr_new_buf_create(struct smc_link_group *lgr,
struct smc_buf_desc *buf_desc;
/* try to alloc a new buffer */
- buf_desc = kzalloc(sizeof(*buf_desc), GFP_KERNEL);
+ buf_desc = kzalloc_obj(*buf_desc, GFP_KERNEL);
if (!buf_desc)
return ERR_PTR(-ENOMEM);
@@ -2394,7 +2394,7 @@ static struct smc_buf_desc *smcd_new_buf_create(struct smc_link_group *lgr,
int rc;
/* try to alloc a new DMB */
- buf_desc = kzalloc(sizeof(*buf_desc), GFP_KERNEL);
+ buf_desc = kzalloc_obj(*buf_desc, GFP_KERNEL);
if (!buf_desc)
return ERR_PTR(-ENOMEM);
if (is_dmb) {
@@ -2578,7 +2578,7 @@ int smcd_buf_attach(struct smc_sock *smc)
struct smc_buf_desc *buf_desc;
int rc;
- buf_desc = kzalloc(sizeof(*buf_desc), GFP_KERNEL);
+ buf_desc = kzalloc_obj(*buf_desc, GFP_KERNEL);
if (!buf_desc)
return -ENOMEM;
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index 1154907c5c05..5a1384126f91 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -944,7 +944,7 @@ static int smc_ib_add_dev(struct ib_device *ibdev)
if (ibdev->node_type != RDMA_NODE_IB_CA)
return -EOPNOTSUPP;
- smcibdev = kzalloc(sizeof(*smcibdev), GFP_KERNEL);
+ smcibdev = kzalloc_obj(*smcibdev, GFP_KERNEL);
if (!smcibdev)
return -ENOMEM;
diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c
index 7b228ca2f96a..4ee7362e91c5 100644
--- a/net/smc/smc_ism.c
+++ b/net/smc/smc_ism.c
@@ -142,7 +142,7 @@ int smc_ism_get_vlan(struct smcd_dev *smcd, unsigned short vlanid)
return -EOPNOTSUPP;
/* create new vlan entry, in case we need it */
- new_vlan = kzalloc(sizeof(*new_vlan), GFP_KERNEL);
+ new_vlan = kzalloc_obj(*new_vlan, GFP_KERNEL);
if (!new_vlan)
return -ENOMEM;
new_vlan->vlanid = vlanid;
@@ -467,11 +467,10 @@ static struct smcd_dev *smcd_alloc_dev(const char *name, int max_dmbs)
{
struct smcd_dev *smcd;
- smcd = kzalloc(sizeof(*smcd), GFP_KERNEL);
+ smcd = kzalloc_obj(*smcd, GFP_KERNEL);
if (!smcd)
return NULL;
- smcd->conn = kcalloc(max_dmbs, sizeof(struct smc_connection *),
- GFP_KERNEL);
+ smcd->conn = kzalloc_objs(struct smc_connection *, max_dmbs, GFP_KERNEL);
if (!smcd->conn)
goto free_smcd;
@@ -582,7 +581,7 @@ static void smcd_handle_event(struct dibs_dev *dibs,
if (smcd->going_away)
return;
/* copy event to event work queue, and let it be handled there */
- wrk = kmalloc(sizeof(*wrk), GFP_ATOMIC);
+ wrk = kmalloc_obj(*wrk, GFP_ATOMIC);
if (!wrk)
return;
INIT_WORK(&wrk->work, smc_ism_event_work);
diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c
index f5d5eb617526..f82d5fc7f068 100644
--- a/net/smc/smc_llc.c
+++ b/net/smc/smc_llc.c
@@ -1040,7 +1040,7 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)
if (!llc->qp_mtu)
goto out_reject;
- ini = kzalloc(sizeof(*ini), GFP_KERNEL);
+ ini = kzalloc_obj(*ini, GFP_KERNEL);
if (!ini) {
rc = -ENOMEM;
goto out_reject;
@@ -1180,7 +1180,7 @@ static void smc_llc_cli_add_link_invite(struct smc_link *link,
if (lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1)
goto out;
- ini = kzalloc(sizeof(*ini), GFP_KERNEL);
+ ini = kzalloc_obj(*ini, GFP_KERNEL);
if (!ini)
goto out;
@@ -1419,7 +1419,7 @@ int smc_llc_srv_add_link(struct smc_link *link,
req_qentry->msg.raw.hdr.common.llc_type == SMC_LLC_REQ_ADD_LINK)
send_req_add_link_resp = true;
- ini = kzalloc(sizeof(*ini), GFP_KERNEL);
+ ini = kzalloc_obj(*ini, GFP_KERNEL);
if (!ini) {
rc = -ENOMEM;
goto out;
@@ -2069,7 +2069,7 @@ static void smc_llc_enqueue(struct smc_link *link, union smc_llc_msg *llc)
struct smc_llc_qentry *qentry;
unsigned long flags;
- qentry = kmalloc(sizeof(*qentry), GFP_ATOMIC);
+ qentry = kmalloc_obj(*qentry, GFP_ATOMIC);
if (!qentry)
return;
qentry->link = link;
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index a3a1e1fde8eb..239da54ba01c 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -368,7 +368,7 @@ static int smc_pnet_add_eth(struct smc_pnettable *pnettable, struct net *net,
/* add a new netdev entry to the pnet table if there isn't one */
rc = -ENOMEM;
- new_pe = kzalloc(sizeof(*new_pe), GFP_KERNEL);
+ new_pe = kzalloc_obj(*new_pe, GFP_KERNEL);
if (!new_pe)
goto out_put;
new_pe->type = SMC_PNET_ETH;
@@ -445,7 +445,7 @@ static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name,
return -EEXIST;
/* add a new ib entry to the pnet table if there isn't one */
- new_pe = kzalloc(sizeof(*new_pe), GFP_KERNEL);
+ new_pe = kzalloc_obj(*new_pe, GFP_KERNEL);
if (!new_pe)
return -ENOMEM;
new_pe->type = SMC_PNET_IB;
@@ -747,7 +747,7 @@ static int smc_pnet_add_pnetid(struct net *net, u8 *pnetid)
struct smc_net *sn = net_generic(net, smc_net_id);
struct smc_pnetids_ndev_entry *pe, *pi;
- pe = kzalloc(sizeof(*pe), GFP_KERNEL);
+ pe = kzalloc_obj(*pe, GFP_KERNEL);
if (!pe)
return -ENOMEM;
diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
index e7f1134453ef..bde9bc1ed4c0 100644
--- a/net/smc/smc_rx.c
+++ b/net/smc/smc_rx.c
@@ -161,17 +161,17 @@ static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len,
nr_pages = !lgr->is_smcd && smc->conn.rmb_desc->is_vm ?
PAGE_ALIGN(len + offset) / PAGE_SIZE : 1;
- pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
+ pages = kzalloc_objs(*pages, nr_pages, GFP_KERNEL);
if (!pages)
goto out;
- partial = kcalloc(nr_pages, sizeof(*partial), GFP_KERNEL);
+ partial = kzalloc_objs(*partial, nr_pages, GFP_KERNEL);
if (!partial)
goto out_page;
- priv = kcalloc(nr_pages, sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_objs(*priv, nr_pages, GFP_KERNEL);
if (!priv)
goto out_part;
for (i = 0; i < nr_pages; i++) {
- priv[i] = kzalloc(sizeof(**priv), GFP_KERNEL);
+ priv[i] = kzalloc_obj(**priv, GFP_KERNEL);
if (!priv[i])
goto out_priv;
}
diff --git a/net/smc/smc_stats.c b/net/smc/smc_stats.c
index e71b17d1e21c..aeb462dbbb2c 100644
--- a/net/smc/smc_stats.c
+++ b/net/smc/smc_stats.c
@@ -20,7 +20,7 @@
int smc_stats_init(struct net *net)
{
- net->smc.fback_rsn = kzalloc(sizeof(*net->smc.fback_rsn), GFP_KERNEL);
+ net->smc.fback_rsn = kzalloc_obj(*net->smc.fback_rsn, GFP_KERNEL);
if (!net->smc.fback_rsn)
goto err_fback;
net->smc.smc_stats = alloc_percpu(struct smc_stats);
@@ -285,7 +285,7 @@ int smc_nl_get_stats(struct sk_buff *skb,
attrs = nla_nest_start(skb, SMC_GEN_STATS);
if (!attrs)
goto errnest;
- stats = kzalloc(sizeof(*stats), GFP_KERNEL);
+ stats = kzalloc_obj(*stats, GFP_KERNEL);
if (!stats)
goto erralloc;
size = sizeof(*stats) / sizeof(u64);
diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
index 5feafa98ab1a..bad014f353b3 100644
--- a/net/smc/smc_wr.c
+++ b/net/smc/smc_wr.c
@@ -749,27 +749,24 @@ int smc_wr_alloc_link_mem(struct smc_link *link)
GFP_KERNEL);
if (!link->wr_rx_bufs)
goto no_mem_wr_tx_bufs;
- link->wr_tx_ibs = kcalloc(link->max_send_wr,
- sizeof(link->wr_tx_ibs[0]), GFP_KERNEL);
+ link->wr_tx_ibs = kzalloc_objs(link->wr_tx_ibs[0], link->max_send_wr,
+ GFP_KERNEL);
if (!link->wr_tx_ibs)
goto no_mem_wr_rx_bufs;
- link->wr_rx_ibs = kcalloc(link->max_recv_wr,
- sizeof(link->wr_rx_ibs[0]),
- GFP_KERNEL);
+ link->wr_rx_ibs = kzalloc_objs(link->wr_rx_ibs[0], link->max_recv_wr,
+ GFP_KERNEL);
if (!link->wr_rx_ibs)
goto no_mem_wr_tx_ibs;
- link->wr_tx_rdmas = kcalloc(link->max_send_wr,
- sizeof(link->wr_tx_rdmas[0]),
- GFP_KERNEL);
+ link->wr_tx_rdmas = kzalloc_objs(link->wr_tx_rdmas[0],
+ link->max_send_wr, GFP_KERNEL);
if (!link->wr_tx_rdmas)
goto no_mem_wr_rx_ibs;
- link->wr_tx_rdma_sges = kcalloc(link->max_send_wr,
- sizeof(link->wr_tx_rdma_sges[0]),
- GFP_KERNEL);
+ link->wr_tx_rdma_sges = kzalloc_objs(link->wr_tx_rdma_sges[0],
+ link->max_send_wr, GFP_KERNEL);
if (!link->wr_tx_rdma_sges)
goto no_mem_wr_tx_rdmas;
- link->wr_tx_sges = kcalloc(link->max_send_wr, sizeof(link->wr_tx_sges[0]),
- GFP_KERNEL);
+ link->wr_tx_sges = kzalloc_objs(link->wr_tx_sges[0], link->max_send_wr,
+ GFP_KERNEL);
if (!link->wr_tx_sges)
goto no_mem_wr_tx_rdma_sges;
link->wr_rx_sges = kcalloc(link->max_recv_wr,
@@ -780,28 +777,25 @@ int smc_wr_alloc_link_mem(struct smc_link *link)
link->wr_tx_mask = bitmap_zalloc(link->max_send_wr, GFP_KERNEL);
if (!link->wr_tx_mask)
goto no_mem_wr_rx_sges;
- link->wr_tx_pends = kcalloc(link->max_send_wr,
- sizeof(link->wr_tx_pends[0]),
- GFP_KERNEL);
+ link->wr_tx_pends = kzalloc_objs(link->wr_tx_pends[0],
+ link->max_send_wr, GFP_KERNEL);
if (!link->wr_tx_pends)
goto no_mem_wr_tx_mask;
- link->wr_tx_compl = kcalloc(link->max_send_wr,
- sizeof(link->wr_tx_compl[0]),
- GFP_KERNEL);
+ link->wr_tx_compl = kzalloc_objs(link->wr_tx_compl[0],
+ link->max_send_wr, GFP_KERNEL);
if (!link->wr_tx_compl)
goto no_mem_wr_tx_pends;
if (link->lgr->smc_version == SMC_V2) {
- link->wr_tx_v2_ib = kzalloc(sizeof(*link->wr_tx_v2_ib),
- GFP_KERNEL);
+ link->wr_tx_v2_ib = kzalloc_obj(*link->wr_tx_v2_ib, GFP_KERNEL);
if (!link->wr_tx_v2_ib)
goto no_mem_tx_compl;
- link->wr_tx_v2_sge = kzalloc(sizeof(*link->wr_tx_v2_sge),
- GFP_KERNEL);
+ link->wr_tx_v2_sge = kzalloc_obj(*link->wr_tx_v2_sge,
+ GFP_KERNEL);
if (!link->wr_tx_v2_sge)
goto no_mem_v2_ib;
- link->wr_tx_v2_pend = kzalloc(sizeof(*link->wr_tx_v2_pend),
- GFP_KERNEL);
+ link->wr_tx_v2_pend = kzalloc_obj(*link->wr_tx_v2_pend,
+ GFP_KERNEL);
if (!link->wr_tx_v2_pend)
goto no_mem_v2_sge;
}
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 5a827afd8e3b..fb33a4d0cdc7 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -290,12 +290,12 @@ rpcauth_init_credcache(struct rpc_auth *auth)
struct rpc_cred_cache *new;
unsigned int hashsize;
- new = kmalloc(sizeof(*new), GFP_KERNEL);
+ new = kmalloc_obj(*new, GFP_KERNEL);
if (!new)
goto out_nocache;
new->hashbits = auth_hashbits;
hashsize = 1U << new->hashbits;
- new->hashtable = kcalloc(hashsize, sizeof(new->hashtable[0]), GFP_KERNEL);
+ new->hashtable = kzalloc_objs(new->hashtable[0], hashsize, GFP_KERNEL);
if (!new->hashtable)
goto out_nohashtbl;
spin_lock_init(&new->lock);
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index bb3c3db2713b..f8a0d6386635 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -164,7 +164,7 @@ gss_alloc_context(void)
{
struct gss_cl_ctx *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (ctx != NULL) {
ctx->gc_proc = RPC_GSS_PROC_DATA;
ctx->gc_seq = 1; /* NetApp 6.4R1 doesn't accept seq. no. 0 */
@@ -529,7 +529,7 @@ gss_alloc_msg(struct gss_auth *gss_auth,
int vers;
int err = -ENOMEM;
- gss_msg = kzalloc(sizeof(*gss_msg), GFP_KERNEL);
+ gss_msg = kzalloc_obj(*gss_msg, GFP_KERNEL);
if (gss_msg == NULL)
goto err;
vers = get_pipe_version(gss_auth->net);
@@ -914,7 +914,7 @@ static struct gss_pipe *gss_pipe_alloc(struct rpc_clnt *clnt,
struct gss_pipe *p;
int err = -ENOMEM;
- p = kmalloc(sizeof(*p), GFP_KERNEL);
+ p = kmalloc_obj(*p, GFP_KERNEL);
if (p == NULL)
goto err;
p->pipe = rpc_mkpipe_data(upcall_ops, RPC_PIPE_WAIT_FOR_OPEN);
@@ -1029,7 +1029,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
if (!try_module_get(THIS_MODULE))
return ERR_PTR(err);
- if (!(gss_auth = kmalloc(sizeof(*gss_auth), GFP_KERNEL)))
+ if (!(gss_auth = kmalloc_obj(*gss_auth, GFP_KERNEL)))
goto out_dec;
INIT_HLIST_NODE(&gss_auth->hash);
gss_auth->target_name = NULL;
@@ -1246,7 +1246,7 @@ gss_dup_cred(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
struct gss_cred *new;
/* Make a copy of the cred so that we can reference count it */
- new = kzalloc(sizeof(*gss_cred), GFP_KERNEL);
+ new = kzalloc_obj(*gss_cred, GFP_KERNEL);
if (new) {
struct auth_cred acred = {
.cred = gss_cred->gc_base.cr_cred,
@@ -1380,7 +1380,7 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t
struct gss_cred *cred = NULL;
int err = -ENOMEM;
- if (!(cred = kzalloc(sizeof(*cred), gfp)))
+ if (!(cred = kzalloc_obj(*cred, gfp)))
goto out_err;
rpcauth_init_cred(&cred->gc_base, acred, auth, &gss_credops);
@@ -1817,9 +1817,8 @@ alloc_enc_pages(struct rpc_rqst *rqstp)
last = (snd_buf->page_base + snd_buf->page_len - 1) >> PAGE_SHIFT;
rqstp->rq_enc_pages_num = last - first + 1 + 1;
rqstp->rq_enc_pages
- = kmalloc_array(rqstp->rq_enc_pages_num,
- sizeof(struct page *),
- GFP_KERNEL);
+ = kmalloc_objs(struct page *, rqstp->rq_enc_pages_num,
+ GFP_KERNEL);
if (!rqstp->rq_enc_pages)
goto out;
for (i=0; i < rqstp->rq_enc_pages_num; i++) {
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c
index 3366505bc669..6db64a9111a9 100644
--- a/net/sunrpc/auth_gss/gss_krb5_mech.c
+++ b/net/sunrpc/auth_gss/gss_krb5_mech.c
@@ -473,7 +473,7 @@ gss_krb5_import_sec_context(const void *p, size_t len, struct gss_ctx *ctx_id,
struct krb5_ctx *ctx;
int ret;
- ctx = kzalloc(sizeof(*ctx), gfp_mask);
+ ctx = kzalloc_obj(*ctx, gfp_mask);
if (ctx == NULL)
return -ENOMEM;
diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c
index c84d0cf61980..78eab245f94a 100644
--- a/net/sunrpc/auth_gss/gss_mech_switch.c
+++ b/net/sunrpc/auth_gss/gss_mech_switch.c
@@ -355,7 +355,7 @@ gss_import_sec_context(const void *input_token, size_t bufsize,
time64_t *endtime,
gfp_t gfp_mask)
{
- if (!(*ctx_id = kzalloc(sizeof(**ctx_id), gfp_mask)))
+ if (!(*ctx_id = kzalloc_obj(**ctx_id, gfp_mask)))
return -ENOMEM;
(*ctx_id)->mech_type = gss_mech_get(mech);
diff --git a/net/sunrpc/auth_gss/gss_rpc_upcall.c b/net/sunrpc/auth_gss/gss_rpc_upcall.c
index f549e4c05def..e02e6d4a3185 100644
--- a/net/sunrpc/auth_gss/gss_rpc_upcall.c
+++ b/net/sunrpc/auth_gss/gss_rpc_upcall.c
@@ -214,7 +214,7 @@ static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg)
unsigned int i;
arg->npages = DIV_ROUND_UP(NGROUPS_MAX * 4, PAGE_SIZE);
- arg->pages = kcalloc(arg->npages, sizeof(struct page *), GFP_KERNEL);
+ arg->pages = kzalloc_objs(struct page *, arg->npages, GFP_KERNEL);
if (!arg->pages)
return -ENOMEM;
for (i = 0; i < arg->npages; i++) {
diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c
index f320c0a8e604..e1e01965ef58 100644
--- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
+++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
@@ -244,11 +244,11 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,
/* we recognize only 1 currently: CREDS_VALUE */
oa->count = 1;
- oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
+ oa->data = kmalloc_obj(struct gssx_option, GFP_KERNEL);
if (!oa->data)
return -ENOMEM;
- creds = kzalloc(sizeof(struct svc_cred), GFP_KERNEL);
+ creds = kzalloc_obj(struct svc_cred, GFP_KERNEL);
if (!creds) {
err = -ENOMEM;
goto free_oa;
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index e2f0df8cdaa6..411297c9527d 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -197,7 +197,7 @@ static void update_rsi(struct cache_head *cnew, struct cache_head *citem)
static struct cache_head *rsi_alloc(void)
{
- struct rsi *rsii = kmalloc(sizeof(*rsii), GFP_KERNEL);
+ struct rsi *rsii = kmalloc_obj(*rsii, GFP_KERNEL);
if (rsii)
return &rsii->h;
else
@@ -449,7 +449,7 @@ update_rsc(struct cache_head *cnew, struct cache_head *ctmp)
static struct cache_head *
rsc_alloc(void)
{
- struct rsc *rsci = kmalloc(sizeof(*rsci), GFP_KERNEL);
+ struct rsc *rsci = kmalloc_obj(*rsci, GFP_KERNEL);
if (rsci)
return &rsci->h;
else
@@ -814,7 +814,7 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
struct auth_domain *test;
int stat = -ENOMEM;
- new = kmalloc(sizeof(*new), GFP_KERNEL);
+ new = kmalloc_obj(*new, GFP_KERNEL);
if (!new)
goto out;
kref_init(&new->h.ref);
@@ -1069,7 +1069,7 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
goto out_denied_free;
pages = DIV_ROUND_UP(inlen, PAGE_SIZE);
- in_token->pages = kcalloc(pages + 1, sizeof(struct page *), GFP_KERNEL);
+ in_token->pages = kzalloc_objs(struct page *, pages + 1, GFP_KERNEL);
if (!in_token->pages)
goto out_denied_free;
in_token->page_base = 0;
@@ -1631,7 +1631,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp)
rqstp->rq_auth_stat = rpc_autherr_failed;
if (!svcdata)
- svcdata = kmalloc(sizeof(*svcdata), GFP_KERNEL);
+ svcdata = kmalloc_obj(*svcdata, GFP_KERNEL);
if (!svcdata)
goto auth_err;
rqstp->rq_auth_data = svcdata;
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 1e091d3fa607..6c742a3400c4 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -45,7 +45,7 @@ static struct rpc_cred *unx_lookup_cred(struct rpc_auth *auth,
{
struct rpc_cred *ret;
- ret = kmalloc(sizeof(*ret), rpc_task_gfp_mask());
+ ret = kmalloc_obj(*ret, rpc_task_gfp_mask());
if (!ret) {
if (!(flags & RPCAUTH_LOOKUP_ASYNC))
return ERR_PTR(-ENOMEM);
diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
index 6b9dee4119d5..0ffa4d01a938 100644
--- a/net/sunrpc/backchannel_rqst.c
+++ b/net/sunrpc/backchannel_rqst.c
@@ -94,7 +94,7 @@ static struct rpc_rqst *xprt_alloc_bc_req(struct rpc_xprt *xprt)
struct rpc_rqst *req;
/* Pre-allocate one backchannel rpc_rqst */
- req = kzalloc(sizeof(*req), gfp_flags);
+ req = kzalloc_obj(*req, gfp_flags);
if (req == NULL)
return NULL;
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index d808c0b63f30..5129f3dace8c 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1038,7 +1038,7 @@ static int cache_open(struct inode *inode, struct file *filp,
return -EACCES;
nonseekable_open(inode, filp);
if (filp->f_mode & FMODE_READ) {
- rp = kmalloc(sizeof(*rp), GFP_KERNEL);
+ rp = kmalloc_obj(*rp, GFP_KERNEL);
if (!rp) {
module_put(cd->owner);
return -ENOMEM;
@@ -1225,7 +1225,7 @@ static int cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h)
if (!buf)
return -EAGAIN;
- crq = kmalloc(sizeof (*crq), GFP_KERNEL);
+ crq = kmalloc_obj(*crq, GFP_KERNEL);
if (!crq) {
kfree(buf);
return -EAGAIN;
@@ -1745,8 +1745,8 @@ struct cache_detail *cache_create_net(const struct cache_detail *tmpl, struct ne
if (cd == NULL)
return ERR_PTR(-ENOMEM);
- cd->hash_table = kcalloc(cd->hash_size, sizeof(struct hlist_head),
- GFP_KERNEL);
+ cd->hash_table = kzalloc_objs(struct hlist_head, cd->hash_size,
+ GFP_KERNEL);
if (cd->hash_table == NULL) {
kfree(cd);
return ERR_PTR(-ENOMEM);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 58442ae1c2da..f6e086b62053 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -374,7 +374,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args,
goto out_err;
err = -ENOMEM;
- clnt = kzalloc(sizeof(*clnt), GFP_KERNEL);
+ clnt = kzalloc_obj(*clnt, GFP_KERNEL);
if (!clnt)
goto out_err;
clnt->cl_parent = parent ? : clnt;
@@ -2976,7 +2976,7 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt,
return -EINVAL;
}
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
data->xps = xprt_switch_get(xps);
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 379daefc4847..a4b3c51be0f3 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -511,7 +511,7 @@ struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags)
{
struct rpc_pipe *pipe;
- pipe = kzalloc(sizeof(struct rpc_pipe), GFP_KERNEL);
+ pipe = kzalloc_obj(struct rpc_pipe, GFP_KERNEL);
if (!pipe)
return ERR_PTR(-ENOMEM);
init_pipe(pipe);
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index 53bcca365fb1..6aa372188c86 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -737,7 +737,7 @@ void rpcb_getport_async(struct rpc_task *task)
goto bailout_nofree;
}
- map = kzalloc(sizeof(struct rpcbind_args), rpc_task_gfp_mask());
+ map = kzalloc_obj(struct rpcbind_args, rpc_task_gfp_mask());
if (!map) {
status = -ENOMEM;
goto bailout_release_client;
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c
index 383860cb1d5b..36308711e0e9 100644
--- a/net/sunrpc/stats.c
+++ b/net/sunrpc/stats.c
@@ -126,7 +126,7 @@ struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt)
struct rpc_iostats *stats;
int i;
- stats = kcalloc(clnt->cl_maxproc, sizeof(*stats), GFP_KERNEL);
+ stats = kzalloc_objs(*stats, clnt->cl_maxproc, GFP_KERNEL);
if (stats) {
for (i = 0; i < clnt->cl_maxproc; i++)
spin_lock_init(&stats[i].om_lock);
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 346ac560dcc2..bc160368a7dc 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -488,7 +488,7 @@ __svc_create(struct svc_program *prog, int nprogs, struct svc_stat *stats,
unsigned int xdrsize;
unsigned int i;
- if (!(serv = kzalloc(sizeof(*serv), GFP_KERNEL)))
+ if (!(serv = kzalloc_obj(*serv, GFP_KERNEL)))
return NULL;
serv->sv_name = prog->pg_name;
serv->sv_programs = prog;
@@ -523,8 +523,7 @@ __svc_create(struct svc_program *prog, int nprogs, struct svc_stat *stats,
serv->sv_nrpools = npools;
serv->sv_pools =
- kcalloc(serv->sv_nrpools, sizeof(struct svc_pool),
- GFP_KERNEL);
+ kzalloc_objs(struct svc_pool, serv->sv_nrpools, GFP_KERNEL);
if (!serv->sv_pools) {
kfree(serv);
return NULL;
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 8ca98b146ec8..7f952d9201f5 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -72,7 +72,7 @@ struct auth_domain *unix_domain_find(char *name)
return rv;
}
- new = kmalloc(sizeof(*new), GFP_KERNEL);
+ new = kmalloc_obj(*new, GFP_KERNEL);
if (new == NULL)
return NULL;
kref_init(&new->h.ref);
@@ -143,7 +143,7 @@ static void update(struct cache_head *cnew, struct cache_head *citem)
}
static struct cache_head *ip_map_alloc(void)
{
- struct ip_map *i = kmalloc(sizeof(*i), GFP_KERNEL);
+ struct ip_map *i = kmalloc_obj(*i, GFP_KERNEL);
if (i)
return &i->h;
else
@@ -458,7 +458,7 @@ static void unix_gid_update(struct cache_head *cnew, struct cache_head *citem)
}
static struct cache_head *unix_gid_alloc(void)
{
- struct unix_gid *g = kmalloc(sizeof(*g), GFP_KERNEL);
+ struct unix_gid *g = kmalloc_obj(*g, GFP_KERNEL);
if (g)
return &g->h;
else
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index d61cd9b40491..e1576c807e07 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1436,12 +1436,13 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
return ERR_PTR(sendpages);
pages = svc_serv_maxpages(serv);
- svsk = kzalloc(struct_size(svsk, sk_pages, pages), GFP_KERNEL);
+ svsk = kzalloc_flex(*svsk, sk_pages, pages, GFP_KERNEL);
if (!svsk)
return ERR_PTR(-ENOMEM);
if (sendpages) {
- svsk->sk_bvec = kcalloc(sendpages, sizeof(*svsk->sk_bvec), GFP_KERNEL);
+ svsk->sk_bvec = kzalloc_objs(*svsk->sk_bvec, sendpages,
+ GFP_KERNEL);
if (!svsk->sk_bvec) {
kfree(svsk);
return ERR_PTR(-ENOMEM);
diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c
index 8b01b7ae2690..ec6ddfa11f86 100644
--- a/net/sunrpc/sysfs.c
+++ b/net/sunrpc/sysfs.c
@@ -48,7 +48,7 @@ static struct kobject *rpc_sysfs_object_alloc(const char *name,
{
struct kobject *kobj;
- kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
+ kobj = kzalloc_obj(*kobj, GFP_KERNEL);
if (kobj) {
kobj->kset = kset;
if (kobject_init_and_add(kobj, &rpc_sysfs_object_type,
@@ -397,7 +397,7 @@ static ssize_t rpc_sysfs_xprt_dstaddr_store(struct kobject *kobj,
dst_addr = kstrndup(buf, buf_len, GFP_KERNEL);
if (!dst_addr)
goto out_err;
- saved_addr = kzalloc(sizeof(*saved_addr), GFP_KERNEL);
+ saved_addr = kzalloc_obj(*saved_addr, GFP_KERNEL);
if (!saved_addr)
goto out_err_free;
saved_addr->addr =
@@ -663,7 +663,7 @@ static struct rpc_sysfs_client *rpc_sysfs_client_alloc(struct kobject *parent,
{
struct rpc_sysfs_client *p;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (p) {
p->net = net;
p->kobject.kset = rpc_sunrpc_kset;
@@ -683,7 +683,7 @@ rpc_sysfs_xprt_switch_alloc(struct kobject *parent,
{
struct rpc_sysfs_xprt_switch *p;
- p = kzalloc(sizeof(*p), gfp_flags);
+ p = kzalloc_obj(*p, gfp_flags);
if (p) {
p->net = net;
p->kobject.kset = rpc_sunrpc_kset;
@@ -703,7 +703,7 @@ static struct rpc_sysfs_xprt *rpc_sysfs_xprt_alloc(struct kobject *parent,
{
struct rpc_sysfs_xprt *p;
- p = kzalloc(sizeof(*p), gfp_flags);
+ p = kzalloc_obj(*p, gfp_flags);
if (!p)
goto out;
p->kobject.kset = rpc_sunrpc_kset;
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 70efc727a9cd..e83d5d0be78b 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -118,7 +118,7 @@ xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp)
size_t i, n = xdr_buf_pagecount(buf);
if (n != 0 && buf->bvec == NULL) {
- buf->bvec = kmalloc_array(n, sizeof(buf->bvec[0]), gfp);
+ buf->bvec = kmalloc_objs(buf->bvec[0], n, gfp);
if (!buf->bvec)
return -ENOMEM;
for (i = 0; i < n; i++) {
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 1023361845f9..16f6989a0a2d 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1709,7 +1709,7 @@ static struct rpc_rqst *xprt_dynamic_alloc_slot(struct rpc_xprt *xprt)
goto out;
++xprt->num_reqs;
spin_unlock(&xprt->reserve_lock);
- req = kzalloc(sizeof(*req), rpc_task_gfp_mask());
+ req = kzalloc_obj(*req, rpc_task_gfp_mask());
spin_lock(&xprt->reserve_lock);
if (req != NULL)
goto out;
@@ -1829,7 +1829,7 @@ struct rpc_xprt *xprt_alloc(struct net *net, size_t size,
xprt_init(xprt, net);
for (i = 0; i < num_prealloc; i++) {
- req = kzalloc(sizeof(struct rpc_rqst), GFP_KERNEL);
+ req = kzalloc_obj(struct rpc_rqst, GFP_KERNEL);
if (!req)
goto out_free;
list_add(&req->rq_list, &xprt->free);
diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c
index 4c5e08b0aa64..3ba818d637be 100644
--- a/net/sunrpc/xprtmultipath.c
+++ b/net/sunrpc/xprtmultipath.c
@@ -150,7 +150,7 @@ struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt,
{
struct rpc_xprt_switch *xps;
- xps = kmalloc(sizeof(*xps), gfp_flags);
+ xps = kmalloc_obj(*xps, gfp_flags);
if (xps != NULL) {
spin_lock_init(&xps->xps_lock);
kref_init(&xps->xps_kref);
diff --git a/net/sunrpc/xprtrdma/ib_client.c b/net/sunrpc/xprtrdma/ib_client.c
index 28c68b5f6823..e5b6dfaf01aa 100644
--- a/net/sunrpc/xprtrdma/ib_client.c
+++ b/net/sunrpc/xprtrdma/ib_client.c
@@ -108,7 +108,7 @@ static int rpcrdma_add_one(struct ib_device *device)
{
struct rpcrdma_device *rd;
- rd = kzalloc(sizeof(*rd), GFP_KERNEL);
+ rd = kzalloc_obj(*rd, GFP_KERNEL);
if (!rd)
return -ENOMEM;
diff --git a/net/sunrpc/xprtrdma/svc_rdma_pcl.c b/net/sunrpc/xprtrdma/svc_rdma_pcl.c
index b63cfeaa2923..b7c09a1f1c62 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_pcl.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_pcl.c
@@ -29,7 +29,7 @@ static struct svc_rdma_chunk *pcl_alloc_chunk(u32 segcount, u32 position)
{
struct svc_rdma_chunk *chunk;
- chunk = kmalloc(struct_size(chunk, ch_segments, segcount), GFP_KERNEL);
+ chunk = kmalloc_flex(*chunk, ch_segments, segcount, GFP_KERNEL);
if (!chunk)
return NULL;
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 63262ef0c2e3..15bbf953dfad 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -383,7 +383,7 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
struct rpcrdma_ep *ep;
int rc;
- ep = kzalloc(sizeof(*ep), XPRTRDMA_GFP_FLAGS);
+ ep = kzalloc_obj(*ep, XPRTRDMA_GFP_FLAGS);
if (!ep)
return -ENOTCONN;
ep->re_xprt = &r_xprt->rx_xprt;
@@ -615,8 +615,8 @@ static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ep *ep)
{
struct rpcrdma_sendctx *sc;
- sc = kzalloc(struct_size(sc, sc_sges, ep->re_attr.cap.max_send_sge),
- XPRTRDMA_GFP_FLAGS);
+ sc = kzalloc_flex(*sc, sc_sges, ep->re_attr.cap.max_send_sge,
+ XPRTRDMA_GFP_FLAGS);
if (!sc)
return NULL;
@@ -639,7 +639,7 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
* Sends are posted.
*/
i = r_xprt->rx_ep->re_max_requests + RPCRDMA_MAX_BC_REQUESTS;
- buf->rb_sc_ctxs = kcalloc(i, sizeof(sc), XPRTRDMA_GFP_FLAGS);
+ buf->rb_sc_ctxs = kzalloc_objs(sc, i, XPRTRDMA_GFP_FLAGS);
if (!buf->rb_sc_ctxs)
return -ENOMEM;
@@ -822,7 +822,7 @@ struct rpcrdma_req *rpcrdma_req_create(struct rpcrdma_xprt *r_xprt,
struct rpcrdma_buffer *buffer = &r_xprt->rx_buf;
struct rpcrdma_req *req;
- req = kzalloc(sizeof(*req), XPRTRDMA_GFP_FLAGS);
+ req = kzalloc_obj(*req, XPRTRDMA_GFP_FLAGS);
if (req == NULL)
goto out1;
@@ -952,7 +952,7 @@ struct rpcrdma_rep *rpcrdma_rep_create(struct rpcrdma_xprt *r_xprt)
struct ib_device *device = ep->re_id->device;
struct rpcrdma_rep *rep;
- rep = kzalloc(sizeof(*rep), XPRTRDMA_GFP_FLAGS);
+ rep = kzalloc_obj(*rep, XPRTRDMA_GFP_FLAGS);
if (rep == NULL)
goto out;
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 4d5fbacef496..b55df183e6d5 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -114,7 +114,7 @@ static int switchdev_deferred_enqueue(struct net_device *dev,
{
struct switchdev_deferred_item *dfitem;
- dfitem = kmalloc(struct_size(dfitem, data, data_len), GFP_ATOMIC);
+ dfitem = kmalloc_flex(*dfitem, data, data_len, GFP_ATOMIC);
if (!dfitem)
return -ENOMEM;
dfitem->dev = dev;
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 114fef65f92e..c7c7f08eee9a 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -692,7 +692,7 @@ int tipc_bcast_init(struct net *net)
struct tipc_bc_base *bb = NULL;
struct tipc_link *l = NULL;
- bb = kzalloc(sizeof(*bb), GFP_KERNEL);
+ bb = kzalloc_obj(*bb, GFP_KERNEL);
if (!bb)
goto enomem;
tn->bcbase = bb;
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index ae1ddbf71853..a3bd1ef17558 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -322,7 +322,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
goto rejected;
}
- b = kzalloc(sizeof(*b), GFP_ATOMIC);
+ b = kzalloc_obj(*b, GFP_ATOMIC);
if (!b)
return -ENOMEM;
diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
index a3f9ca28c3d5..abd191a3ac4a 100644
--- a/net/tipc/crypto.c
+++ b/net/tipc/crypto.c
@@ -524,7 +524,7 @@ static int tipc_aead_init(struct tipc_aead **aead, struct tipc_aead_key *ukey,
return -EEXIST;
/* Allocate a new AEAD */
- tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);
+ tmp = kzalloc_obj(*tmp, GFP_ATOMIC);
if (unlikely(!tmp))
return -ENOMEM;
@@ -560,7 +560,7 @@ static int tipc_aead_init(struct tipc_aead **aead, struct tipc_aead_key *ukey,
break;
}
- tfm_entry = kmalloc(sizeof(*tfm_entry), GFP_KERNEL);
+ tfm_entry = kmalloc_obj(*tfm_entry, GFP_KERNEL);
if (unlikely(!tfm_entry)) {
crypto_free_aead(tfm);
err = -ENOMEM;
@@ -637,7 +637,7 @@ static int tipc_aead_clone(struct tipc_aead **dst, struct tipc_aead *src)
if (unlikely(*dst))
return -EEXIST;
- aead = kzalloc(sizeof(*aead), GFP_ATOMIC);
+ aead = kzalloc_obj(*aead, GFP_ATOMIC);
if (unlikely(!aead))
return -ENOMEM;
@@ -1472,7 +1472,7 @@ int tipc_crypto_start(struct tipc_crypto **crypto, struct net *net,
return -EEXIST;
/* Allocate crypto */
- c = kzalloc(sizeof(*c), GFP_ATOMIC);
+ c = kzalloc_obj(*c, GFP_ATOMIC);
if (!c)
return -ENOMEM;
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 775fd4f3f072..3e54d2df5683 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -353,7 +353,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b,
struct tipc_net *tn = tipc_net(net);
struct tipc_discoverer *d;
- d = kmalloc(sizeof(*d), GFP_ATOMIC);
+ d = kmalloc_obj(*d, GFP_ATOMIC);
if (!d)
return -ENOMEM;
d->skb = tipc_buf_acquire(MAX_H_SIZE + NODE_ID_LEN, GFP_ATOMIC);
diff --git a/net/tipc/group.c b/net/tipc/group.c
index 3e137d8c9d2f..e0e6227b433b 100644
--- a/net/tipc/group.c
+++ b/net/tipc/group.c
@@ -169,7 +169,7 @@ struct tipc_group *tipc_group_create(struct net *net, u32 portid,
struct tipc_group *grp;
u32 type = mreq->type;
- grp = kzalloc(sizeof(*grp), GFP_ATOMIC);
+ grp = kzalloc_obj(*grp, GFP_ATOMIC);
if (!grp)
return NULL;
tipc_nlist_init(&grp->dests, tipc_own_addr(net));
@@ -306,7 +306,7 @@ static struct tipc_member *tipc_group_create_member(struct tipc_group *grp,
struct tipc_member *m;
int ret;
- m = kzalloc(sizeof(*m), GFP_ATOMIC);
+ m = kzalloc_obj(*m, GFP_ATOMIC);
if (!m)
return NULL;
INIT_LIST_HEAD(&m->list);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 931f55f781a1..49dfc098d89b 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -487,7 +487,7 @@ bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
char self_str[NODE_ID_STR_LEN] = {0,};
struct tipc_link *l;
- l = kzalloc(sizeof(*l), GFP_ATOMIC);
+ l = kzalloc_obj(*l, GFP_ATOMIC);
if (!l)
return false;
*link = l;
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 572b79bf76ce..a94b9b36a700 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -393,7 +393,7 @@ static bool tipc_mon_add_peer(struct tipc_monitor *mon, u32 addr,
struct tipc_peer *self = mon->self;
struct tipc_peer *cur, *prev, *p;
- p = kzalloc(sizeof(*p), GFP_ATOMIC);
+ p = kzalloc_obj(*p, GFP_ATOMIC);
*peer = p;
if (!p)
return false;
@@ -654,9 +654,9 @@ int tipc_mon_create(struct net *net, int bearer_id)
if (tn->monitors[bearer_id])
return 0;
- mon = kzalloc(sizeof(*mon), GFP_ATOMIC);
- self = kzalloc(sizeof(*self), GFP_ATOMIC);
- dom = kzalloc(sizeof(*dom), GFP_ATOMIC);
+ mon = kzalloc_obj(*mon, GFP_ATOMIC);
+ self = kzalloc_obj(*self, GFP_ATOMIC);
+ dom = kzalloc_obj(*dom, GFP_ATOMIC);
if (!mon || !self || !dom) {
kfree(mon);
kfree(self);
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index e74940eab3a4..ec0ac85ca70b 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -230,7 +230,7 @@ static struct publication *tipc_publ_create(struct tipc_uaddr *ua,
struct tipc_socket_addr *sk,
u32 key)
{
- struct publication *p = kzalloc(sizeof(*p), GFP_ATOMIC);
+ struct publication *p = kzalloc_obj(*p, GFP_ATOMIC);
if (!p)
return NULL;
@@ -261,7 +261,7 @@ static struct tipc_service *tipc_service_create(struct net *net,
struct tipc_service *service;
struct hlist_head *hd;
- service = kzalloc(sizeof(*service), GFP_ATOMIC);
+ service = kzalloc_obj(*service, GFP_ATOMIC);
if (!service) {
pr_warn("Service creation failed, no memory\n");
return NULL;
@@ -314,7 +314,7 @@ static struct service_range *tipc_service_create_range(struct tipc_service *sc,
else
n = &parent->rb_right;
}
- sr = kzalloc(sizeof(*sr), GFP_ATOMIC);
+ sr = kzalloc_obj(*sr, GFP_ATOMIC);
if (!sr)
return NULL;
sr->lower = lower;
@@ -888,7 +888,7 @@ int tipc_nametbl_init(struct net *net)
struct name_table *nt;
int i;
- nt = kzalloc(sizeof(*nt), GFP_KERNEL);
+ nt = kzalloc_obj(*nt, GFP_KERNEL);
if (!nt)
return -ENOMEM;
@@ -1156,7 +1156,7 @@ bool tipc_dest_push(struct list_head *l, u32 node, u32 port)
if (tipc_dest_find(l, node, port))
return false;
- dst = kmalloc(sizeof(*dst), GFP_ATOMIC);
+ dst = kmalloc_obj(*dst, GFP_ATOMIC);
if (unlikely(!dst))
return false;
dst->node = node;
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 079aebb16ed8..f64f03ab4933 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -202,8 +202,8 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
return -ENOMEM;
}
- attrbuf = kcalloc(tipc_genl_family.maxattr + 1,
- sizeof(struct nlattr *), GFP_KERNEL);
+ attrbuf = kzalloc_objs(struct nlattr *, tipc_genl_family.maxattr + 1,
+ GFP_KERNEL);
if (!attrbuf) {
err = -ENOMEM;
goto err_out;
@@ -338,9 +338,8 @@ static int __tipc_nl_compat_doit(struct tipc_nl_compat_cmd_doit *cmd,
if (!trans_buf)
return -ENOMEM;
- attrbuf = kmalloc_array(tipc_genl_family.maxattr + 1,
- sizeof(struct nlattr *),
- GFP_KERNEL);
+ attrbuf = kmalloc_objs(struct nlattr *, tipc_genl_family.maxattr + 1,
+ GFP_KERNEL);
if (!attrbuf) {
err = -ENOMEM;
goto trans_out;
diff --git a/net/tipc/node.c b/net/tipc/node.c
index a07fb073368c..af442a5ef8f3 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -535,7 +535,7 @@ update:
goto exit;
}
- n = kzalloc(sizeof(*n), GFP_ATOMIC);
+ n = kzalloc_obj(*n, GFP_ATOMIC);
if (!n) {
pr_warn("Node creation failed, no memory\n");
goto exit;
@@ -703,7 +703,7 @@ int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port)
pr_warn("Connecting sock to node 0x%x failed\n", dnode);
return -EHOSTUNREACH;
}
- conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
+ conn = kmalloc_obj(*conn, GFP_ATOMIC);
if (!conn) {
err = -EHOSTUNREACH;
goto exit;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 817b07d95a91..d52f700b5493 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -3595,7 +3595,7 @@ int __tipc_dump_start(struct netlink_callback *cb, struct net *net)
struct tipc_net *tn = tipc_net(net);
if (!iter) {
- iter = kmalloc(sizeof(*iter), GFP_KERNEL);
+ iter = kmalloc_obj(*iter, GFP_KERNEL);
if (!iter)
return -ENOMEM;
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index f8490d94e323..352d304c3acd 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -143,7 +143,7 @@ struct tipc_subscription *tipc_sub_subscribe(struct net *net,
pr_warn("Subscription rejected, illegal request\n");
return NULL;
}
- sub = kmalloc(sizeof(*sub), GFP_ATOMIC);
+ sub = kmalloc_obj(*sub, GFP_ATOMIC);
if (!sub) {
pr_warn("Subscription rejected, no memory\n");
return NULL;
diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c
index aad7f96b6009..af530c9ed840 100644
--- a/net/tipc/topsrv.c
+++ b/net/tipc/topsrv.c
@@ -182,7 +182,7 @@ static struct tipc_conn *tipc_conn_alloc(struct tipc_topsrv *s, struct socket *s
struct tipc_conn *con;
int ret;
- con = kzalloc(sizeof(*con), GFP_ATOMIC);
+ con = kzalloc_obj(*con, GFP_ATOMIC);
if (!con)
return ERR_PTR(-ENOMEM);
@@ -325,7 +325,7 @@ void tipc_topsrv_queue_evt(struct net *net, int conid,
if (!connected(con))
goto err;
- e = kmalloc(sizeof(*e), GFP_ATOMIC);
+ e = kmalloc_obj(*e, GFP_ATOMIC);
if (!e)
goto err;
e->inactive = (event == TIPC_SUBSCR_TIMEOUT);
@@ -661,7 +661,7 @@ static int tipc_topsrv_start(struct net *net)
struct tipc_topsrv *srv;
int ret;
- srv = kzalloc(sizeof(*srv), GFP_ATOMIC);
+ srv = kzalloc_obj(*srv, GFP_ATOMIC);
if (!srv)
return -ENOMEM;
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index b85ab0fb3b8c..2b8e385d1e51 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -309,7 +309,7 @@ static int tipc_udp_rcast_add(struct tipc_bearer *b,
if (!ub)
return -ENODEV;
- rcast = kmalloc(sizeof(*rcast), GFP_ATOMIC);
+ rcast = kmalloc_obj(*rcast, GFP_ATOMIC);
if (!rcast)
return -ENOMEM;
@@ -675,7 +675,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
struct net_device *dev;
int rmcast = 0;
- ub = kzalloc(sizeof(*ub), GFP_ATOMIC);
+ ub = kzalloc_obj(*ub, GFP_ATOMIC);
if (!ub)
return -ENOMEM;
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 82ea407e520a..7a85ef064e4c 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -346,7 +346,7 @@ static int tls_create_new_record(struct tls_offload_context_tx *offload_ctx,
struct tls_record_info *record;
skb_frag_t *frag;
- record = kmalloc(sizeof(*record), GFP_KERNEL);
+ record = kmalloc_obj(*record, GFP_KERNEL);
if (!record)
return -ENOMEM;
@@ -1040,7 +1040,7 @@ static struct tls_offload_context_tx *alloc_offload_ctx_tx(struct tls_context *c
struct tls_offload_context_tx *offload_ctx;
__be64 rcd_sn;
- offload_ctx = kzalloc(sizeof(*offload_ctx), GFP_KERNEL);
+ offload_ctx = kzalloc_obj(*offload_ctx, GFP_KERNEL);
if (!offload_ctx)
return NULL;
@@ -1110,7 +1110,7 @@ int tls_set_device_offload(struct sock *sk)
memcpy(ctx->tx.iv + cipher_desc->salt, iv, cipher_desc->iv);
memcpy(ctx->tx.rec_seq, rec_seq, cipher_desc->rec_seq);
- start_marker_record = kmalloc(sizeof(*start_marker_record), GFP_KERNEL);
+ start_marker_record = kmalloc_obj(*start_marker_record, GFP_KERNEL);
if (!start_marker_record) {
rc = -ENOMEM;
goto release_netdev;
@@ -1224,7 +1224,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
goto release_lock;
}
- context = kzalloc(sizeof(*context), GFP_KERNEL);
+ context = kzalloc_obj(*context, GFP_KERNEL);
if (!context) {
rc = -ENOMEM;
goto release_lock;
diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c
index 03d508a45aae..d3c72f509baa 100644
--- a/net/tls/tls_device_fallback.c
+++ b/net/tls/tls_device_fallback.c
@@ -383,7 +383,7 @@ static struct sk_buff *tls_sw_fallback(struct sock *sk, struct sk_buff *skb)
if (!payload_len)
return skb;
- sg_in = kmalloc_array(sg_in_max_elements, sizeof(*sg_in), GFP_ATOMIC);
+ sg_in = kmalloc_objs(*sg_in, sg_in_max_elements, GFP_ATOMIC);
if (!sg_in)
goto free_orig;
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 56ce0bc8317b..fd39acf41a61 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -915,7 +915,7 @@ struct tls_context *tls_ctx_create(struct sock *sk)
struct inet_connection_sock *icsk = inet_csk(sk);
struct tls_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
+ ctx = kzalloc_obj(*ctx, GFP_ATOMIC);
if (!ctx)
return NULL;
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 9937d4c810f2..36bacedd6177 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -2698,7 +2698,7 @@ static struct tls_sw_context_tx *init_ctx_tx(struct tls_context *ctx, struct soc
struct tls_sw_context_tx *sw_ctx_tx;
if (!ctx->priv_ctx_tx) {
- sw_ctx_tx = kzalloc(sizeof(*sw_ctx_tx), GFP_KERNEL);
+ sw_ctx_tx = kzalloc_obj(*sw_ctx_tx, GFP_KERNEL);
if (!sw_ctx_tx)
return NULL;
} else {
@@ -2719,7 +2719,7 @@ static struct tls_sw_context_rx *init_ctx_rx(struct tls_context *ctx)
struct tls_sw_context_rx *sw_ctx_rx;
if (!ctx->priv_ctx_rx) {
- sw_ctx_rx = kzalloc(sizeof(*sw_ctx_rx), GFP_KERNEL);
+ sw_ctx_rx = kzalloc_obj(*sw_ctx_rx, GFP_KERNEL);
if (!sw_ctx_rx)
return NULL;
} else {
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index f6d56e70c7a2..1c4d298a9eb3 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -3798,14 +3798,13 @@ static int __net_init unix_net_init(struct net *net)
goto err_sysctl;
#endif
- net->unx.table.locks = kvmalloc_array(UNIX_HASH_SIZE,
- sizeof(spinlock_t), GFP_KERNEL);
+ net->unx.table.locks = kvmalloc_objs(spinlock_t, UNIX_HASH_SIZE,
+ GFP_KERNEL);
if (!net->unx.table.locks)
goto err_proc;
- net->unx.table.buckets = kvmalloc_array(UNIX_HASH_SIZE,
- sizeof(struct hlist_head),
- GFP_KERNEL);
+ net->unx.table.buckets = kvmalloc_objs(struct hlist_head,
+ UNIX_HASH_SIZE, GFP_KERNEL);
if (!net->unx.table.buckets)
goto free_locks;
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 25f65817faab..a15e7eb50851 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -288,15 +288,15 @@ int unix_prepare_fpl(struct scm_fp_list *fpl)
return 0;
for (i = 0; i < fpl->count_unix; i++) {
- vertex = kmalloc(sizeof(*vertex), GFP_KERNEL);
+ vertex = kmalloc_obj(*vertex, GFP_KERNEL);
if (!vertex)
goto err;
list_add(&vertex->entry, &fpl->vertices);
}
- fpl->edges = kvmalloc_array(fpl->count_unix, sizeof(*fpl->edges),
- GFP_KERNEL_ACCOUNT);
+ fpl->edges = kvmalloc_objs(*fpl->edges, fpl->count_unix,
+ GFP_KERNEL_ACCOUNT);
if (!fpl->edges)
goto err;
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index c3010c874308..b1bf64b5cc97 100644
--- a/net/vmw_vsock/hyperv_transport.c
+++ b/net/vmw_vsock/hyperv_transport.c
@@ -444,7 +444,7 @@ static int hvs_sock_init(struct vsock_sock *vsk, struct vsock_sock *psk)
struct hvsock *hvs;
struct sock *sk = sk_vsock(vsk);
- hvs = kzalloc(sizeof(*hvs), GFP_KERNEL);
+ hvs = kzalloc_obj(*hvs, GFP_KERNEL);
if (!hvs)
return -ENOMEM;
@@ -655,7 +655,7 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg,
BUILD_BUG_ON(sizeof(*send_buf) != HV_HYP_PAGE_SIZE);
- send_buf = kmalloc(sizeof(*send_buf), GFP_KERNEL);
+ send_buf = kmalloc_obj(*send_buf, GFP_KERNEL);
if (!send_buf)
return -ENOMEM;
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 357e80ac3f3a..d6c07334bf94 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -805,7 +805,7 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
goto out;
}
- vsock = kzalloc(sizeof(*vsock), GFP_KERNEL);
+ vsock = kzalloc_obj(*vsock, GFP_KERNEL);
if (!vsock) {
ret = -ENOMEM;
goto out;
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index d017ab318a7e..925ed086058c 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -920,7 +920,7 @@ int virtio_transport_do_socket_init(struct vsock_sock *vsk,
{
struct virtio_vsock_sock *vvs;
- vvs = kzalloc(sizeof(*vvs), GFP_KERNEL);
+ vvs = kzalloc_obj(*vvs, GFP_KERNEL);
if (!vvs)
return -ENOMEM;
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index a64522be1bad..3e80639b7c08 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -262,7 +262,7 @@ vmci_transport_alloc_send_control_pkt(struct sockaddr_vm *src,
struct vmci_transport_packet *pkt;
int err;
- pkt = kmalloc(sizeof(*pkt), GFP_KERNEL);
+ pkt = kmalloc_obj(*pkt, GFP_KERNEL);
if (!pkt)
return -ENOMEM;
@@ -779,7 +779,7 @@ static int vmci_transport_recv_stream_cb(void *data, struct vmci_datagram *dg)
if (!bh_process_pkt) {
struct vmci_transport_recv_pkt_info *recv_pkt_info;
- recv_pkt_info = kmalloc(sizeof(*recv_pkt_info), GFP_ATOMIC);
+ recv_pkt_info = kmalloc_obj(*recv_pkt_info, GFP_ATOMIC);
if (!recv_pkt_info) {
if (vmci_transport_send_reset_bh(&dst, &src, pkt) < 0)
pr_err("unable to send reset\n");
@@ -1583,7 +1583,7 @@ static int vmci_transport_recv_connected(struct sock *sk,
static int vmci_transport_socket_init(struct vsock_sock *vsk,
struct vsock_sock *psk)
{
- vsk->trans = kmalloc(sizeof(struct vmci_transport), GFP_KERNEL);
+ vsk->trans = kmalloc_obj(struct vmci_transport, GFP_KERNEL);
if (!vsk->trans)
return -ENOMEM;
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 9af85d655027..bd53317e44ef 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -1000,9 +1000,8 @@ int wiphy_register(struct wiphy *wiphy)
if (wiphy->n_radio > 0) {
int idx;
- wiphy->radio_cfg = kcalloc(wiphy->n_radio,
- sizeof(*wiphy->radio_cfg),
- GFP_KERNEL);
+ wiphy->radio_cfg = kzalloc_objs(*wiphy->radio_cfg,
+ wiphy->n_radio, GFP_KERNEL);
if (!wiphy->radio_cfg)
return -ENOMEM;
/*
@@ -1446,7 +1445,7 @@ void cfg80211_stop_link(struct wiphy *wiphy, struct wireless_dev *wdev,
trace_cfg80211_stop_link(wiphy, wdev, link_id);
- ev = kzalloc(sizeof(*ev), gfp);
+ ev = kzalloc_obj(*ev, gfp);
if (!ev)
return;
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index 1e3ed29f7cfc..a7024af39b40 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -69,7 +69,7 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
if (WARN_ON(!channel))
return;
- ev = kzalloc(sizeof(*ev), gfp);
+ ev = kzalloc_obj(*ev, gfp);
if (!ev)
return;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6e58b238a1f8..33782370fbaf 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1106,8 +1106,8 @@ static int nl80211_prepare_wdev_dump(struct netlink_callback *cb,
struct nlattr **attrbuf_free = NULL;
if (!attrbuf) {
- attrbuf = kcalloc(NUM_NL80211_ATTR, sizeof(*attrbuf),
- GFP_KERNEL);
+ attrbuf = kzalloc_objs(*attrbuf, NUM_NL80211_ATTR,
+ GFP_KERNEL);
if (!attrbuf)
return -ENOMEM;
attrbuf_free = attrbuf;
@@ -1615,7 +1615,7 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
if (!have_key)
return NULL;
- result = kzalloc(sizeof(*result), GFP_KERNEL);
+ result = kzalloc_obj(*result, GFP_KERNEL);
if (!result)
return ERR_PTR(-ENOMEM);
@@ -3367,7 +3367,7 @@ static int nl80211_dump_wiphy_parse(struct sk_buff *skb,
struct netlink_callback *cb,
struct nl80211_dump_wiphy_state *state)
{
- struct nlattr **tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL);
+ struct nlattr **tb = kzalloc_objs(*tb, NUM_NL80211_ATTR, GFP_KERNEL);
int ret;
if (!tb)
@@ -3419,7 +3419,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
rtnl_lock();
if (!state) {
- state = kzalloc(sizeof(*state), GFP_KERNEL);
+ state = kzalloc_obj(*state, GFP_KERNEL);
if (!state) {
rtnl_unlock();
return -ENOMEM;
@@ -5333,7 +5333,7 @@ static struct cfg80211_acl_data *parse_acl_data(struct wiphy *wiphy,
if (n_entries > wiphy->max_acl_mac_addrs)
return ERR_PTR(-EOPNOTSUPP);
- acl = kzalloc(struct_size(acl, mac_addrs, n_entries), GFP_KERNEL);
+ acl = kzalloc_flex(*acl, mac_addrs, n_entries, GFP_KERNEL);
if (!acl)
return ERR_PTR(-ENOMEM);
acl->n_acl_entries = n_entries;
@@ -6113,7 +6113,7 @@ nl80211_parse_mbssid_elems(struct wiphy *wiphy, struct nlattr *attrs)
num_elems++;
}
- elems = kzalloc(struct_size(elems, elem, num_elems), GFP_KERNEL);
+ elems = kzalloc_flex(*elems, elem, num_elems, GFP_KERNEL);
if (!elems)
return ERR_PTR(-ENOMEM);
elems->cnt = num_elems;
@@ -6145,7 +6145,7 @@ nl80211_parse_rnr_elems(struct wiphy *wiphy, struct nlattr *attrs,
num_elems++;
}
- elems = kzalloc(struct_size(elems, elem, num_elems), GFP_KERNEL);
+ elems = kzalloc_flex(*elems, elem, num_elems, GFP_KERNEL);
if (!elems)
return ERR_PTR(-ENOMEM);
elems->cnt = num_elems;
@@ -6702,7 +6702,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
nla_get_u8(info->attrs[NL80211_ATTR_SMPS_MODE]) != NL80211_SMPS_OFF)
return -EOPNOTSUPP;
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ params = kzalloc_obj(*params, GFP_KERNEL);
if (!params)
return -ENOMEM;
@@ -6995,7 +6995,7 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info)
if (!wdev->links[link_id].ap.beacon_interval)
return -EINVAL;
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ params = kzalloc_obj(*params, GFP_KERNEL);
if (!params)
return -ENOMEM;
@@ -7985,7 +7985,7 @@ static int nl80211_dump_station(struct sk_buff *skb,
for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
sinfo.links[i] =
- kzalloc(sizeof(*sinfo.links[0]), GFP_KERNEL);
+ kzalloc_obj(*sinfo.links[0], GFP_KERNEL);
if (!sinfo.links[i]) {
err = -ENOMEM;
goto out_err;
@@ -8049,7 +8049,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
return -EOPNOTSUPP;
for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
- sinfo.links[i] = kzalloc(sizeof(*sinfo.links[0]), GFP_KERNEL);
+ sinfo.links[i] = kzalloc_obj(*sinfo.links[0], GFP_KERNEL);
if (!sinfo.links[i]) {
cfg80211_sinfo_release_content(&sinfo);
return -ENOMEM;
@@ -10157,7 +10157,7 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
goto out;
}
- rd = kzalloc(struct_size(rd, reg_rules, num_rules), GFP_KERNEL);
+ rd = kzalloc_flex(*rd, reg_rules, num_rules, GFP_KERNEL);
if (!rd) {
r = -ENOMEM;
goto out;
@@ -11520,8 +11520,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
if (err)
goto free;
- csa_attrs = kcalloc(NL80211_ATTR_MAX + 1, sizeof(*csa_attrs),
- GFP_KERNEL);
+ csa_attrs = kzalloc_objs(*csa_attrs, NL80211_ATTR_MAX + 1, GFP_KERNEL);
if (!csa_attrs) {
err = -ENOMEM;
goto free;
@@ -11781,7 +11780,7 @@ static int nl80211_dump_scan(struct sk_buff *skb, struct netlink_callback *cb)
bool dump_include_use_data;
int err;
- attrbuf = kcalloc(NUM_NL80211_ATTR, sizeof(*attrbuf), GFP_KERNEL);
+ attrbuf = kzalloc_objs(*attrbuf, NUM_NL80211_ATTR, GFP_KERNEL);
if (!attrbuf)
return -ENOMEM;
@@ -11921,7 +11920,7 @@ static int nl80211_dump_survey(struct sk_buff *skb, struct netlink_callback *cb)
int res;
bool radio_stats;
- attrbuf = kcalloc(NUM_NL80211_ATTR, sizeof(*attrbuf), GFP_KERNEL);
+ attrbuf = kzalloc_objs(*attrbuf, NUM_NL80211_ATTR, GFP_KERNEL);
if (!attrbuf)
return -ENOMEM;
@@ -13112,8 +13111,7 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
goto out_err;
}
} else {
- attrbuf = kcalloc(NUM_NL80211_ATTR, sizeof(*attrbuf),
- GFP_KERNEL);
+ attrbuf = kzalloc_objs(*attrbuf, NUM_NL80211_ATTR, GFP_KERNEL);
if (!attrbuf) {
err = -ENOMEM;
goto out_err;
@@ -14310,9 +14308,8 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
}
if (n_thresholds) {
- cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
- n_thresholds),
- GFP_KERNEL);
+ cqm_config = kzalloc_flex(*cqm_config, rssi_thresholds,
+ n_thresholds, GFP_KERNEL);
if (!cqm_config)
return -ENOMEM;
@@ -14938,7 +14935,7 @@ static int nl80211_parse_wowlan_nd(struct cfg80211_registered_device *rdev,
struct nlattr **tb;
int err;
- tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL);
+ tb = kzalloc_objs(*tb, NUM_NL80211_ATTR, GFP_KERNEL);
if (!tb)
return -ENOMEM;
@@ -15054,9 +15051,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
if (n_patterns > wowlan->n_patterns)
return -EINVAL;
- new_triggers.patterns = kcalloc(n_patterns,
- sizeof(new_triggers.patterns[0]),
- GFP_KERNEL);
+ new_triggers.patterns = kzalloc_objs(new_triggers.patterns[0],
+ n_patterns, GFP_KERNEL);
if (!new_triggers.patterns)
return -ENOMEM;
@@ -15303,8 +15299,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
if (n_patterns > coalesce->n_patterns)
return -EINVAL;
- new_rule->patterns = kcalloc(n_patterns, sizeof(new_rule->patterns[0]),
- GFP_KERNEL);
+ new_rule->patterns = kzalloc_objs(new_rule->patterns[0], n_patterns,
+ GFP_KERNEL);
if (!new_rule->patterns)
return -ENOMEM;
@@ -15382,8 +15378,7 @@ static int nl80211_set_coalesce(struct sk_buff *skb, struct genl_info *info)
if (n_rules > coalesce->n_rules)
return -EINVAL;
- new_coalesce = kzalloc(struct_size(new_coalesce, rules, n_rules),
- GFP_KERNEL);
+ new_coalesce = kzalloc_flex(*new_coalesce, rules, n_rules, GFP_KERNEL);
if (!new_coalesce)
return -ENOMEM;
@@ -15543,7 +15538,7 @@ static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info)
if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS))
return -EOPNOTSUPP;
- nreg = kzalloc(sizeof(*nreg), GFP_KERNEL);
+ nreg = kzalloc_obj(*nreg, GFP_KERNEL);
if (!nreg)
return -ENOMEM;
@@ -15900,7 +15895,7 @@ static int handle_nan_filter(struct nlattr *attr_filter,
BUILD_BUG_ON(sizeof(*func->rx_filters) != sizeof(*func->tx_filters));
- filter = kcalloc(n_entries, sizeof(*func->rx_filters), GFP_KERNEL);
+ filter = kzalloc_objs(*func->rx_filters, n_entries, GFP_KERNEL);
if (!filter)
return -ENOMEM;
@@ -15960,7 +15955,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
if (err)
return err;
- func = kzalloc(sizeof(*func), GFP_KERNEL);
+ func = kzalloc_obj(*func, GFP_KERNEL);
if (!func)
return -ENOMEM;
@@ -16099,8 +16094,8 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
func->srf_num_macs = n_entries;
func->srf_macs =
- kcalloc(n_entries, sizeof(*func->srf_macs),
- GFP_KERNEL);
+ kzalloc_objs(*func->srf_macs, n_entries,
+ GFP_KERNEL);
if (!func->srf_macs) {
err = -ENOMEM;
goto out;
@@ -16602,7 +16597,7 @@ static int nl80211_prepare_vendor_dump(struct sk_buff *skb,
return 0;
}
- attrbuf = kcalloc(NUM_NL80211_ATTR, sizeof(*attrbuf), GFP_KERNEL);
+ attrbuf = kzalloc_objs(*attrbuf, NUM_NL80211_ATTR, GFP_KERNEL);
if (!attrbuf)
return -ENOMEM;
@@ -16833,7 +16828,7 @@ static int nl80211_set_qos_map(struct sk_buff *skb,
if (len % 2)
return -EINVAL;
- qos_map = kzalloc(sizeof(struct cfg80211_qos_map), GFP_KERNEL);
+ qos_map = kzalloc_obj(struct cfg80211_qos_map, GFP_KERNEL);
if (!qos_map)
return -ENOMEM;
@@ -17467,8 +17462,7 @@ static int nl80211_set_tid_config(struct sk_buff *skb,
rem_conf)
num_conf++;
- tid_config = kzalloc(struct_size(tid_config, tid_conf, num_conf),
- GFP_KERNEL);
+ tid_config = kzalloc_flex(*tid_config, tid_conf, num_conf, GFP_KERNEL);
if (!tid_config)
return -ENOMEM;
@@ -17534,7 +17528,7 @@ static int nl80211_color_change(struct sk_buff *skb, struct genl_info *info)
if (err)
return err;
- tb = kcalloc(NL80211_ATTR_MAX + 1, sizeof(*tb), GFP_KERNEL);
+ tb = kzalloc_objs(*tb, NL80211_ATTR_MAX + 1, GFP_KERNEL);
if (!tb)
return -ENOMEM;
@@ -18262,7 +18256,7 @@ static int nl80211_set_sar_specs(struct sk_buff *skb, struct genl_info *info)
if (specs > rdev->wiphy.sar_capa->num_freq_ranges)
return -EINVAL;
- sar_spec = kzalloc(struct_size(sar_spec, sub_specs, specs), GFP_KERNEL);
+ sar_spec = kzalloc_flex(*sar_spec, sub_specs, specs, GFP_KERNEL);
if (!sar_spec)
return -ENOMEM;
diff --git a/net/wireless/of.c b/net/wireless/of.c
index de221f0edca5..35a3bcd84b6f 100644
--- a/net/wireless/of.c
+++ b/net/wireless/of.c
@@ -98,7 +98,7 @@ void wiphy_read_of_freq_limits(struct wiphy *wiphy)
}
n_freq_limits = len / sizeof(u32) / 2;
- freq_limits = kcalloc(n_freq_limits, sizeof(*freq_limits), GFP_KERNEL);
+ freq_limits = kzalloc_objs(*freq_limits, n_freq_limits, GFP_KERNEL);
if (!freq_limits) {
err = -ENOMEM;
goto out_kfree;
diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c
index 60e1e31c2185..41aa8636a243 100644
--- a/net/wireless/pmsr.c
+++ b/net/wireless/pmsr.c
@@ -312,7 +312,7 @@ int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info)
}
}
- req = kzalloc(struct_size(req, peers, count), GFP_KERNEL);
+ req = kzalloc_flex(*req, peers, count, GFP_KERNEL);
if (!req)
return -ENOMEM;
req->n_peers = count;
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 139cb27e5a81..d6f3282fe986 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -452,8 +452,7 @@ reg_copy_regd(const struct ieee80211_regdomain *src_regd)
struct ieee80211_regdomain *regd;
unsigned int i;
- regd = kzalloc(struct_size(regd, reg_rules, src_regd->n_reg_rules),
- GFP_KERNEL);
+ regd = kzalloc_flex(*regd, reg_rules, src_regd->n_reg_rules, GFP_KERNEL);
if (!regd)
return ERR_PTR(-ENOMEM);
@@ -510,7 +509,7 @@ static int reg_schedule_apply(const struct ieee80211_regdomain *regdom)
{
struct reg_regdb_apply_request *request;
- request = kzalloc(sizeof(struct reg_regdb_apply_request), GFP_KERNEL);
+ request = kzalloc_obj(struct reg_regdb_apply_request, GFP_KERNEL);
if (!request) {
kfree(regdom);
return -ENOMEM;
@@ -933,8 +932,7 @@ static int regdb_query_country(const struct fwdb_header *db,
struct ieee80211_regdomain *regdom;
unsigned int i;
- regdom = kzalloc(struct_size(regdom, reg_rules, coll->n_rules),
- GFP_KERNEL);
+ regdom = kzalloc_flex(*regdom, reg_rules, coll->n_rules, GFP_KERNEL);
if (!regdom)
return -ENOMEM;
@@ -1100,7 +1098,7 @@ int reg_reload_regdb(void)
/* reset regulatory domain */
current_regdomain = get_cfg80211_regdom();
- request = kzalloc(sizeof(*request), GFP_KERNEL);
+ request = kzalloc_obj(*request, GFP_KERNEL);
if (!request) {
err = -ENOMEM;
goto out_unlock;
@@ -1532,7 +1530,7 @@ regdom_intersect(const struct ieee80211_regdomain *rd1,
if (!num_rules)
return NULL;
- rd = kzalloc(struct_size(rd, reg_rules, num_rules), GFP_KERNEL);
+ rd = kzalloc_flex(*rd, reg_rules, num_rules, GFP_KERNEL);
if (!rd)
return NULL;
@@ -3224,7 +3222,7 @@ static int regulatory_hint_core(const char *alpha2)
{
struct regulatory_request *request;
- request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
+ request = kzalloc_obj(struct regulatory_request, GFP_KERNEL);
if (!request)
return -ENOMEM;
@@ -3250,7 +3248,7 @@ int regulatory_hint_user(const char *alpha2,
if (!is_world_regdom(alpha2) && !is_an_alpha2(alpha2))
return -EINVAL;
- request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
+ request = kzalloc_obj(struct regulatory_request, GFP_KERNEL);
if (!request)
return -ENOMEM;
@@ -3320,7 +3318,7 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)
wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG;
- request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
+ request = kzalloc_obj(struct regulatory_request, GFP_KERNEL);
if (!request)
return -ENOMEM;
@@ -3353,7 +3351,7 @@ void regulatory_hint_country_ie(struct wiphy *wiphy, enum nl80211_band band,
if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN)
return;
- request = kzalloc(sizeof(*request), GFP_KERNEL);
+ request = kzalloc_obj(*request, GFP_KERNEL);
if (!request)
return;
@@ -3666,7 +3664,7 @@ void regulatory_hint_found_beacon(struct wiphy *wiphy,
if (processing)
return;
- reg_beacon = kzalloc(sizeof(struct reg_beacon), gfp);
+ reg_beacon = kzalloc_obj(struct reg_beacon, gfp);
if (!reg_beacon)
return;
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index eb0e77813d46..89174a9049a3 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -729,7 +729,7 @@ cfg80211_parse_colocated_ap_iter(void *_data, u8 type,
bss_params)))
return RNR_ITER_CONTINUE;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
return RNR_ITER_ERROR;
@@ -895,7 +895,7 @@ static int cfg80211_scan_6ghz(struct cfg80211_registered_device *rdev,
if (ret)
continue;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
continue;
@@ -1085,8 +1085,7 @@ int cfg80211_scan(struct cfg80211_registered_device *rdev)
if (!n_channels)
return cfg80211_scan_6ghz(rdev, true);
- request = kzalloc(struct_size(request, req.channels, n_channels),
- GFP_KERNEL);
+ request = kzalloc_flex(*request, req.channels, n_channels, GFP_KERNEL);
if (!request)
return -ENOMEM;
@@ -2694,7 +2693,7 @@ cfg80211_defrag_mle(const struct element *mle, const u8 *ie, size_t ielen,
buf_len += elem->datalen;
}
- res = kzalloc(struct_size(res, data, buf_len), gfp);
+ res = kzalloc_flex(*res, data, buf_len, gfp);
if (!res)
return NULL;
@@ -2910,9 +2909,8 @@ cfg80211_gen_reporter_rnr(struct cfg80211_bss *source_bss, bool is_mbssid,
le16_encode_bits(bss_change_count,
IEEE80211_RNR_MLD_PARAMS_BSS_CHANGE_COUNT);
- res = kzalloc(struct_size(res, data,
- sizeof(ap_info) + ap_info.tbtt_info_len),
- gfp);
+ res = kzalloc_flex(*res, data, sizeof(ap_info) + ap_info.tbtt_info_len,
+ gfp);
if (!res)
return NULL;
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 4e629ca305bc..cb1a75fda5ca 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -570,7 +570,7 @@ static int cfg80211_sme_connect(struct wireless_dev *wdev,
if (wdev->conn)
return -EINPROGRESS;
- wdev->conn = kzalloc(sizeof(*wdev->conn), GFP_KERNEL);
+ wdev->conn = kzalloc_obj(*wdev->conn, GFP_KERNEL);
if (!wdev->conn)
return -ENOMEM;
diff --git a/net/wireless/tests/util.c b/net/wireless/tests/util.c
index 8abdaeb820ce..6f870b06307d 100644
--- a/net/wireless/tests/util.c
+++ b/net/wireless/tests/util.c
@@ -17,7 +17,7 @@ int t_wiphy_init(struct kunit_resource *resource, void *ctx)
struct wiphy *wiphy;
struct t_wiphy_priv *priv;
- ops = kzalloc(sizeof(*ops), GFP_KERNEL);
+ ops = kzalloc_obj(*ops, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, ops);
wiphy = wiphy_new_nm(ops, sizeof(*priv), "kunit");
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 404fe604a8db..b78530c3e3f8 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -2713,8 +2713,8 @@ bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
int cfg80211_link_sinfo_alloc_tid_stats(struct link_station_info *link_sinfo,
gfp_t gfp)
{
- link_sinfo->pertid = kcalloc(IEEE80211_NUM_TIDS + 1,
- sizeof(*link_sinfo->pertid), gfp);
+ link_sinfo->pertid = kzalloc_objs(*link_sinfo->pertid,
+ IEEE80211_NUM_TIDS + 1, gfp);
if (!link_sinfo->pertid)
return -ENOMEM;
@@ -2724,9 +2724,8 @@ EXPORT_SYMBOL(cfg80211_link_sinfo_alloc_tid_stats);
int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp)
{
- sinfo->pertid = kcalloc(IEEE80211_NUM_TIDS + 1,
- sizeof(*(sinfo->pertid)),
- gfp);
+ sinfo->pertid = kzalloc_objs(*(sinfo->pertid), IEEE80211_NUM_TIDS + 1,
+ gfp);
if (!sinfo->pertid)
return -ENOMEM;
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 1241fda78a68..3ce845cd1936 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -414,8 +414,7 @@ static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
* to do it first in case the allocation fails. Don't use wext.
*/
if (!wdev->wext.keys) {
- wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys),
- GFP_KERNEL);
+ wdev->wext.keys = kzalloc_obj(*wdev->wext.keys, GFP_KERNEL);
if (!wdev->wext.keys)
return -ENOMEM;
for (i = 0; i < 4; i++)
diff --git a/net/x25/x25_forward.c b/net/x25/x25_forward.c
index 21b30b56e889..3b406906eb9e 100644
--- a/net/x25/x25_forward.c
+++ b/net/x25/x25_forward.c
@@ -55,8 +55,7 @@ int x25_forward_call(struct x25_address *dest_addr, struct x25_neigh *from,
/* Save the forwarding details for future traffic */
if (!same_lci){
- if ((new_frwd = kmalloc(sizeof(struct x25_forward),
- GFP_ATOMIC)) == NULL){
+ if ((new_frwd = kmalloc_obj(struct x25_forward, GFP_ATOMIC)) == NULL){
rc = -ENOMEM;
goto out_put_nb;
}
diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c
index 4608aa5b4f31..d1e8cd81c214 100644
--- a/net/x25/x25_link.c
+++ b/net/x25/x25_link.c
@@ -262,7 +262,7 @@ void x25_link_terminated(struct x25_neigh *nb)
*/
void x25_link_device_up(struct net_device *dev)
{
- struct x25_neigh *nb = kmalloc(sizeof(*nb), GFP_ATOMIC);
+ struct x25_neigh *nb = kmalloc_obj(*nb, GFP_ATOMIC);
if (!nb)
return;
diff --git a/net/x25/x25_route.c b/net/x25/x25_route.c
index 647f325ed867..b28055f852df 100644
--- a/net/x25/x25_route.c
+++ b/net/x25/x25_route.c
@@ -37,7 +37,7 @@ static int x25_add_route(struct x25_address *address, unsigned int sigdigits,
goto out;
}
- rt = kmalloc(sizeof(*rt), GFP_ATOMIC);
+ rt = kmalloc_obj(*rt, GFP_ATOMIC);
rc = -ENOMEM;
if (!rt)
goto out;
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 9f76ca591d54..4c94ec312d75 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -97,7 +97,8 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address)
long npgs;
int err;
- umem->pgs = kvcalloc(umem->npgs, sizeof(*umem->pgs), GFP_KERNEL | __GFP_NOWARN);
+ umem->pgs = kvzalloc_objs(*umem->pgs, umem->npgs,
+ GFP_KERNEL | __GFP_NOWARN);
if (!umem->pgs)
return -ENOMEM;
@@ -249,7 +250,7 @@ struct xdp_umem *xdp_umem_create(struct xdp_umem_reg *mr)
struct xdp_umem *umem;
int err;
- umem = kzalloc(sizeof(*umem), GFP_KERNEL);
+ umem = kzalloc_obj(*umem, GFP_KERNEL);
if (!umem)
return ERR_PTR(-ENOMEM);
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index cd5125b6af53..a8f932b28ee3 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -42,8 +42,8 @@ void xp_destroy(struct xsk_buff_pool *pool)
int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs)
{
- pool->tx_descs = kvcalloc(xs->tx->nentries, sizeof(*pool->tx_descs),
- GFP_KERNEL);
+ pool->tx_descs = kvzalloc_objs(*pool->tx_descs, xs->tx->nentries,
+ GFP_KERNEL);
if (!pool->tx_descs)
return -ENOMEM;
@@ -59,11 +59,11 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
u32 i, entries;
entries = unaligned ? umem->chunks : 0;
- pool = kvzalloc(struct_size(pool, free_heads, entries), GFP_KERNEL);
+ pool = kvzalloc_flex(*pool, free_heads, entries, GFP_KERNEL);
if (!pool)
goto out;
- pool->heads = kvcalloc(umem->chunks, sizeof(*pool->heads), GFP_KERNEL);
+ pool->heads = kvzalloc_objs(*pool->heads, umem->chunks, GFP_KERNEL);
if (!pool->heads)
goto out;
@@ -328,11 +328,12 @@ static struct xsk_dma_map *xp_create_dma_map(struct device *dev, struct net_devi
{
struct xsk_dma_map *dma_map;
- dma_map = kzalloc(sizeof(*dma_map), GFP_KERNEL);
+ dma_map = kzalloc_obj(*dma_map, GFP_KERNEL);
if (!dma_map)
return NULL;
- dma_map->dma_pages = kvcalloc(nr_pages, sizeof(*dma_map->dma_pages), GFP_KERNEL);
+ dma_map->dma_pages = kvzalloc_objs(*dma_map->dma_pages, nr_pages,
+ GFP_KERNEL);
if (!dma_map->dma_pages) {
kfree(dma_map);
return NULL;
@@ -420,7 +421,8 @@ static int xp_init_dma_info(struct xsk_buff_pool *pool, struct xsk_dma_map *dma_
}
}
- pool->dma_pages = kvcalloc(dma_map->dma_pages_cnt, sizeof(*pool->dma_pages), GFP_KERNEL);
+ pool->dma_pages = kvzalloc_objs(*pool->dma_pages,
+ dma_map->dma_pages_cnt, GFP_KERNEL);
if (!pool->dma_pages)
return -ENOMEM;
diff --git a/net/xdp/xsk_queue.c b/net/xdp/xsk_queue.c
index d2c264030017..ef089b9c4fc8 100644
--- a/net/xdp/xsk_queue.c
+++ b/net/xdp/xsk_queue.c
@@ -26,7 +26,7 @@ struct xsk_queue *xskq_create(u32 nentries, bool umem_queue)
struct xsk_queue *q;
size_t size;
- q = kzalloc(sizeof(*q), GFP_KERNEL);
+ q = kzalloc_obj(*q, GFP_KERNEL);
if (!q)
return NULL;
diff --git a/net/xfrm/espintcp.c b/net/xfrm/espintcp.c
index bf744ac9d5a7..3f6eda9364ec 100644
--- a/net/xfrm/espintcp.c
+++ b/net/xfrm/espintcp.c
@@ -465,7 +465,7 @@ static int espintcp_init_sk(struct sock *sk)
if (sk->sk_user_data)
return -EBUSY;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index 43fdc6ed8dd1..35f8236059a7 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -336,7 +336,7 @@ int ipcomp_init_state(struct xfrm_state *x, struct netlink_ext_ack *extack)
}
err = -ENOMEM;
- ipcd = kzalloc(sizeof(*ipcd), GFP_KERNEL);
+ ipcd = kzalloc_obj(*ipcd, GFP_KERNEL);
if (!ipcd)
goto out;
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 3b6d7284fc70..92b9a5b80804 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -2526,8 +2526,8 @@ static int iptfs_user_init(struct net *net, struct xfrm_state *x,
nla_get_u16(attrs[XFRMA_IPTFS_REORDER_WINDOW]);
/* saved array is for saving 1..N seq nums from wantseq */
if (xc->reorder_win_size) {
- xtfs->w_saved = kcalloc(xc->reorder_win_size,
- sizeof(*xtfs->w_saved), GFP_KERNEL);
+ xtfs->w_saved = kzalloc_objs(*xtfs->w_saved,
+ xc->reorder_win_size, GFP_KERNEL);
if (!xtfs->w_saved) {
NL_SET_ERR_MSG(extack, "Cannot alloc reorder window");
return -ENOMEM;
@@ -2658,8 +2658,9 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig)
xtfs->ra_newskb = NULL;
if (xtfs->cfg.reorder_win_size) {
- xtfs->w_saved = kcalloc(xtfs->cfg.reorder_win_size,
- sizeof(*xtfs->w_saved), GFP_KERNEL);
+ xtfs->w_saved = kzalloc_objs(*xtfs->w_saved,
+ xtfs->cfg.reorder_win_size,
+ GFP_KERNEL);
if (!xtfs->w_saved) {
kfree_sensitive(xtfs);
return -ENOMEM;
@@ -2677,7 +2678,7 @@ static int iptfs_init_state(struct xfrm_state *x)
/* We have arrived here from xfrm_state_clone() */
xtfs = x->mode_data;
} else {
- xtfs = kzalloc(sizeof(*xtfs), GFP_KERNEL);
+ xtfs = kzalloc_obj(*xtfs, GFP_KERNEL);
if (!xtfs)
return -ENOMEM;
}
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 62486f866975..ee8bb445c4d3 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -429,7 +429,7 @@ struct xfrm_policy *xfrm_policy_alloc(struct net *net, gfp_t gfp)
{
struct xfrm_policy *policy;
- policy = kzalloc(sizeof(struct xfrm_policy), gfp);
+ policy = kzalloc_obj(struct xfrm_policy, gfp);
if (policy) {
write_pnet(&policy->xp_net, net);
@@ -765,7 +765,7 @@ xfrm_policy_inexact_alloc_bin(const struct xfrm_policy *pol, u8 dir)
if (bin)
return bin;
- bin = kzalloc(sizeof(*bin), GFP_ATOMIC);
+ bin = kzalloc_obj(*bin, GFP_ATOMIC);
if (!bin)
return NULL;
@@ -836,7 +836,7 @@ xfrm_pol_inexact_node_alloc(const xfrm_address_t *addr, u8 prefixlen)
{
struct xfrm_pol_inexact_node *node;
- node = kzalloc(sizeof(*node), GFP_ATOMIC);
+ node = kzalloc_obj(*node, GFP_ATOMIC);
if (node)
xfrm_pol_inexact_node_init(node, addr, prefixlen);