summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /fs
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/vfs_super.c4
-rw-r--r--fs/adfs/dir.c2
-rw-r--r--fs/adfs/map.c2
-rw-r--r--fs/adfs/super.c2
-rw-r--r--fs/affs/dir.c2
-rw-r--r--fs/affs/super.c4
-rw-r--r--fs/afs/addr_list.c2
-rw-r--r--fs/afs/addr_prefs.c2
-rw-r--r--fs/afs/cell.c2
-rw-r--r--fs/afs/cmservice.c14
-rw-r--r--fs/afs/dir.c9
-rw-r--r--fs/afs/dir_silly.c2
-rw-r--r--fs/afs/file.c4
-rw-r--r--fs/afs/fs_operation.c2
-rw-r--r--fs/afs/fs_probe.c2
-rw-r--r--fs/afs/fsclient.c2
-rw-r--r--fs/afs/main.c2
-rw-r--r--fs/afs/proc.c2
-rw-r--r--fs/afs/rotate.c5
-rw-r--r--fs/afs/rxrpc.c2
-rw-r--r--fs/afs/security.c2
-rw-r--r--fs/afs/server.c2
-rw-r--r--fs/afs/server_list.c2
-rw-r--r--fs/afs/super.c4
-rw-r--r--fs/afs/vl_list.c5
-rw-r--r--fs/afs/vlclient.c2
-rw-r--r--fs/afs/volume.c2
-rw-r--r--fs/afs/xattr.c4
-rw-r--r--fs/afs/yfsclient.c4
-rw-r--r--fs/aio.c6
-rw-r--r--fs/autofs/inode.c6
-rw-r--r--fs/autofs/waitq.c2
-rw-r--r--fs/befs/btree.c5
-rw-r--r--fs/befs/linuxvfs.c4
-rw-r--r--fs/bfs/inode.c2
-rw-r--r--fs/binfmt_elf.c17
-rw-r--r--fs/binfmt_elf_fdpic.c12
-rw-r--r--fs/binfmt_misc.c2
-rw-r--r--fs/btrfs/async-thread.c4
-rw-r--r--fs/btrfs/backref.c12
-rw-r--r--fs/btrfs/bio.c2
-rw-r--r--fs/btrfs/block-group.c7
-rw-r--r--fs/btrfs/block-rsv.c2
-rw-r--r--fs/btrfs/compression.c8
-rw-r--r--fs/btrfs/defrag.c4
-rw-r--r--fs/btrfs/delayed-inode.c4
-rw-r--r--fs/btrfs/delayed-ref.c2
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/btrfs/extent_io.h2
-rw-r--r--fs/btrfs/fiemap.c5
-rw-r--r--fs/btrfs/file-item.c2
-rw-r--r--fs/btrfs/file.c4
-rw-r--r--fs/btrfs/free-space-cache.c2
-rw-r--r--fs/btrfs/inode.c18
-rw-r--r--fs/btrfs/ioctl.c24
-rw-r--r--fs/btrfs/lru_cache.c2
-rw-r--r--fs/btrfs/lzo.c2
-rw-r--r--fs/btrfs/qgroup.c25
-rw-r--r--fs/btrfs/raid56.c14
-rw-r--r--fs/btrfs/ref-verify.c16
-rw-r--r--fs/btrfs/relocation.c8
-rw-r--r--fs/btrfs/scrub.c13
-rw-r--r--fs/btrfs/send.c30
-rw-r--r--fs/btrfs/space-info.c4
-rw-r--r--fs/btrfs/super.c4
-rw-r--r--fs/btrfs/sysfs.c4
-rw-r--r--fs/btrfs/tests/btrfs-tests.c17
-rw-r--r--fs/btrfs/tests/delayed-refs-tests.c2
-rw-r--r--fs/btrfs/transaction.c2
-rw-r--r--fs/btrfs/tree-log.c6
-rw-r--r--fs/btrfs/tree-mod-log.c17
-rw-r--r--fs/btrfs/ulist.c6
-rw-r--r--fs/btrfs/volumes.c12
-rw-r--r--fs/btrfs/zlib.c2
-rw-r--r--fs/btrfs/zoned.c5
-rw-r--r--fs/btrfs/zstd.c4
-rw-r--r--fs/buffer.c3
-rw-r--r--fs/cachefiles/daemon.c2
-rw-r--r--fs/cachefiles/io.c4
-rw-r--r--fs/cachefiles/ondemand.c4
-rw-r--r--fs/cachefiles/volume.c2
-rw-r--r--fs/ceph/addr.c8
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/crypto.c4
-rw-r--r--fs/ceph/file.c6
-rw-r--r--fs/ceph/inode.c2
-rw-r--r--fs/ceph/mds_client.c17
-rw-r--r--fs/ceph/mdsmap.c4
-rw-r--r--fs/ceph/quota.c2
-rw-r--r--fs/ceph/snap.c4
-rw-r--r--fs/ceph/super.c6
-rw-r--r--fs/ceph/xattr.c10
-rw-r--r--fs/char_dev.c4
-rw-r--r--fs/coda/dir.c2
-rw-r--r--fs/coda/file.c4
-rw-r--r--fs/coda/inode.c2
-rw-r--r--fs/coda/upcall.c6
-rw-r--r--fs/configfs/dir.c4
-rw-r--r--fs/configfs/file.c2
-rw-r--r--fs/configfs/inode.c2
-rw-r--r--fs/coredump.c5
-rw-r--r--fs/cramfs/inode.c4
-rw-r--r--fs/crypto/inline_crypt.c4
-rw-r--r--fs/crypto/keyring.c4
-rw-r--r--fs/crypto/keysetup_v1.c2
-rw-r--r--fs/crypto/policy.c2
-rw-r--r--fs/debugfs/file.c2
-rw-r--r--fs/debugfs/inode.c2
-rw-r--r--fs/devpts/inode.c2
-rw-r--r--fs/dlm/config.c20
-rw-r--r--fs/dlm/dir.c2
-rw-r--r--fs/dlm/lock.c4
-rw-r--r--fs/dlm/lockspace.c2
-rw-r--r--fs/dlm/lowcomms.c6
-rw-r--r--fs/dlm/member.c10
-rw-r--r--fs/dlm/midcomms.c2
-rw-r--r--fs/dlm/plock.c10
-rw-r--r--fs/dlm/user.c6
-rw-r--r--fs/ecryptfs/crypto.c2
-rw-r--r--fs/ecryptfs/keystore.c4
-rw-r--r--fs/ecryptfs/main.c2
-rw-r--r--fs/ecryptfs/messaging.c2
-rw-r--r--fs/efivarfs/super.c4
-rw-r--r--fs/efs/super.c2
-rw-r--r--fs/erofs/decompressor_deflate.c2
-rw-r--r--fs/erofs/decompressor_lzma.c2
-rw-r--r--fs/erofs/decompressor_zstd.c2
-rw-r--r--fs/erofs/fileio.c3
-rw-r--r--fs/erofs/fscache.c10
-rw-r--r--fs/erofs/super.c8
-rw-r--r--fs/erofs/xattr.c6
-rw-r--r--fs/erofs/zdata.c16
-rw-r--r--fs/erofs/zutil.c10
-rw-r--r--fs/eventfd.c2
-rw-r--r--fs/eventpoll.c2
-rw-r--r--fs/exec.c2
-rw-r--r--fs/exfat/balloc.c4
-rw-r--r--fs/exfat/dir.c2
-rw-r--r--fs/exfat/super.c2
-rw-r--r--fs/ext2/balloc.c2
-rw-r--r--fs/ext2/super.c11
-rw-r--r--fs/ext4/block_validity.c2
-rw-r--r--fs/ext4/dir.c5
-rw-r--r--fs/ext4/extents-test.c4
-rw-r--r--fs/ext4/extents.c12
-rw-r--r--fs/ext4/fsmap.c2
-rw-r--r--fs/ext4/mballoc-test.c13
-rw-r--r--fs/ext4/mballoc.c11
-rw-r--r--fs/ext4/orphan.c3
-rw-r--r--fs/ext4/resize.c11
-rw-r--r--fs/ext4/super.c18
-rw-r--r--fs/ext4/sysfs.c2
-rw-r--r--fs/ext4/xattr.c18
-rw-r--r--fs/f2fs/super.c8
-rw-r--r--fs/fat/inode.c4
-rw-r--r--fs/fat/namei_vfat.c2
-rw-r--r--fs/fcntl.c2
-rw-r--r--fs/fhandle.c8
-rw-r--r--fs/file.c4
-rw-r--r--fs/freevxfs/vxfs_fshead.c2
-rw-r--r--fs/freevxfs/vxfs_super.c2
-rw-r--r--fs/fs-writeback.c9
-rw-r--r--fs/fs_context.c2
-rw-r--r--fs/fsopen.c2
-rw-r--r--fs/fuse/backing.c2
-rw-r--r--fs/fuse/cuse.c6
-rw-r--r--fs/fuse/dax.c8
-rw-r--r--fs/fuse/dev.c5
-rw-r--r--fs/fuse/dev_uring.c12
-rw-r--r--fs/fuse/dir.c4
-rw-r--r--fs/fuse/file.c10
-rw-r--r--fs/fuse/inode.c20
-rw-r--r--fs/fuse/virtio_fs.c22
-rw-r--r--fs/gfs2/bmap.c2
-rw-r--r--fs/gfs2/dir.c2
-rw-r--r--fs/gfs2/file.c4
-rw-r--r--fs/gfs2/glock.c3
-rw-r--r--fs/gfs2/ops_fstype.c8
-rw-r--r--fs/gfs2/quota.c4
-rw-r--r--fs/gfs2/recovery.c2
-rw-r--r--fs/gfs2/rgrp.c11
-rw-r--r--fs/gfs2/super.c4
-rw-r--r--fs/gfs2/xattr.c2
-rw-r--r--fs/hfs/btree.c2
-rw-r--r--fs/hfs/dir.c2
-rw-r--r--fs/hfs/super.c2
-rw-r--r--fs/hfsplus/btree.c2
-rw-r--r--fs/hfsplus/dir.c2
-rw-r--r--fs/hfsplus/super.c2
-rw-r--r--fs/hfsplus/unicode_test.c4
-rw-r--r--fs/hostfs/hostfs_kern.c2
-rw-r--r--fs/hpfs/dnode.c2
-rw-r--r--fs/hpfs/super.c4
-rw-r--r--fs/hugetlbfs/inode.c4
-rw-r--r--fs/iomap/buffered-io.c3
-rw-r--r--fs/iomap/direct-io.c2
-rw-r--r--fs/isofs/compress.c7
-rw-r--r--fs/isofs/inode.c4
-rw-r--r--fs/jbd2/journal.c11
-rw-r--r--fs/jbd2/revoke.c2
-rw-r--r--fs/jffs2/acl.c3
-rw-r--r--fs/jffs2/erase.c2
-rw-r--r--fs/jffs2/fs.c3
-rw-r--r--fs/jffs2/readinode.c2
-rw-r--r--fs/jffs2/scan.c2
-rw-r--r--fs/jffs2/summary.c18
-rw-r--r--fs/jffs2/super.c2
-rw-r--r--fs/jffs2/wbuf.c2
-rw-r--r--fs/jffs2/xattr.c4
-rw-r--r--fs/jfs/jfs_dmap.c4
-rw-r--r--fs/jfs/jfs_imap.c2
-rw-r--r--fs/jfs/jfs_logmgr.c8
-rw-r--r--fs/jfs/jfs_metapage.c2
-rw-r--r--fs/jfs/super.c4
-rw-r--r--fs/kernfs/dir.c2
-rw-r--r--fs/kernfs/file.c4
-rw-r--r--fs/kernfs/mount.c4
-rw-r--r--fs/libfs.c4
-rw-r--r--fs/lockd/clntlock.c2
-rw-r--r--fs/lockd/clntproc.c4
-rw-r--r--fs/lockd/host.c2
-rw-r--r--fs/lockd/svclock.c4
-rw-r--r--fs/lockd/svcsubs.c2
-rw-r--r--fs/mbcache.c7
-rw-r--r--fs/minix/inode.c2
-rw-r--r--fs/mnt_idmapping.c2
-rw-r--r--fs/namei.c4
-rw-r--r--fs/namespace.c6
-rw-r--r--fs/netfs/buffered_read.c2
-rw-r--r--fs/netfs/buffered_write.c2
-rw-r--r--fs/netfs/fscache_cache.c2
-rw-r--r--fs/netfs/fscache_io.c2
-rw-r--r--fs/netfs/fscache_volume.c3
-rw-r--r--fs/netfs/rolling_buffer.c2
-rw-r--r--fs/nfs/blocklayout/blocklayout.c8
-rw-r--r--fs/nfs/blocklayout/dev.c13
-rw-r--r--fs/nfs/blocklayout/extent_tree.c9
-rw-r--r--fs/nfs/cache_lib.c2
-rw-r--r--fs/nfs/callback_proc.c2
-rw-r--r--fs/nfs/callback_xdr.c13
-rw-r--r--fs/nfs/client.c4
-rw-r--r--fs/nfs/delegation.c7
-rw-r--r--fs/nfs/dir.c12
-rw-r--r--fs/nfs/dns_resolve.c2
-rw-r--r--fs/nfs/filelayout/filelayout.c10
-rw-r--r--fs/nfs/filelayout/filelayoutdev.c2
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c23
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayoutdev.c9
-rw-r--r--fs/nfs/fs_context.c2
-rw-r--r--fs/nfs/fscache.c2
-rw-r--r--fs/nfs/inode.c12
-rw-r--r--fs/nfs/localio.c7
-rw-r--r--fs/nfs/nfs3proc.c2
-rw-r--r--fs/nfs/nfs40client.c2
-rw-r--r--fs/nfs/nfs40proc.c4
-rw-r--r--fs/nfs/nfs42proc.c18
-rw-r--r--fs/nfs/nfs42xdr.c2
-rw-r--r--fs/nfs/nfs4client.c2
-rw-r--r--fs/nfs/nfs4file.c3
-rw-r--r--fs/nfs/nfs4idmap.c4
-rw-r--r--fs/nfs/nfs4namespace.c4
-rw-r--r--fs/nfs/nfs4proc.c38
-rw-r--r--fs/nfs/nfs4session.c4
-rw-r--r--fs/nfs/nfs4state.c10
-rw-r--r--fs/nfs/nfs4super.c2
-rw-r--r--fs/nfs/pagelist.c5
-rw-r--r--fs/nfs/pnfs.c12
-rw-r--r--fs/nfs/pnfs_dev.c4
-rw-r--r--fs/nfs/pnfs_nfs.c6
-rw-r--r--fs/nfs/proc.c2
-rw-r--r--fs/nfs/sysfs.c4
-rw-r--r--fs/nfs/unlink.c4
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/nfsd/blocklayout.c6
-rw-r--r--fs/nfsd/blocklayoutxdr.c4
-rw-r--r--fs/nfsd/export.c11
-rw-r--r--fs/nfsd/filecache.c2
-rw-r--r--fs/nfsd/flexfilelayout.c4
-rw-r--r--fs/nfsd/nfs4callback.c4
-rw-r--r--fs/nfsd/nfs4idmap.c2
-rw-r--r--fs/nfsd/nfs4proc.c9
-rw-r--r--fs/nfsd/nfs4recover.c16
-rw-r--r--fs/nfsd/nfs4state.c34
-rw-r--r--fs/nfsd/nfs4xdr.c6
-rw-r--r--fs/nfsd/nfsctl.c4
-rw-r--r--fs/nilfs2/alloc.c2
-rw-r--r--fs/nilfs2/recovery.c4
-rw-r--r--fs/nilfs2/segment.c2
-rw-r--r--fs/nilfs2/super.c2
-rw-r--r--fs/nilfs2/the_nilfs.c4
-rw-r--r--fs/notify/fanotify/fanotify_user.c2
-rw-r--r--fs/notify/group.c2
-rw-r--r--fs/notify/inotify/inotify_user.c2
-rw-r--r--fs/notify/mark.c2
-rw-r--r--fs/ntfs3/bitmap.c2
-rw-r--r--fs/ntfs3/file.c2
-rw-r--r--fs/ntfs3/frecord.c6
-rw-r--r--fs/ntfs3/fslog.c9
-rw-r--r--fs/ntfs3/index.c4
-rw-r--r--fs/ntfs3/lib/lzx_decompress.c2
-rw-r--r--fs/ntfs3/lib/xpress_decompress.c2
-rw-r--r--fs/ntfs3/ntfs_fs.h4
-rw-r--r--fs/ntfs3/record.c2
-rw-r--r--fs/ntfs3/super.c4
-rw-r--r--fs/ocfs2/alloc.c15
-rw-r--r--fs/ocfs2/aops.c7
-rw-r--r--fs/ocfs2/cluster/heartbeat.c12
-rw-r--r--fs/ocfs2/cluster/netdebug.c2
-rw-r--r--fs/ocfs2/cluster/nodemanager.c6
-rw-r--r--fs/ocfs2/cluster/tcp.c8
-rw-r--r--fs/ocfs2/dcache.c2
-rw-r--r--fs/ocfs2/dir.c3
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c8
-rw-r--r--fs/ocfs2/dlm/dlmlock.c2
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c4
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c6
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c2
-rw-r--r--fs/ocfs2/dlmglue.c2
-rw-r--r--fs/ocfs2/extent_map.c2
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/ocfs2/filecheck.c4
-rw-r--r--fs/ocfs2/ioctl.c4
-rw-r--r--fs/ocfs2/journal.c14
-rw-r--r--fs/ocfs2/localalloc.c2
-rw-r--r--fs/ocfs2/move_extents.c2
-rw-r--r--fs/ocfs2/namei.c2
-rw-r--r--fs/ocfs2/quota_local.c6
-rw-r--r--fs/ocfs2/refcounttree.c6
-rw-r--r--fs/ocfs2/slot_map.c6
-rw-r--r--fs/ocfs2/stack_o2cb.c2
-rw-r--r--fs/ocfs2/stack_user.c4
-rw-r--r--fs/ocfs2/stackglue.c3
-rw-r--r--fs/ocfs2/suballoc.c8
-rw-r--r--fs/ocfs2/super.c4
-rw-r--r--fs/ocfs2/xattr.c2
-rw-r--r--fs/omfs/inode.c4
-rw-r--r--fs/orangefs/dir.c3
-rw-r--r--fs/orangefs/inode.c10
-rw-r--r--fs/orangefs/orangefs-bufmap.c8
-rw-r--r--fs/orangefs/orangefs-debugfs.c2
-rw-r--r--fs/orangefs/orangefs-mod.c2
-rw-r--r--fs/orangefs/orangefs-sysfs.c16
-rw-r--r--fs/orangefs/super.c2
-rw-r--r--fs/orangefs/xattr.c4
-rw-r--r--fs/overlayfs/file.c2
-rw-r--r--fs/overlayfs/namei.c2
-rw-r--r--fs/overlayfs/params.c6
-rw-r--r--fs/overlayfs/readdir.c6
-rw-r--r--fs/overlayfs/super.c4
-rw-r--r--fs/overlayfs/util.c4
-rw-r--r--fs/pipe.c9
-rw-r--r--fs/posix_acl.c2
-rw-r--r--fs/proc/kcore.c6
-rw-r--r--fs/proc/root.c4
-rw-r--r--fs/proc/task_mmu.c5
-rw-r--r--fs/pstore/blk.c2
-rw-r--r--fs/pstore/inode.c6
-rw-r--r--fs/pstore/platform.c2
-rw-r--r--fs/pstore/ram.c6
-rw-r--r--fs/pstore/ram_core.c9
-rw-r--r--fs/pstore/zone.c4
-rw-r--r--fs/qnx4/inode.c2
-rw-r--r--fs/qnx6/inode.c4
-rw-r--r--fs/qnx6/super_mmi.c2
-rw-r--r--fs/quota/quota_v2.c2
-rw-r--r--fs/ramfs/inode.c2
-rw-r--r--fs/resctrl/monitor.c2
-rw-r--r--fs/resctrl/pseudo_lock.c4
-rw-r--r--fs/resctrl/rdtgroup.c8
-rw-r--r--fs/select.c4
-rw-r--r--fs/seq_file.c2
-rw-r--r--fs/signalfd.c2
-rw-r--r--fs/smb/client/cached_dir.c6
-rw-r--r--fs/smb/client/cifs_swn.c2
-rw-r--r--fs/smb/client/cifsacl.c9
-rw-r--r--fs/smb/client/cifsencrypt.c2
-rw-r--r--fs/smb/client/cifsfs.c4
-rw-r--r--fs/smb/client/compress.c2
-rw-r--r--fs/smb/client/connect.c10
-rw-r--r--fs/smb/client/dfs.h2
-rw-r--r--fs/smb/client/dfs_cache.c4
-rw-r--r--fs/smb/client/file.c16
-rw-r--r--fs/smb/client/fs_context.c2
-rw-r--r--fs/smb/client/inode.c11
-rw-r--r--fs/smb/client/ioctl.c2
-rw-r--r--fs/smb/client/misc.c16
-rw-r--r--fs/smb/client/readdir.c4
-rw-r--r--fs/smb/client/sess.c2
-rw-r--r--fs/smb/client/smb1ops.c2
-rw-r--r--fs/smb/client/smb1session.c4
-rw-r--r--fs/smb/client/smb2file.c4
-rw-r--r--fs/smb/client/smb2inode.c2
-rw-r--r--fs/smb/client/smb2misc.c4
-rw-r--r--fs/smb/client/smb2ops.c17
-rw-r--r--fs/smb/client/smb2pdu.c24
-rw-r--r--fs/smb/client/smbdirect.c9
-rw-r--r--fs/smb/server/auth.c7
-rw-r--r--fs/smb/server/connection.c2
-rw-r--r--fs/smb/server/crypto_ctx.c4
-rw-r--r--fs/smb/server/ksmbd_work.c6
-rw-r--r--fs/smb/server/mgmt/share_config.c4
-rw-r--r--fs/smb/server/mgmt/tree_connect.c3
-rw-r--r--fs/smb/server/mgmt/user_config.c2
-rw-r--r--fs/smb/server/mgmt/user_session.c6
-rw-r--r--fs/smb/server/oplock.c12
-rw-r--r--fs/smb/server/server.c2
-rw-r--r--fs/smb/server/smb2pdu.c10
-rw-r--r--fs/smb/server/smbacl.c10
-rw-r--r--fs/smb/server/transport_rdma.c8
-rw-r--r--fs/smb/server/transport_tcp.c6
-rw-r--r--fs/smb/server/vfs_cache.c4
-rw-r--r--fs/splice.c10
-rw-r--r--fs/squashfs/block.c4
-rw-r--r--fs/squashfs/cache.c4
-rw-r--r--fs/squashfs/decompressor_multi.c6
-rw-r--r--fs/squashfs/decompressor_single.c2
-rw-r--r--fs/squashfs/file.c5
-rw-r--r--fs/squashfs/lz4_wrapper.c2
-rw-r--r--fs/squashfs/lzo_wrapper.c2
-rw-r--r--fs/squashfs/page_actor.c4
-rw-r--r--fs/squashfs/super.c4
-rw-r--r--fs/squashfs/xz_wrapper.c4
-rw-r--r--fs/squashfs/zlib_wrapper.c2
-rw-r--r--fs/squashfs/zstd_wrapper.c2
-rw-r--r--fs/super.c6
-rw-r--r--fs/sync.c2
-rw-r--r--fs/sysfs/mount.c2
-rw-r--r--fs/timerfd.c2
-rw-r--r--fs/tracefs/event_inode.c8
-rw-r--r--fs/tracefs/inode.c2
-rw-r--r--fs/ubifs/debug.c4
-rw-r--r--fs/ubifs/dir.c6
-rw-r--r--fs/ubifs/file.c2
-rw-r--r--fs/ubifs/gc.c4
-rw-r--r--fs/ubifs/log.c4
-rw-r--r--fs/ubifs/lpt.c15
-rw-r--r--fs/ubifs/orphan.c4
-rw-r--r--fs/ubifs/recovery.c4
-rw-r--r--fs/ubifs/replay.c8
-rw-r--r--fs/ubifs/scan.c4
-rw-r--r--fs/ubifs/super.c12
-rw-r--r--fs/ubifs/sysfs.c2
-rw-r--r--fs/ubifs/tnc.c9
-rw-r--r--fs/ubifs/tnc_commit.c5
-rw-r--r--fs/udf/super.c16
-rw-r--r--fs/ufs/super.c11
-rw-r--r--fs/ufs/util.c2
-rw-r--r--fs/unicode/utf8-core.c2
-rw-r--r--fs/userfaultfd.c4
-rw-r--r--fs/vboxsf/file.c2
-rw-r--r--fs/vboxsf/super.c4
-rw-r--r--fs/vboxsf/utils.c4
-rw-r--r--fs/xfs/libxfs/xfs_ag.c2
-rw-r--r--fs/xfs/libxfs/xfs_defer.c2
-rw-r--r--fs/xfs/libxfs/xfs_dir2.c19
-rw-r--r--fs/xfs/libxfs/xfs_refcount.c4
-rw-r--r--fs/xfs/libxfs/xfs_rtgroup.c2
-rw-r--r--fs/xfs/scrub/agheader.c4
-rw-r--r--fs/xfs/scrub/agheader_repair.c2
-rw-r--r--fs/xfs/scrub/alloc_repair.c2
-rw-r--r--fs/xfs/scrub/attr.c2
-rw-r--r--fs/xfs/scrub/attr_repair.c2
-rw-r--r--fs/xfs/scrub/bitmap.c12
-rw-r--r--fs/xfs/scrub/bmap_repair.c2
-rw-r--r--fs/xfs/scrub/btree.c2
-rw-r--r--fs/xfs/scrub/cow_repair.c2
-rw-r--r--fs/xfs/scrub/dabtree.c2
-rw-r--r--fs/xfs/scrub/dir.c2
-rw-r--r--fs/xfs/scrub/dir_repair.c2
-rw-r--r--fs/xfs/scrub/dirtree.c4
-rw-r--r--fs/xfs/scrub/dirtree_repair.c2
-rw-r--r--fs/xfs/scrub/fscounters.c2
-rw-r--r--fs/xfs/scrub/ialloc_repair.c2
-rw-r--r--fs/xfs/scrub/inode_repair.c2
-rw-r--r--fs/xfs/scrub/metapath.c2
-rw-r--r--fs/xfs/scrub/newbt.c2
-rw-r--r--fs/xfs/scrub/nlinks.c2
-rw-r--r--fs/xfs/scrub/parent.c2
-rw-r--r--fs/xfs/scrub/parent_repair.c2
-rw-r--r--fs/xfs/scrub/quotacheck.c4
-rw-r--r--fs/xfs/scrub/rcbag.c2
-rw-r--r--fs/xfs/scrub/refcount.c3
-rw-r--r--fs/xfs/scrub/refcount_repair.c2
-rw-r--r--fs/xfs/scrub/rmap.c2
-rw-r--r--fs/xfs/scrub/rmap_repair.c2
-rw-r--r--fs/xfs/scrub/rtbitmap.c4
-rw-r--r--fs/xfs/scrub/rtrefcount.c3
-rw-r--r--fs/xfs/scrub/rtrefcount_repair.c2
-rw-r--r--fs/xfs/scrub/rtrmap_repair.c2
-rw-r--r--fs/xfs/scrub/rtsummary.c3
-rw-r--r--fs/xfs/scrub/scrub.c4
-rw-r--r--fs/xfs/scrub/stats.c2
-rw-r--r--fs/xfs/scrub/xfblob.c2
-rw-r--r--fs/xfs/scrub/xfile.c2
-rw-r--r--fs/xfs/xfs_buf.c6
-rw-r--r--fs/xfs/xfs_buf_item_recover.c5
-rw-r--r--fs/xfs/xfs_buf_mem.c2
-rw-r--r--fs/xfs/xfs_discard.c6
-rw-r--r--fs/xfs/xfs_extent_busy.c5
-rw-r--r--fs/xfs/xfs_filestream.c2
-rw-r--r--fs/xfs/xfs_fsmap.c4
-rw-r--r--fs/xfs/xfs_healthmon.c7
-rw-r--r--fs/xfs/xfs_inode_item_recover.c4
-rw-r--r--fs/xfs/xfs_ioctl.c2
-rw-r--r--fs/xfs/xfs_itable.c8
-rw-r--r--fs/xfs/xfs_iwalk.c4
-rw-r--r--fs/xfs/xfs_log.c2
-rw-r--r--fs/xfs/xfs_log_cil.c4
-rw-r--r--fs/xfs/xfs_log_recover.c9
-rw-r--r--fs/xfs/xfs_mru_cache.c2
-rw-r--r--fs/xfs/xfs_qm.c4
-rw-r--r--fs/xfs/xfs_super.c6
-rw-r--r--fs/xfs/xfs_trans_ail.c3
-rw-r--r--fs/xfs/xfs_zone_alloc.c4
-rw-r--r--fs/xfs/xfs_zone_gc.c6
-rw-r--r--fs/zonefs/super.c12
516 files changed, 1276 insertions, 1355 deletions
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 315336de6f02..b9872016deae 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -90,7 +90,7 @@ static int v9fs_get_tree(struct fs_context *fc)
p9_debug(P9_DEBUG_VFS, "\n");
- v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL);
+ v9ses = kzalloc_obj(struct v9fs_session_info, GFP_KERNEL);
if (!v9ses)
return -ENOMEM;
@@ -308,7 +308,7 @@ static int v9fs_init_fs_context(struct fs_context *fc)
{
struct v9fs_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 4f9dc276da6f..366fb93c7b38 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -108,7 +108,7 @@ int adfs_dir_read_buffers(struct super_block *sb, u32 indaddr,
if (dir->bhs != dir->bh)
return -EINVAL;
- bhs = kcalloc(num, sizeof(*bhs), GFP_KERNEL);
+ bhs = kzalloc_objs(*bhs, num, GFP_KERNEL);
if (!bhs)
return -ENOMEM;
diff --git a/fs/adfs/map.c b/fs/adfs/map.c
index a0ce272b4098..9e24e212b3e1 100644
--- a/fs/adfs/map.c
+++ b/fs/adfs/map.c
@@ -373,7 +373,7 @@ struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_discrecor
((nzones > 1) ? ADFS_DR_SIZE_BITS : 0);
map_addr = signed_asl(map_addr, asb->s_map2blk);
- dm = kmalloc_array(nzones, sizeof(*dm), GFP_KERNEL);
+ dm = kmalloc_objs(*dm, nzones, GFP_KERNEL);
if (dm == NULL) {
adfs_error(sb, "not enough memory");
return ERR_PTR(-ENOMEM);
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index fdccdbbfc213..a8e73e980abb 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -437,7 +437,7 @@ static int adfs_init_fs_context(struct fs_context *fc)
{
struct adfs_sb_info *asb;
- asb = kzalloc(sizeof(struct adfs_sb_info), GFP_KERNEL);
+ asb = kzalloc_obj(struct adfs_sb_info, GFP_KERNEL);
if (!asb)
return -ENOMEM;
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index fe18caaf4d65..39b6ddc4e4b1 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -36,7 +36,7 @@ static int affs_dir_open(struct inode *inode, struct file *file)
{
struct affs_dir_data *data;
- data = kzalloc(sizeof(struct affs_dir_data), GFP_KERNEL);
+ data = kzalloc_obj(struct affs_dir_data, GFP_KERNEL);
if (!data)
return -ENOMEM;
file->private_data = data;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 44f8aa883100..1a2f72fea1ab 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -327,7 +327,7 @@ static int affs_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_time_min = sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA;
sb->s_time_max = 86400LL * U32_MAX + 86400 + sb->s_time_min;
- sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct affs_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
@@ -615,7 +615,7 @@ static int affs_init_fs_context(struct fs_context *fc)
{
struct affs_context *ctx;
- ctx = kzalloc(sizeof(struct affs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct affs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/afs/addr_list.c b/fs/afs/addr_list.c
index e941da5b6dd9..26590bfeae91 100644
--- a/fs/afs/addr_list.c
+++ b/fs/afs/addr_list.c
@@ -66,7 +66,7 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr)
if (nr > AFS_MAX_ADDRESSES)
nr = AFS_MAX_ADDRESSES;
- alist = kzalloc(struct_size(alist, addrs, nr), GFP_KERNEL);
+ alist = kzalloc_flex(*alist, addrs, nr, GFP_KERNEL);
if (!alist)
return NULL;
diff --git a/fs/afs/addr_prefs.c b/fs/afs/addr_prefs.c
index 133736412c3d..f5a4fb6f609a 100644
--- a/fs/afs/addr_prefs.c
+++ b/fs/afs/addr_prefs.c
@@ -401,7 +401,7 @@ int afs_proc_addr_prefs_write(struct file *file, char *buf, size_t size)
max_prefs = min_t(size_t, (psize - sizeof(*old)) / sizeof(old->prefs[0]), 255);
ret = -ENOMEM;
- preflist = kmalloc(struct_size(preflist, prefs, max_prefs), GFP_KERNEL);
+ preflist = kmalloc_flex(*preflist, prefs, max_prefs, GFP_KERNEL);
if (!preflist)
goto done;
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 71c10a05cebe..4331bf8e1dbd 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -134,7 +134,7 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
_enter("%*.*s,%s", namelen, namelen, name, addresses);
- cell = kzalloc(sizeof(struct afs_cell), GFP_KERNEL);
+ cell = kzalloc_obj(struct afs_cell, GFP_KERNEL);
if (!cell) {
_leave(" = -ENOMEM");
return ERR_PTR(-ENOMEM);
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 1a906805a9e3..a32e7c2864d2 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -228,9 +228,8 @@ static int afs_deliver_cb_callback(struct afs_call *call)
return ret;
_debug("unmarshall FID array");
- call->request = kcalloc(call->count,
- sizeof(struct afs_callback_break),
- GFP_KERNEL);
+ call->request = kzalloc_objs(struct afs_callback_break,
+ call->count, GFP_KERNEL);
if (!call->request)
return -ENOMEM;
@@ -340,7 +339,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
}
_debug("unmarshall UUID");
- call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
+ call->request = kmalloc_obj(struct afs_uuid, GFP_KERNEL);
if (!call->request)
return -ENOMEM;
@@ -457,7 +456,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
}
_debug("unmarshall UUID");
- call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
+ call->request = kmalloc_obj(struct afs_uuid, GFP_KERNEL);
if (!call->request)
return -ENOMEM;
@@ -589,9 +588,8 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call)
return ret;
_debug("unmarshall FID array");
- call->request = kcalloc(call->count,
- sizeof(struct afs_callback_break),
- GFP_KERNEL);
+ call->request = kzalloc_objs(struct afs_callback_break,
+ call->count, GFP_KERNEL);
if (!call->request)
return -ENOMEM;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index f4e9e12373ac..6f7380f25365 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -785,7 +785,7 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry)
_enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry);
- cookie = kzalloc(sizeof(struct afs_lookup_cookie), GFP_KERNEL);
+ cookie = kzalloc_obj(struct afs_lookup_cookie, GFP_KERNEL);
if (!cookie)
return ERR_PTR(-ENOMEM);
@@ -834,9 +834,8 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry)
/* Need space for examining all the selected files */
if (op->nr_files > 2) {
- op->more_files = kvcalloc(op->nr_files - 2,
- sizeof(struct afs_vnode_param),
- GFP_KERNEL);
+ op->more_files = kvzalloc_objs(struct afs_vnode_param,
+ op->nr_files - 2, GFP_KERNEL);
if (!op->more_files) {
afs_op_nomem(op);
goto out_op;
@@ -2095,7 +2094,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
goto error;
ret = -ENOMEM;
- op->more_files = kvcalloc(2, sizeof(struct afs_vnode_param), GFP_KERNEL);
+ op->more_files = kvzalloc_objs(struct afs_vnode_param, 2, GFP_KERNEL);
if (!op->more_files)
goto error;
diff --git a/fs/afs/dir_silly.c b/fs/afs/dir_silly.c
index 014495d4b868..f77bed45e808 100644
--- a/fs/afs/dir_silly.c
+++ b/fs/afs/dir_silly.c
@@ -69,7 +69,7 @@ static int afs_do_silly_rename(struct afs_vnode *dvnode, struct afs_vnode *vnode
if (IS_ERR(op))
return PTR_ERR(op);
- op->more_files = kvcalloc(2, sizeof(struct afs_vnode_param), GFP_KERNEL);
+ op->more_files = kvzalloc_objs(struct afs_vnode_param, 2, GFP_KERNEL);
if (!op->more_files) {
afs_put_operation(op);
return -ENOMEM;
diff --git a/fs/afs/file.c b/fs/afs/file.c
index f66a92294284..5c429a746d76 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -86,7 +86,7 @@ int afs_cache_wb_key(struct afs_vnode *vnode, struct afs_file *af)
{
struct afs_wb_key *wbk, *p;
- wbk = kzalloc(sizeof(struct afs_wb_key), GFP_KERNEL);
+ wbk = kzalloc_obj(struct afs_wb_key, GFP_KERNEL);
if (!wbk)
return -ENOMEM;
refcount_set(&wbk->usage, 2);
@@ -130,7 +130,7 @@ int afs_open(struct inode *inode, struct file *file)
goto error;
}
- af = kzalloc(sizeof(*af), GFP_KERNEL);
+ af = kzalloc_obj(*af, GFP_KERNEL);
if (!af) {
ret = -ENOMEM;
goto error_key;
diff --git a/fs/afs/fs_operation.c b/fs/afs/fs_operation.c
index 8418813ee043..0ffd19f5279d 100644
--- a/fs/afs/fs_operation.c
+++ b/fs/afs/fs_operation.c
@@ -21,7 +21,7 @@ struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *vo
_enter("");
- op = kzalloc(sizeof(*op), GFP_KERNEL);
+ op = kzalloc_obj(*op, GFP_KERNEL);
if (!op)
return ERR_PTR(-ENOMEM);
diff --git a/fs/afs/fs_probe.c b/fs/afs/fs_probe.c
index e0030ac74ea0..0100ce4c62a0 100644
--- a/fs/afs/fs_probe.c
+++ b/fs/afs/fs_probe.c
@@ -244,7 +244,7 @@ int afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,
_enter("%pU", &server->uuid);
- estate = kzalloc(sizeof(*estate), GFP_KERNEL);
+ estate = kzalloc_obj(*estate, GFP_KERNEL);
if (!estate)
return -ENOMEM;
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index bc9556991d7c..eb3520b9a282 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -2010,7 +2010,7 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call)
size = call->count2 = ntohl(call->tmp);
size = round_up(size, 4);
- acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
+ acl = kmalloc_flex(*acl, data, size, GFP_KERNEL);
if (!acl)
return -ENOMEM;
op->acl = acl;
diff --git a/fs/afs/main.c b/fs/afs/main.c
index e6bb8237db98..7e09bf7aa03b 100644
--- a/fs/afs/main.c
+++ b/fs/afs/main.c
@@ -93,7 +93,7 @@ static int __net_init afs_net_init(struct net *net_ns)
atomic_set(&net->servers_outstanding, 1);
ret = -ENOMEM;
- sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
+ sysnames = kzalloc_obj(*sysnames, GFP_KERNEL);
if (!sysnames)
goto error_sysnames;
sysnames->subs[0] = (char *)&afs_init_sysname;
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 44520549b509..52e8195ef2b8 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -572,7 +572,7 @@ static int afs_proc_sysname_write(struct file *file, char *buf, size_t size)
char *s, *p, *sub;
int ret, len;
- sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
+ sysnames = kzalloc_obj(*sysnames, GFP_KERNEL);
if (!sysnames)
return -ENOMEM;
refcount_set(&sysnames->usage, 1);
diff --git a/fs/afs/rotate.c b/fs/afs/rotate.c
index 6a4e7da10fc4..69e80c5b6610 100644
--- a/fs/afs/rotate.c
+++ b/fs/afs/rotate.c
@@ -46,8 +46,9 @@ static bool afs_start_fs_iteration(struct afs_operation *op,
lockdep_is_held(&op->volume->servers_lock)));
read_unlock(&op->volume->servers_lock);
- op->server_states = kcalloc(op->server_list->nr_servers, sizeof(op->server_states[0]),
- GFP_KERNEL);
+ op->server_states = kzalloc_objs(op->server_states[0],
+ op->server_list->nr_servers,
+ GFP_KERNEL);
if (!op->server_states) {
afs_op_nomem(op);
trace_afs_rotate(op, afs_rotate_trace_nomem, 0);
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index bf0e4ea0aafd..588f8de51167 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -160,7 +160,7 @@ static struct afs_call *afs_alloc_call(struct afs_net *net,
struct afs_call *call;
int o;
- call = kzalloc(sizeof(*call), gfp);
+ call = kzalloc_obj(*call, gfp);
if (!call)
return NULL;
diff --git a/fs/afs/security.c b/fs/afs/security.c
index 55ddce94af03..6d00d62a65ed 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -252,7 +252,7 @@ void afs_cache_permit(struct afs_vnode *vnode, struct key *key,
* yet.
*/
size++;
- new = kzalloc(struct_size(new, permits, size), GFP_NOFS);
+ new = kzalloc_flex(*new, permits, size, GFP_NOFS);
if (!new)
goto out_put;
diff --git a/fs/afs/server.c b/fs/afs/server.c
index c4428ebddb1d..8777c566d12d 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -117,7 +117,7 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell, const uuid_t *
_enter("");
- server = kzalloc(sizeof(struct afs_server), GFP_KERNEL);
+ server = kzalloc_obj(struct afs_server, GFP_KERNEL);
if (!server)
return NULL;
diff --git a/fs/afs/server_list.c b/fs/afs/server_list.c
index 20d5474837df..b948df6dddc7 100644
--- a/fs/afs/server_list.c
+++ b/fs/afs/server_list.c
@@ -51,7 +51,7 @@ struct afs_server_list *afs_alloc_server_list(struct afs_volume *volume,
newrep++;
}
- slist = kzalloc(struct_size(slist, servers, nr_servers), GFP_KERNEL);
+ slist = kzalloc_flex(*slist, servers, nr_servers, GFP_KERNEL);
if (!slist)
goto error;
diff --git a/fs/afs/super.c b/fs/afs/super.c
index d672b7ab57ae..2b567fe5b4cb 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -502,7 +502,7 @@ static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc)
struct afs_fs_context *ctx = fc->fs_private;
struct afs_super_info *as;
- as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
+ as = kzalloc_obj(struct afs_super_info, GFP_KERNEL);
if (as) {
as->net_ns = get_net(fc->net_ns);
as->flock_mode = ctx->flock_mode;
@@ -623,7 +623,7 @@ static int afs_init_fs_context(struct fs_context *fc)
struct afs_fs_context *ctx;
struct afs_cell *cell;
- ctx = kzalloc(sizeof(struct afs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct afs_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/afs/vl_list.c b/fs/afs/vl_list.c
index 9b1c20daac53..4f430ae01646 100644
--- a/fs/afs/vl_list.c
+++ b/fs/afs/vl_list.c
@@ -15,8 +15,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len,
struct afs_vlserver *vlserver;
static atomic_t debug_ids;
- vlserver = kzalloc(struct_size(vlserver, name, name_len + 1),
- GFP_KERNEL);
+ vlserver = kzalloc_flex(*vlserver, name, name_len + 1, GFP_KERNEL);
if (vlserver) {
refcount_set(&vlserver->ref, 1);
rwlock_init(&vlserver->lock);
@@ -52,7 +51,7 @@ struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int nr_servers)
{
struct afs_vlserver_list *vllist;
- vllist = kzalloc(struct_size(vllist, servers, nr_servers), GFP_KERNEL);
+ vllist = kzalloc_flex(*vllist, servers, nr_servers, GFP_KERNEL);
if (vllist) {
refcount_set(&vllist->ref, 1);
rwlock_init(&vllist->lock);
diff --git a/fs/afs/vlclient.c b/fs/afs/vlclient.c
index 3a23c0b08eb6..05abd50e4057 100644
--- a/fs/afs/vlclient.c
+++ b/fs/afs/vlclient.c
@@ -122,7 +122,7 @@ struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *vc,
padsz = (4 - (volnamesz & 3)) & 3;
reqsz = 8 + volnamesz + padsz;
- entry = kzalloc(sizeof(struct afs_vldb_entry), GFP_KERNEL);
+ entry = kzalloc_obj(struct afs_vldb_entry, GFP_KERNEL);
if (!entry)
return ERR_PTR(-ENOMEM);
diff --git a/fs/afs/volume.c b/fs/afs/volume.c
index 0efff3d25133..260df046143a 100644
--- a/fs/afs/volume.c
+++ b/fs/afs/volume.c
@@ -81,7 +81,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,
struct afs_volume *volume;
int ret = -ENOMEM, i;
- volume = kzalloc(sizeof(struct afs_volume), GFP_KERNEL);
+ volume = kzalloc_obj(struct afs_volume, GFP_KERNEL);
if (!volume)
goto error_0;
diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
index e19f396aa370..2daf23af01e5 100644
--- a/fs/afs/xattr.c
+++ b/fs/afs/xattr.c
@@ -75,7 +75,7 @@ static bool afs_make_acl(struct afs_operation *op,
{
struct afs_acl *acl;
- acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
+ acl = kmalloc_flex(*acl, data, size, GFP_KERNEL);
if (!acl) {
afs_op_nomem(op);
return false;
@@ -157,7 +157,7 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler,
else
return -EOPNOTSUPP;
- yacl = kzalloc(sizeof(struct yfs_acl), GFP_KERNEL);
+ yacl = kzalloc_obj(struct yfs_acl, GFP_KERNEL);
if (!yacl)
goto error;
diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c
index febf13a49f0b..9adc2dcde9a7 100644
--- a/fs/afs/yfsclient.c
+++ b/fs/afs/yfsclient.c
@@ -2048,7 +2048,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
size = round_up(size, 4);
if (yacl->flags & YFS_ACL_WANT_ACL) {
- acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
+ acl = kmalloc_flex(*acl, data, size, GFP_KERNEL);
if (!acl)
return -ENOMEM;
yacl->acl = acl;
@@ -2080,7 +2080,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
size = round_up(size, 4);
if (yacl->flags & YFS_ACL_WANT_VOL_ACL) {
- acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
+ acl = kmalloc_flex(*acl, data, size, GFP_KERNEL);
if (!acl)
return -ENOMEM;
yacl->vol_acl = acl;
diff --git a/fs/aio.c b/fs/aio.c
index 59b67b8da1b2..4eb757df3d80 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -510,8 +510,8 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
ctx->ring_folios = ctx->internal_folios;
if (nr_pages > AIO_RING_PAGES) {
- ctx->ring_folios = kcalloc(nr_pages, sizeof(struct folio *),
- GFP_KERNEL);
+ ctx->ring_folios = kzalloc_objs(struct folio *, nr_pages,
+ GFP_KERNEL);
if (!ctx->ring_folios) {
put_aio_ring_file(ctx);
return -ENOMEM;
@@ -693,7 +693,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
new_nr = (table ? table->nr : 1) * 4;
spin_unlock(&mm->ioctx_lock);
- table = kzalloc(struct_size(table, table, new_nr), GFP_KERNEL);
+ table = kzalloc_flex(*table, table, new_nr, GFP_KERNEL);
if (!table)
return -ENOMEM;
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index b932b1719dfc..5134a042044c 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -13,7 +13,7 @@ struct autofs_info *autofs_new_ino(struct autofs_sb_info *sbi)
{
struct autofs_info *ino;
- ino = kzalloc(sizeof(*ino), GFP_KERNEL);
+ ino = kzalloc_obj(*ino, GFP_KERNEL);
if (ino) {
INIT_LIST_HEAD(&ino->active);
INIT_LIST_HEAD(&ino->expiring);
@@ -242,7 +242,7 @@ static struct autofs_sb_info *autofs_alloc_sbi(void)
{
struct autofs_sb_info *sbi;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return NULL;
@@ -405,7 +405,7 @@ int autofs_init_fs_context(struct fs_context *fc)
struct autofs_fs_context *ctx;
struct autofs_sb_info *sbi;
- ctx = kzalloc(sizeof(struct autofs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct autofs_fs_context, GFP_KERNEL);
if (!ctx)
goto nomem;
diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c
index 33dd4660d82f..21ecd0bbc0ca 100644
--- a/fs/autofs/waitq.c
+++ b/fs/autofs/waitq.c
@@ -376,7 +376,7 @@ int autofs_wait(struct autofs_sb_info *sbi,
if (!wq) {
/* Create a new wait queue */
- wq = kmalloc(sizeof(struct autofs_wait_queue), GFP_KERNEL);
+ wq = kmalloc_obj(struct autofs_wait_queue, GFP_KERNEL);
if (!wq) {
kfree(name);
mutex_unlock(&sbi->wq_mutex);
diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 53b36aa29978..aa24f1daccdd 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -258,8 +258,7 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds,
goto error;
}
- this_node = kmalloc(sizeof(struct befs_btree_node),
- GFP_NOFS);
+ this_node = kmalloc_obj(struct befs_btree_node, GFP_NOFS);
if (!this_node) {
befs_error(sb, "befs_btree_find() failed to allocate %zu "
"bytes of memory", sizeof(struct befs_btree_node));
@@ -431,7 +430,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
goto error;
}
- this_node = kmalloc(sizeof(struct befs_btree_node), GFP_NOFS);
+ this_node = kmalloc_obj(struct befs_btree_node, GFP_NOFS);
if (this_node == NULL) {
befs_error(sb, "befs_btree_read() failed to allocate %zu "
"bytes of memory", sizeof(struct befs_btree_node));
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index d7c5d9270387..df54c52d2f19 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -790,7 +790,7 @@ befs_fill_super(struct super_block *sb, struct fs_context *fc)
struct befs_mount_options *parsed_opts = fc->fs_private;
int silent = fc->sb_flags & SB_SILENT;
- sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL);
+ sb->s_fs_info = kzalloc_obj(*befs_sb, GFP_KERNEL);
if (sb->s_fs_info == NULL)
goto unacquire_none;
@@ -956,7 +956,7 @@ static int befs_init_fs_context(struct fs_context *fc)
{
struct befs_mount_options *opts;
- opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kzalloc_obj(*opts, GFP_KERNEL);
if (!opts)
return -ENOMEM;
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index ce6f83234b67..6ed07d892e3d 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -334,7 +334,7 @@ static int bfs_fill_super(struct super_block *s, struct fs_context *fc)
unsigned long i_sblock, i_eblock, i_eoff, s_size;
int silent = fc->sb_flags & SB_SILENT;
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
mutex_init(&info->bfs_lock);
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 3eb734c192e9..6ea9681cab33 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -916,7 +916,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
*/
would_dump(bprm, interpreter);
- interp_elf_ex = kmalloc(sizeof(*interp_elf_ex), GFP_KERNEL);
+ interp_elf_ex = kmalloc_obj(*interp_elf_ex, GFP_KERNEL);
if (!interp_elf_ex) {
retval = -ENOMEM;
goto out_free_file;
@@ -1798,7 +1798,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
fill_note(&t->notes[0], PRSTATUS, sizeof(t->prstatus), &t->prstatus);
info->size += notesize(&t->notes[0]);
- fpu = kzalloc(sizeof(elf_fpregset_t), GFP_KERNEL);
+ fpu = kzalloc_obj(elf_fpregset_t, GFP_KERNEL);
if (!fpu || !elf_core_copy_task_fpregs(p, fpu)) {
kfree(fpu);
return 1;
@@ -1824,7 +1824,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
u16 machine;
u32 flags;
- psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
+ psinfo = kmalloc_obj(*psinfo, GFP_KERNEL);
if (!psinfo)
return 0;
fill_note(&info->psinfo, PRPSINFO, sizeof(*psinfo), psinfo);
@@ -1873,15 +1873,14 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
/*
* Allocate a structure for each thread.
*/
- info->thread = kzalloc(struct_size(info->thread, notes, info->thread_notes),
- GFP_KERNEL);
+ info->thread = kzalloc_flex(*info->thread, notes, info->thread_notes,
+ GFP_KERNEL);
if (unlikely(!info->thread))
return 0;
info->thread->task = dump_task;
for (ct = dump_task->signal->core_state->dumper.next; ct; ct = ct->next) {
- t = kzalloc(struct_size(t, notes, info->thread_notes),
- GFP_KERNEL);
+ t = kzalloc_flex(*t, notes, info->thread_notes, GFP_KERNEL);
if (unlikely(!t))
return 0;
@@ -2037,7 +2036,7 @@ static int elf_core_dump(struct coredump_params *cprm)
/* For cell spufs and x86 xstate */
sz += elf_coredump_extra_notes_size();
- phdr4note = kmalloc(sizeof(*phdr4note), GFP_KERNEL);
+ phdr4note = kmalloc_obj(*phdr4note, GFP_KERNEL);
if (!phdr4note)
goto end_coredump;
@@ -2052,7 +2051,7 @@ static int elf_core_dump(struct coredump_params *cprm)
e_shoff = offset;
if (e_phnum == PN_XNUM) {
- shdr4extnum = kmalloc(sizeof(*shdr4extnum), GFP_KERNEL);
+ shdr4extnum = kmalloc_obj(*shdr4extnum, GFP_KERNEL);
if (!shdr4extnum)
goto end_coredump;
fill_extnum_info(&elf, shdr4extnum, e_shoff, segs);
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 48fd2de3bca0..cee0871b0164 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -761,7 +761,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
if (nloads == 0)
return -ELIBBAD;
- loadmap = kzalloc(struct_size(loadmap, segs, nloads), GFP_KERNEL);
+ loadmap = kzalloc_flex(*loadmap, segs, nloads, GFP_KERNEL);
if (!loadmap)
return -ENOMEM;
@@ -1391,7 +1391,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_
struct elf_thread_status *t;
int i, ret;
- t = kzalloc(sizeof(struct elf_thread_status), GFP_KERNEL);
+ t = kzalloc_obj(struct elf_thread_status, GFP_KERNEL);
if (!t)
return t;
@@ -1486,10 +1486,10 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
struct elf_thread_status *tmp;
/* alloc memory for large data structures: too large to be on stack */
- elf = kmalloc(sizeof(*elf), GFP_KERNEL);
+ elf = kmalloc_obj(*elf, GFP_KERNEL);
if (!elf)
goto end_coredump;
- psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
+ psinfo = kmalloc_obj(*psinfo, GFP_KERNEL);
if (!psinfo)
goto end_coredump;
@@ -1547,7 +1547,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
offset += segs * sizeof(struct elf_phdr); /* Program headers */
/* Write notes phdr entry */
- phdr4note = kmalloc(sizeof(*phdr4note), GFP_KERNEL);
+ phdr4note = kmalloc_obj(*phdr4note, GFP_KERNEL);
if (!phdr4note)
goto end_coredump;
@@ -1562,7 +1562,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
e_shoff = offset;
if (e_phnum == PN_XNUM) {
- shdr4extnum = kmalloc(sizeof(*shdr4extnum), GFP_KERNEL);
+ shdr4extnum = kmalloc_obj(*shdr4extnum, GFP_KERNEL);
if (!shdr4extnum)
goto end_coredump;
fill_extnum_info(elf, shdr4extnum, e_shoff, segs);
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 2b772613a74c..4a15e09bc398 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -961,7 +961,7 @@ static int bm_fill_super(struct super_block *sb, struct fs_context *fc)
* create their own separate binfmt_misc mounts we should
* consider turning this into a kmem cache.
*/
- misc = kzalloc(sizeof(struct binfmt_misc), GFP_KERNEL);
+ misc = kzalloc_obj(struct binfmt_misc, GFP_KERNEL);
if (!misc)
return -ENOMEM;
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 6c6f3bb58f4e..cce7b2610364 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -85,7 +85,7 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
const char *name, unsigned int flags,
int limit_active, int thresh)
{
- struct btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_KERNEL);
+ struct btrfs_workqueue *ret = kzalloc_obj(*ret, GFP_KERNEL);
if (!ret)
return NULL;
@@ -126,7 +126,7 @@ struct btrfs_workqueue *btrfs_alloc_ordered_workqueue(
{
struct btrfs_workqueue *ret;
- ret = kzalloc(sizeof(*ret), GFP_KERNEL);
+ ret = kzalloc_obj(*ret, GFP_KERNEL);
if (!ret)
return NULL;
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 9bb406f7dd30..78bf0cad1d2d 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -78,7 +78,7 @@ static int check_extent_in_eb(struct btrfs_backref_walk_ctx *ctx,
}
add_inode_elem:
- e = kmalloc(sizeof(*e), GFP_NOFS);
+ e = kmalloc_obj(*e, GFP_NOFS);
if (!e)
return -ENOMEM;
@@ -1805,7 +1805,7 @@ struct btrfs_backref_share_check_ctx *btrfs_alloc_backref_share_check_ctx(void)
{
struct btrfs_backref_share_check_ctx *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return NULL;
@@ -2797,7 +2797,7 @@ struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
if (IS_ERR(fspath))
return ERR_CAST(fspath);
- ifp = kmalloc(sizeof(*ifp), GFP_KERNEL);
+ ifp = kmalloc_obj(*ifp, GFP_KERNEL);
if (!ifp) {
kvfree(fspath);
return ERR_PTR(-ENOMEM);
@@ -2814,7 +2814,7 @@ struct btrfs_backref_iter *btrfs_backref_iter_alloc(struct btrfs_fs_info *fs_inf
{
struct btrfs_backref_iter *ret;
- ret = kzalloc(sizeof(*ret), GFP_NOFS);
+ ret = kzalloc_obj(*ret, GFP_NOFS);
if (!ret)
return NULL;
@@ -3024,7 +3024,7 @@ struct btrfs_backref_node *btrfs_backref_alloc_node(
struct btrfs_backref_node *node;
ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL);
- node = kzalloc(sizeof(*node), GFP_NOFS);
+ node = kzalloc_obj(*node, GFP_NOFS);
if (!node)
return node;
@@ -3057,7 +3057,7 @@ struct btrfs_backref_edge *btrfs_backref_alloc_edge(
{
struct btrfs_backref_edge *edge;
- edge = kzalloc(sizeof(*edge), GFP_NOFS);
+ edge = kzalloc_obj(*edge, GFP_NOFS);
if (edge)
cache->nr_edges++;
return edge;
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 4a1528803ff7..2a2a21aec817 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -709,7 +709,7 @@ static bool btrfs_wq_submit_bio(struct btrfs_bio *bbio,
struct btrfs_fs_info *fs_info = bbio->inode->root->fs_info;
struct async_submit_bio *async;
- async = kmalloc(sizeof(*async), GFP_NOFS);
+ async = kmalloc_obj(*async, GFP_NOFS);
if (!async)
return false;
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 5f76683b3f21..c284f48cfae4 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -947,7 +947,7 @@ int btrfs_cache_block_group(struct btrfs_block_group *cache, bool wait)
if (cache->flags & BTRFS_BLOCK_GROUP_REMAPPED)
return 0;
- caching_ctl = kzalloc(sizeof(*caching_ctl), GFP_NOFS);
+ caching_ctl = kzalloc_obj(*caching_ctl, GFP_NOFS);
if (!caching_ctl)
return -ENOMEM;
@@ -2312,12 +2312,11 @@ static struct btrfs_block_group *btrfs_create_block_group(
{
struct btrfs_block_group *cache;
- cache = kzalloc(sizeof(*cache), GFP_NOFS);
+ cache = kzalloc_obj(*cache, GFP_NOFS);
if (!cache)
return NULL;
- cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl),
- GFP_NOFS);
+ cache->free_space_ctl = kzalloc_obj(*cache->free_space_ctl, GFP_NOFS);
if (!cache->free_space_ctl) {
kfree(cache);
return NULL;
diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
index 93c371db8731..6064dd00d041 100644
--- a/fs/btrfs/block-rsv.c
+++ b/fs/btrfs/block-rsv.c
@@ -192,7 +192,7 @@ struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct btrfs_fs_info *fs_info,
{
struct btrfs_block_rsv *block_rsv;
- block_rsv = kmalloc(sizeof(*block_rsv), GFP_NOFS);
+ block_rsv = kmalloc_obj(*block_rsv, GFP_NOFS);
if (!block_rsv)
return NULL;
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 1e7174ad32e2..7fde7698c331 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -662,7 +662,7 @@ static struct list_head *alloc_heuristic_ws(struct btrfs_fs_info *fs_info)
{
struct heuristic_ws *ws;
- ws = kzalloc(sizeof(*ws), GFP_KERNEL);
+ ws = kzalloc_obj(*ws, GFP_KERNEL);
if (!ws)
return ERR_PTR(-ENOMEM);
@@ -670,11 +670,11 @@ static struct list_head *alloc_heuristic_ws(struct btrfs_fs_info *fs_info)
if (!ws->sample)
goto fail;
- ws->bucket = kcalloc(BUCKET_SIZE, sizeof(*ws->bucket), GFP_KERNEL);
+ ws->bucket = kzalloc_objs(*ws->bucket, BUCKET_SIZE, GFP_KERNEL);
if (!ws->bucket)
goto fail;
- ws->bucket_b = kcalloc(BUCKET_SIZE, sizeof(*ws->bucket_b), GFP_KERNEL);
+ ws->bucket_b = kzalloc_objs(*ws->bucket_b, BUCKET_SIZE, GFP_KERNEL);
if (!ws->bucket_b)
goto fail;
@@ -734,7 +734,7 @@ static int alloc_workspace_manager(struct btrfs_fs_info *fs_info,
struct list_head *workspace;
ASSERT(fs_info->compr_wsm[type] == NULL);
- gwsm = kzalloc(sizeof(*gwsm), GFP_KERNEL);
+ gwsm = kzalloc_obj(*gwsm, GFP_KERNEL);
if (!gwsm)
return -ENOMEM;
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
index ecf05cd64696..7e2db5d3a4d4 100644
--- a/fs/btrfs/defrag.c
+++ b/fs/btrfs/defrag.c
@@ -1091,7 +1091,7 @@ add:
}
/* Allocate new defrag_target_range */
- new = kmalloc(sizeof(*new), GFP_NOFS);
+ new = kmalloc_obj(*new, GFP_NOFS);
if (!new) {
btrfs_free_extent_map(em);
ret = -ENOMEM;
@@ -1206,7 +1206,7 @@ static int defrag_one_range(struct btrfs_inode *inode, u64 start, u32 len,
ASSERT(nr_pages <= CLUSTER_SIZE / PAGE_SIZE);
ASSERT(IS_ALIGNED(start, sectorsize) && IS_ALIGNED(len, sectorsize));
- folios = kcalloc(nr_pages, sizeof(struct folio *), GFP_NOFS);
+ folios = kzalloc_objs(struct folio *, nr_pages, GFP_NOFS);
if (!folios)
return -ENOMEM;
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 1739a0b29c49..d97bbbd045e0 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -349,7 +349,7 @@ static struct btrfs_delayed_item *btrfs_alloc_delayed_item(u16 data_len,
{
struct btrfs_delayed_item *item;
- item = kmalloc(struct_size(item, data, data_len), GFP_NOFS);
+ item = kmalloc_flex(*item, data, data_len, GFP_NOFS);
if (item) {
item->data_len = data_len;
item->type = type;
@@ -1384,7 +1384,7 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
{
struct btrfs_async_delayed_work *async_work;
- async_work = kmalloc(sizeof(*async_work), GFP_NOFS);
+ async_work = kmalloc_obj(*async_work, GFP_NOFS);
if (!async_work)
return -ENOMEM;
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index e8bc37453336..3766ff29fbbb 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -1027,7 +1027,7 @@ static int add_delayed_ref(struct btrfs_trans_handle *trans,
delayed_refs = &trans->transaction->delayed_refs;
if (btrfs_qgroup_full_accounting(fs_info) && !generic_ref->skip_qgroup) {
- record = kzalloc(sizeof(*record), GFP_NOFS);
+ record = kzalloc_obj(*record, GFP_NOFS);
if (!record) {
ret = -ENOMEM;
goto free_head_ref;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 13e400046c87..f6fa15a1193f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -605,7 +605,7 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info,
{
struct btrfs_root *root;
- root = kzalloc(sizeof(*root), flags);
+ root = kzalloc_obj(*root, flags);
if (!root)
return NULL;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 73571d5d3d5a..a9b0b596429d 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -200,7 +200,7 @@ static inline struct extent_changeset *extent_changeset_alloc(void)
{
struct extent_changeset *ret;
- ret = kmalloc(sizeof(*ret), GFP_KERNEL);
+ ret = kmalloc_obj(*ret, GFP_KERNEL);
if (!ret)
return NULL;
diff --git a/fs/btrfs/fiemap.c b/fs/btrfs/fiemap.c
index f2eaaef8422b..2e113f81a2d8 100644
--- a/fs/btrfs/fiemap.c
+++ b/fs/btrfs/fiemap.c
@@ -646,9 +646,8 @@ static int extent_fiemap(struct btrfs_inode *inode,
int ret;
cache.entries_size = PAGE_SIZE / sizeof(struct btrfs_fiemap_entry);
- cache.entries = kmalloc_array(cache.entries_size,
- sizeof(struct btrfs_fiemap_entry),
- GFP_KERNEL);
+ cache.entries = kmalloc_objs(struct btrfs_fiemap_entry,
+ cache.entries_size, GFP_KERNEL);
backref_ctx = btrfs_alloc_backref_share_check_ctx();
path = btrfs_alloc_path();
if (!cache.entries || !backref_ctx || !path) {
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 7bd715442f3e..927324a2175a 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -845,7 +845,7 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool async)
*/
int btrfs_alloc_dummy_sum(struct btrfs_bio *bbio)
{
- bbio->sums = kmalloc(sizeof(*bbio->sums), GFP_NOFS);
+ bbio->sums = kmalloc_obj(*bbio->sums, GFP_NOFS);
if (!bbio->sums)
return -ENOMEM;
bbio->sums->len = bbio->bio.bi_iter.bi_size;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index acaa3dbd2b7b..21cb45e23a6f 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2842,7 +2842,7 @@ static int add_falloc_range(struct list_head *head, u64 start, u64 len)
}
}
- range = kmalloc(sizeof(*range), GFP_KERNEL);
+ range = kmalloc_obj(*range, GFP_KERNEL);
if (!range)
return -ENOMEM;
range->start = start;
@@ -3572,7 +3572,7 @@ static loff_t find_desired_extent(struct file *file, loff_t offset, int whence)
*/
private = NULL;
} else if (!private) {
- private = kzalloc(sizeof(*private), GFP_KERNEL);
+ private = kzalloc_obj(*private, GFP_KERNEL);
/*
* No worries if memory allocation failed.
* The private structure is used only for speeding up multiple
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index cc075a460a22..ab22e4f9ffdd 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -388,7 +388,7 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
memset(io_ctl, 0, sizeof(struct btrfs_io_ctl));
- io_ctl->pages = kcalloc(num_pages, sizeof(struct page *), GFP_NOFS);
+ io_ctl->pages = kzalloc_objs(struct page *, num_pages, GFP_NOFS);
if (!io_ctl->pages)
return -ENOMEM;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5bbbce2224a1..da4be08d133e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -781,7 +781,7 @@ static int add_async_extent(struct async_chunk *cow, u64 start, u64 ram_size,
{
struct async_extent *async_extent;
- async_extent = kmalloc(sizeof(*async_extent), GFP_NOFS);
+ async_extent = kmalloc_obj(*async_extent, GFP_NOFS);
if (!async_extent)
return -ENOMEM;
ASSERT(ram_size < U32_MAX);
@@ -1692,7 +1692,7 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode,
const blk_opf_t write_flags = wbc_to_write_flags(wbc);
nofs_flag = memalloc_nofs_save();
- ctx = kvmalloc(struct_size(ctx, chunks, num_chunks), GFP_KERNEL);
+ ctx = kvmalloc_flex(*ctx, chunks, num_chunks, GFP_KERNEL);
memalloc_nofs_restore(nofs_flag);
if (!ctx)
return false;
@@ -2991,7 +2991,7 @@ int btrfs_writepage_cow_fixup(struct folio *folio)
if (folio_test_checked(folio))
return -EAGAIN;
- fixup = kzalloc(sizeof(*fixup), GFP_NOFS);
+ fixup = kzalloc_obj(*fixup, GFP_NOFS);
if (!fixup)
return -EAGAIN;
@@ -3967,7 +3967,7 @@ static int btrfs_init_file_extent_tree(struct btrfs_inode *inode)
if (btrfs_is_free_space_inode(inode))
return 0;
- inode->file_extent_tree = kmalloc(sizeof(struct extent_io_tree), GFP_KERNEL);
+ inode->file_extent_tree = kmalloc_obj(struct extent_io_tree, GFP_KERNEL);
if (!inode->file_extent_tree)
return -ENOMEM;
@@ -6221,7 +6221,7 @@ static int btrfs_opendir(struct inode *inode, struct file *file)
if (ret)
return ret;
- private = kzalloc(sizeof(struct btrfs_file_private), GFP_KERNEL);
+ private = kzalloc_obj(struct btrfs_file_private, GFP_KERNEL);
if (!private)
return -ENOMEM;
private->last_index = last_index;
@@ -8839,7 +8839,7 @@ static struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode
{
struct btrfs_delalloc_work *work;
- work = kmalloc(sizeof(*work), GFP_NOFS);
+ work = kmalloc_obj(*work, GFP_NOFS);
if (!work)
return NULL;
@@ -9538,7 +9538,7 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,
* needs longer time span.
*/
if (uring_ctx) {
- priv = kmalloc(sizeof(struct btrfs_encoded_read_private), GFP_NOFS);
+ priv = kmalloc_obj(struct btrfs_encoded_read_private, GFP_NOFS);
if (!priv)
return -ENOMEM;
} else {
@@ -9608,7 +9608,7 @@ ssize_t btrfs_encoded_read_regular(struct kiocb *iocb, struct iov_iter *iter,
ssize_t ret;
nr_pages = DIV_ROUND_UP(disk_io_size, PAGE_SIZE);
- pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
+ pages = kzalloc_objs(struct page *, nr_pages, GFP_NOFS);
if (!pages)
return -ENOMEM;
ret = btrfs_alloc_page_array(nr_pages, pages, false);
@@ -10092,7 +10092,7 @@ static int btrfs_add_swapfile_pin(struct inode *inode, void *ptr,
struct rb_node **p;
struct rb_node *parent = NULL;
- sp = kmalloc(sizeof(*sp), GFP_NOFS);
+ sp = kmalloc_obj(*sp, GFP_NOFS);
if (!sp)
return -ENOMEM;
sp->ptr = ptr;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a6cc2d3b414c..af8a9c698b07 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -726,15 +726,15 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
return -ETXTBSY;
}
- pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_KERNEL);
+ pending_snapshot = kzalloc_obj(*pending_snapshot, GFP_KERNEL);
if (!pending_snapshot)
return -ENOMEM;
ret = get_anon_bdev(&pending_snapshot->anon_dev);
if (ret < 0)
goto free_pending;
- pending_snapshot->root_item = kzalloc(sizeof(struct btrfs_root_item),
- GFP_KERNEL);
+ pending_snapshot->root_item = kzalloc_obj(struct btrfs_root_item,
+ GFP_KERNEL);
pending_snapshot->path = btrfs_alloc_path();
if (!pending_snapshot->root_item || !pending_snapshot->path) {
ret = -ENOMEM;
@@ -1958,7 +1958,7 @@ static int btrfs_ioctl_get_subvol_info(struct inode *inode, void __user *argp)
if (!path)
return -ENOMEM;
- subvol_info = kzalloc(sizeof(*subvol_info), GFP_KERNEL);
+ subvol_info = kzalloc_obj(*subvol_info, GFP_KERNEL);
if (!subvol_info) {
btrfs_free_path(path);
return -ENOMEM;
@@ -3423,7 +3423,7 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
goto out_unlock;
}
- bctl = kzalloc(sizeof(*bctl), GFP_KERNEL);
+ bctl = kzalloc_obj(*bctl, GFP_KERNEL);
if (!bctl) {
ret = -ENOMEM;
goto out_unlock;
@@ -3604,7 +3604,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
}
if (sa->assign) {
- prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
+ prealloc = kzalloc_obj(*prealloc, GFP_KERNEL);
if (!prealloc) {
ret = -ENOMEM;
goto out;
@@ -3924,7 +3924,7 @@ static long btrfs_ioctl_set_received_subvol_32(struct file *file,
if (IS_ERR(args32))
return PTR_ERR(args32);
- args64 = kmalloc(sizeof(*args64), GFP_KERNEL);
+ args64 = kmalloc_obj(*args64, GFP_KERNEL);
if (!args64) {
ret = -ENOMEM;
goto out;
@@ -4234,7 +4234,7 @@ static int _btrfs_ioctl_send(struct btrfs_root *root, void __user *argp, bool co
ret = copy_from_user(&args32, argp, sizeof(args32));
if (ret)
return -EFAULT;
- arg = kzalloc(sizeof(*arg), GFP_KERNEL);
+ arg = kzalloc_obj(*arg, GFP_KERNEL);
if (!arg)
return -ENOMEM;
arg->send_fd = args32.send_fd;
@@ -4588,7 +4588,7 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter,
int ret;
nr_pages = DIV_ROUND_UP(disk_io_size, PAGE_SIZE);
- pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
+ pages = kzalloc_objs(struct page *, nr_pages, GFP_NOFS);
if (!pages)
return -ENOMEM;
ret = btrfs_alloc_page_array(nr_pages, pages, 0);
@@ -4597,7 +4597,7 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter,
goto out_fail;
}
- priv = kmalloc(sizeof(*priv), GFP_NOFS);
+ priv = kmalloc_obj(*priv, GFP_NOFS);
if (!priv) {
ret = -ENOMEM;
goto out_fail;
@@ -4682,7 +4682,7 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
}
if (!data) {
- data = kzalloc(sizeof(*data), GFP_NOFS);
+ data = kzalloc_obj(*data, GFP_NOFS);
if (!data) {
ret = -ENOMEM;
goto out_acct;
@@ -4817,7 +4817,7 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
}
if (!data) {
- data = kzalloc(sizeof(*data), GFP_NOFS);
+ data = kzalloc_obj(*data, GFP_NOFS);
if (!data) {
ret = -ENOMEM;
goto out_acct;
diff --git a/fs/btrfs/lru_cache.c b/fs/btrfs/lru_cache.c
index fd88af17d8d9..f5a053b905e1 100644
--- a/fs/btrfs/lru_cache.c
+++ b/fs/btrfs/lru_cache.c
@@ -111,7 +111,7 @@ int btrfs_lru_cache_store(struct btrfs_lru_cache *cache,
struct list_head *head;
int ret;
- head = kmalloc(sizeof(*head), gfp);
+ head = kmalloc_obj(*head, gfp);
if (!head)
return -ENOMEM;
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index 8e20497afffe..e37d986f26be 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -88,7 +88,7 @@ struct list_head *lzo_alloc_workspace(struct btrfs_fs_info *fs_info)
{
struct workspace *workspace;
- workspace = kzalloc(sizeof(*workspace), GFP_KERNEL);
+ workspace = kzalloc_obj(*workspace, GFP_KERNEL);
if (!workspace)
return ERR_PTR(-ENOMEM);
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 38adadb936dc..6bd8739097d3 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -495,7 +495,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
struct btrfs_qgroup *prealloc;
struct btrfs_root *tree_root = fs_info->tree_root;
- prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
+ prealloc = kzalloc_obj(*prealloc, GFP_KERNEL);
if (!prealloc) {
ret = -ENOMEM;
goto out;
@@ -585,7 +585,7 @@ next1:
goto next2;
}
- list = kzalloc(sizeof(*list), GFP_KERNEL);
+ list = kzalloc_obj(*list, GFP_KERNEL);
if (!list) {
ret = -ENOMEM;
goto out;
@@ -1140,7 +1140,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
/* We should not have a stray @prealloc pointer. */
ASSERT(prealloc == NULL);
- prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS);
+ prealloc = kzalloc_obj(*prealloc, GFP_NOFS);
if (unlikely(!prealloc)) {
ret = -ENOMEM;
btrfs_abort_transaction(trans, ret);
@@ -1197,7 +1197,7 @@ out_add_root:
}
ASSERT(prealloc == NULL);
- prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS);
+ prealloc = kzalloc_obj(*prealloc, GFP_NOFS);
if (!prealloc) {
ret = -ENOMEM;
goto out_free_path;
@@ -1693,7 +1693,7 @@ int btrfs_create_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
goto out;
}
- prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS);
+ prealloc = kzalloc_obj(*prealloc, GFP_NOFS);
if (!prealloc) {
ret = -ENOMEM;
goto out;
@@ -2147,7 +2147,7 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans, u64 bytenr,
if (!btrfs_qgroup_full_accounting(fs_info) || bytenr == 0 || num_bytes == 0)
return 0;
- record = kzalloc(sizeof(*record), GFP_NOFS);
+ record = kzalloc_obj(*record, GFP_NOFS);
if (!record)
return -ENOMEM;
@@ -3346,7 +3346,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
if (!btrfs_qgroup_enabled(fs_info))
return 0;
- prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS);
+ prealloc = kzalloc_obj(*prealloc, GFP_NOFS);
if (!prealloc)
return -ENOMEM;
@@ -3428,16 +3428,15 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
}
ret = 0;
- qlist_prealloc = kcalloc(inherit->num_qgroups,
- sizeof(struct btrfs_qgroup_list *),
- GFP_NOFS);
+ qlist_prealloc = kzalloc_objs(struct btrfs_qgroup_list *,
+ inherit->num_qgroups, GFP_NOFS);
if (!qlist_prealloc) {
ret = -ENOMEM;
goto out;
}
for (int i = 0; i < inherit->num_qgroups; i++) {
- qlist_prealloc[i] = kzalloc(sizeof(struct btrfs_qgroup_list),
- GFP_NOFS);
+ qlist_prealloc[i] = kzalloc_obj(struct btrfs_qgroup_list,
+ GFP_NOFS);
if (!qlist_prealloc[i]) {
ret = -ENOMEM;
goto out;
@@ -4753,7 +4752,7 @@ int btrfs_qgroup_add_swapped_blocks(struct btrfs_root *subvol_root,
return -EUCLEAN;
}
- block = kmalloc(sizeof(*block), GFP_NOFS);
+ block = kmalloc_obj(*block, GFP_NOFS);
if (!block) {
ret = -ENOMEM;
goto out;
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index baadaaa189c0..8112122c13e6 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -208,7 +208,7 @@ int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info)
* Try harder to allocate and fallback to vmalloc to lower the chance
* of a failing mount.
*/
- table = kvzalloc(struct_size(table, table, num_entries), GFP_KERNEL);
+ table = kvzalloc_flex(*table, table, num_entries, GFP_KERNEL);
if (!table)
return -ENOMEM;
@@ -1090,13 +1090,15 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info,
ASSERT(real_stripes >= 2);
ASSERT(real_stripes <= U8_MAX);
- rbio = kzalloc(sizeof(*rbio), GFP_NOFS);
+ rbio = kzalloc_obj(*rbio, GFP_NOFS);
if (!rbio)
return ERR_PTR(-ENOMEM);
- rbio->stripe_pages = kcalloc(num_pages, sizeof(struct page *),
- GFP_NOFS);
- rbio->bio_paddrs = kcalloc(num_sectors * sector_nsteps, sizeof(phys_addr_t), GFP_NOFS);
- rbio->stripe_paddrs = kcalloc(num_sectors * sector_nsteps, sizeof(phys_addr_t), GFP_NOFS);
+ rbio->stripe_pages = kzalloc_objs(struct page *, num_pages, GFP_NOFS);
+ rbio->bio_paddrs = kzalloc_objs(phys_addr_t,
+ num_sectors * sector_nsteps, GFP_NOFS);
+ rbio->stripe_paddrs = kzalloc_objs(phys_addr_t,
+ num_sectors * sector_nsteps,
+ GFP_NOFS);
rbio->finish_pointers = kcalloc(real_stripes, sizeof(void *), GFP_NOFS);
rbio->error_bitmap = bitmap_zalloc(num_sectors, GFP_NOFS);
rbio->stripe_uptodate_bitmap = bitmap_zalloc(num_sectors, GFP_NOFS);
diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
index e9224145d754..f78369ff2a66 100644
--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -249,8 +249,8 @@ static struct block_entry *add_block_entry(struct btrfs_fs_info *fs_info,
struct block_entry *be = NULL, *exist;
struct root_entry *re = NULL;
- re = kzalloc(sizeof(struct root_entry), GFP_NOFS);
- be = kzalloc(sizeof(struct block_entry), GFP_NOFS);
+ re = kzalloc_obj(struct root_entry, GFP_NOFS);
+ be = kzalloc_obj(struct block_entry, GFP_NOFS);
if (!be || !re) {
kfree(re);
kfree(be);
@@ -298,7 +298,7 @@ static int add_tree_block(struct btrfs_fs_info *fs_info, u64 ref_root,
struct root_entry *re;
struct ref_entry *ref = NULL, *exist;
- ref = kmalloc(sizeof(struct ref_entry), GFP_NOFS);
+ ref = kmalloc_obj(struct ref_entry, GFP_NOFS);
if (!ref)
return -ENOMEM;
@@ -343,7 +343,7 @@ static int add_shared_data_ref(struct btrfs_fs_info *fs_info,
struct block_entry *be;
struct ref_entry *ref;
- ref = kzalloc(sizeof(struct ref_entry), GFP_NOFS);
+ ref = kzalloc_obj(struct ref_entry, GFP_NOFS);
if (!ref)
return -ENOMEM;
be = add_block_entry(fs_info, bytenr, num_bytes, 0);
@@ -378,7 +378,7 @@ static int add_extent_data_ref(struct btrfs_fs_info *fs_info,
u64 offset = btrfs_extent_data_ref_offset(leaf, dref);
u32 num_refs = btrfs_extent_data_ref_count(leaf, dref);
- ref = kzalloc(sizeof(struct ref_entry), GFP_NOFS);
+ ref = kzalloc_obj(struct ref_entry, GFP_NOFS);
if (!ref)
return -ENOMEM;
be = add_block_entry(fs_info, bytenr, num_bytes, ref_root);
@@ -680,8 +680,8 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
}
metadata = owner < BTRFS_FIRST_FREE_OBJECTID;
- ref = kzalloc(sizeof(struct ref_entry), GFP_NOFS);
- ra = kmalloc(sizeof(struct ref_action), GFP_NOFS);
+ ref = kzalloc_obj(struct ref_entry, GFP_NOFS);
+ ra = kmalloc_obj(struct ref_action, GFP_NOFS);
if (!ra || !ref) {
kfree(ref);
kfree(ra);
@@ -755,7 +755,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
struct root_entry *tmp;
if (!parent) {
- re = kmalloc(sizeof(struct root_entry), GFP_NOFS);
+ re = kmalloc_obj(struct root_entry, GFP_NOFS);
if (!re) {
kfree(ref);
kfree(ra);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index fcd0a2ba3554..95db7c48fbad 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -483,7 +483,7 @@ static int __add_reloc_root(struct btrfs_root *root)
struct mapping_node *node;
struct reloc_control *rc = fs_info->reloc_ctl;
- node = kmalloc(sizeof(*node), GFP_NOFS);
+ node = kmalloc_obj(*node, GFP_NOFS);
if (!node)
return -ENOMEM;
@@ -3115,7 +3115,7 @@ static int add_tree_block(struct reloc_control *rc,
BUG_ON(level == -1);
- block = kmalloc(sizeof(*block), GFP_NOFS);
+ block = kmalloc_obj(*block, GFP_NOFS);
if (!block)
return -ENOMEM;
@@ -3813,7 +3813,7 @@ static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
{
struct reloc_control *rc;
- rc = kzalloc(sizeof(*rc), GFP_NOFS);
+ rc = kzalloc_obj(*rc, GFP_NOFS);
if (!rc)
return NULL;
@@ -4042,7 +4042,7 @@ static int copy_remapped_data(struct btrfs_fs_info *fs_info, u64 old_addr,
struct reloc_io_private priv;
unsigned int nr_pages = DIV_ROUND_UP(length, PAGE_SIZE);
- pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
+ pages = kzalloc_objs(struct page *, nr_pages, GFP_NOFS);
if (!pages)
return -ENOMEM;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 2a64e2d50ced..dfed8eaf938e 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -373,9 +373,8 @@ static int init_scrub_stripe(struct btrfs_fs_info *fs_info,
if (ret < 0)
goto error;
- stripe->sectors = kcalloc(stripe->nr_sectors,
- sizeof(struct scrub_sector_verification),
- GFP_KERNEL);
+ stripe->sectors = kzalloc_objs(struct scrub_sector_verification,
+ stripe->nr_sectors, GFP_KERNEL);
if (!stripe->sectors)
goto error;
@@ -456,7 +455,7 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx(
/* Since sctx has inline 128 stripes, it can go beyond 64K easily. Use
* kvzalloc().
*/
- sctx = kvzalloc(sizeof(*sctx), GFP_KERNEL);
+ sctx = kvzalloc_obj(*sctx, GFP_KERNEL);
if (!sctx)
goto nomem;
refcount_set(&sctx->refs, 1);
@@ -2474,9 +2473,9 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
if (profile & BTRFS_BLOCK_GROUP_RAID56_MASK) {
ASSERT(sctx->raid56_data_stripes == NULL);
- sctx->raid56_data_stripes = kcalloc(nr_data_stripes(map),
- sizeof(struct scrub_stripe),
- GFP_KERNEL);
+ sctx->raid56_data_stripes = kzalloc_objs(struct scrub_stripe,
+ nr_data_stripes(map),
+ GFP_KERNEL);
if (!sctx->raid56_data_stripes) {
ret = -ENOMEM;
goto out;
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 3dcfdba018b5..23b0b06ac71c 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -450,7 +450,7 @@ static struct fs_path *fs_path_alloc(void)
{
struct fs_path *p;
- p = kmalloc(sizeof(*p), GFP_KERNEL);
+ p = kmalloc_obj(*p, GFP_KERNEL);
if (!p)
return NULL;
init_path(p);
@@ -1429,7 +1429,7 @@ static void store_backref_cache(u64 leaf_bytenr, const struct ulist *root_ids,
* fs_info->commit_root_sem (at iterate_extent_inodes()), so must do a
* NOFS allocation.
*/
- new_entry = kmalloc(sizeof(struct backref_cache_entry), GFP_NOFS);
+ new_entry = kmalloc_obj(struct backref_cache_entry, GFP_NOFS);
/* No worries, cache is optional. */
if (!new_entry)
return;
@@ -2743,7 +2743,7 @@ static int cache_dir_utimes(struct send_ctx *sctx, u64 dir, u64 gen)
return 0;
/* Caching is optional, don't fail if we can't allocate memory. */
- entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kmalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return send_utimes(sctx, dir, gen);
@@ -2870,7 +2870,7 @@ static void cache_dir_created(struct send_ctx *sctx, u64 dir)
int ret;
/* Caching is optional, ignore any failures. */
- entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kmalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return;
@@ -2974,7 +2974,7 @@ static struct recorded_ref *recorded_ref_alloc(void)
{
struct recorded_ref *ref;
- ref = kzalloc(sizeof(*ref), GFP_KERNEL);
+ ref = kzalloc_obj(*ref, GFP_KERNEL);
if (!ref)
return NULL;
RB_CLEAR_NODE(&ref->node);
@@ -3083,7 +3083,7 @@ static struct orphan_dir_info *add_orphan_dir_info(struct send_ctx *sctx,
return entry;
}
- odi = kmalloc(sizeof(*odi), GFP_KERNEL);
+ odi = kmalloc_obj(*odi, GFP_KERNEL);
if (!odi)
return ERR_PTR(-ENOMEM);
odi->ino = dir_ino;
@@ -3284,7 +3284,7 @@ static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized)
struct rb_node *parent = NULL;
struct waiting_dir_move *entry, *dm;
- dm = kmalloc(sizeof(*dm), GFP_KERNEL);
+ dm = kmalloc_obj(*dm, GFP_KERNEL);
if (!dm)
return -ENOMEM;
dm->ino = ino;
@@ -3352,7 +3352,7 @@ static int add_pending_dir_move(struct send_ctx *sctx,
int exists = 0;
int ret;
- pm = kmalloc(sizeof(*pm), GFP_KERNEL);
+ pm = kmalloc_obj(*pm, GFP_KERNEL);
if (!pm)
return -ENOMEM;
pm->parent_ino = parent_ino;
@@ -8035,7 +8035,7 @@ long btrfs_ioctl_send(struct btrfs_root *send_root, const struct btrfs_ioctl_sen
goto out;
}
- sctx = kzalloc(sizeof(struct send_ctx), GFP_KERNEL);
+ sctx = kzalloc_obj(struct send_ctx, GFP_KERNEL);
if (!sctx) {
ret = -ENOMEM;
goto out;
@@ -8097,9 +8097,9 @@ long btrfs_ioctl_send(struct btrfs_root *send_root, const struct btrfs_ioctl_sen
goto out;
}
send_buf_num_pages = sctx->send_max_size >> PAGE_SHIFT;
- sctx->send_buf_pages = kcalloc(send_buf_num_pages,
- sizeof(*sctx->send_buf_pages),
- GFP_KERNEL);
+ sctx->send_buf_pages = kzalloc_objs(*sctx->send_buf_pages,
+ send_buf_num_pages,
+ GFP_KERNEL);
if (!sctx->send_buf_pages) {
ret = -ENOMEM;
goto out;
@@ -8117,9 +8117,9 @@ long btrfs_ioctl_send(struct btrfs_root *send_root, const struct btrfs_ioctl_sen
goto out;
}
- sctx->clone_roots = kvcalloc(arg->clone_sources_count + 1,
- sizeof(*sctx->clone_roots),
- GFP_KERNEL);
+ sctx->clone_roots = kvzalloc_objs(*sctx->clone_roots,
+ arg->clone_sources_count + 1,
+ GFP_KERNEL);
if (!sctx->clone_roots) {
ret = -ENOMEM;
goto out;
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index bb5aac7ee9d2..52a267a5dd80 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -266,7 +266,7 @@ static int create_space_info_sub_group(struct btrfs_space_info *parent, u64 flag
"parent->subgroup_id=%d", parent->subgroup_id);
ASSERT(id != BTRFS_SUB_GROUP_PRIMARY, "id=%d", id);
- sub_group = kzalloc(sizeof(*sub_group), GFP_NOFS);
+ sub_group = kzalloc_obj(*sub_group, GFP_NOFS);
if (!sub_group)
return -ENOMEM;
@@ -289,7 +289,7 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
struct btrfs_space_info *space_info;
int ret = 0;
- space_info = kzalloc(sizeof(*space_info), GFP_NOFS);
+ space_info = kzalloc_obj(*space_info, GFP_NOFS);
if (!space_info)
return -ENOMEM;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index d64d303b6edc..3f9523563259 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2054,7 +2054,7 @@ static int btrfs_get_tree_subvol(struct fs_context *fc)
* of the fs_info (locks and such) to make cleanup easier if we find a
* superblock with our given fs_devices later on at sget() time.
*/
- fs_info = kvzalloc(sizeof(struct btrfs_fs_info), GFP_KERNEL);
+ fs_info = kvzalloc_obj(struct btrfs_fs_info, GFP_KERNEL);
if (!fs_info)
return -ENOMEM;
@@ -2173,7 +2173,7 @@ static int btrfs_init_fs_context(struct fs_context *fc)
{
struct btrfs_fs_context *ctx;
- ctx = kzalloc(sizeof(struct btrfs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct btrfs_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 27bfb7b55ec4..f62278f0c191 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -1833,7 +1833,7 @@ void btrfs_sysfs_add_block_group_type(struct btrfs_block_group *cache)
*/
nofs_flag = memalloc_nofs_save();
- rkobj = kzalloc(sizeof(*rkobj), GFP_NOFS);
+ rkobj = kzalloc_obj(*rkobj, GFP_NOFS);
if (!rkobj) {
memalloc_nofs_restore(nofs_flag);
btrfs_warn(cache->fs_info,
@@ -2597,7 +2597,7 @@ int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info)
if (fs_info->qgroups_kobj)
return 0;
- fs_info->qgroups_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);
+ fs_info->qgroups_kobj = kzalloc_obj(struct kobject, GFP_KERNEL);
if (!fs_info->qgroups_kobj)
return -ENOMEM;
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 7f13c05d3736..c5b1bc0f7f91 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -98,7 +98,7 @@ struct btrfs_device *btrfs_alloc_dummy_device(struct btrfs_fs_info *fs_info)
{
struct btrfs_device *dev;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev)
return ERR_PTR(-ENOMEM);
@@ -117,21 +117,19 @@ static void btrfs_free_dummy_device(struct btrfs_device *dev)
struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize)
{
- struct btrfs_fs_info *fs_info = kzalloc(sizeof(struct btrfs_fs_info),
- GFP_KERNEL);
+ struct btrfs_fs_info *fs_info = kzalloc_obj(struct btrfs_fs_info,
+ GFP_KERNEL);
if (!fs_info)
return fs_info;
- fs_info->fs_devices = kzalloc(sizeof(struct btrfs_fs_devices),
- GFP_KERNEL);
+ fs_info->fs_devices = kzalloc_obj(struct btrfs_fs_devices, GFP_KERNEL);
if (!fs_info->fs_devices) {
kfree(fs_info);
return NULL;
}
INIT_LIST_HEAD(&fs_info->fs_devices->devices);
- fs_info->super_copy = kzalloc(sizeof(struct btrfs_super_block),
- GFP_KERNEL);
+ fs_info->super_copy = kzalloc_obj(struct btrfs_super_block, GFP_KERNEL);
if (!fs_info->super_copy) {
kfree(fs_info->fs_devices);
kfree(fs_info);
@@ -208,11 +206,10 @@ btrfs_alloc_dummy_block_group(struct btrfs_fs_info *fs_info,
{
struct btrfs_block_group *cache;
- cache = kzalloc(sizeof(*cache), GFP_KERNEL);
+ cache = kzalloc_obj(*cache, GFP_KERNEL);
if (!cache)
return NULL;
- cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl),
- GFP_KERNEL);
+ cache->free_space_ctl = kzalloc_obj(*cache->free_space_ctl, GFP_KERNEL);
if (!cache->free_space_ctl) {
kfree(cache);
return NULL;
diff --git a/fs/btrfs/tests/delayed-refs-tests.c b/fs/btrfs/tests/delayed-refs-tests.c
index e2248acb906b..fdc183ebc6da 100644
--- a/fs/btrfs/tests/delayed-refs-tests.c
+++ b/fs/btrfs/tests/delayed-refs-tests.c
@@ -985,7 +985,7 @@ int btrfs_test_delayed_refs(u32 sectorsize, u32 nodesize)
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
}
- transaction = kmalloc(sizeof(*transaction), GFP_KERNEL);
+ transaction = kmalloc_obj(*transaction, GFP_KERNEL);
if (!transaction) {
test_std_err(TEST_ALLOC_TRANSACTION);
ret = -ENOMEM;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 463238ca8a4d..7ef8c9b7dfc1 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -315,7 +315,7 @@ loop:
*/
BUG_ON(type == TRANS_JOIN_NOLOCK);
- cur_trans = kmalloc(sizeof(*cur_trans), GFP_NOFS);
+ cur_trans = kmalloc_obj(*cur_trans, GFP_NOFS);
if (!cur_trans)
return -ENOMEM;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index e1bd03ebfd98..780a06d59240 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -5928,7 +5928,7 @@ again:
if (ret)
goto out;
if (ctx->log_new_dentries) {
- dir_elem = kmalloc(sizeof(*dir_elem), GFP_NOFS);
+ dir_elem = kmalloc_obj(*dir_elem, GFP_NOFS);
if (!dir_elem) {
ret = -ENOMEM;
goto out;
@@ -6122,7 +6122,7 @@ static int add_conflicting_inode(struct btrfs_trans_handle *trans,
return ret;
/* Conflicting inode is a directory, so we'll log its parent. */
- ino_elem = kmalloc(sizeof(*ino_elem), GFP_NOFS);
+ ino_elem = kmalloc_obj(*ino_elem, GFP_NOFS);
if (!ino_elem)
return -ENOMEM;
ino_elem->ino = ino;
@@ -6180,7 +6180,7 @@ static int add_conflicting_inode(struct btrfs_trans_handle *trans,
btrfs_add_delayed_iput(inode);
- ino_elem = kmalloc(sizeof(*ino_elem), GFP_NOFS);
+ ino_elem = kmalloc_obj(*ino_elem, GFP_NOFS);
if (!ino_elem)
return -ENOMEM;
ino_elem->ino = ino;
diff --git a/fs/btrfs/tree-mod-log.c b/fs/btrfs/tree-mod-log.c
index 9e8cb3b7c064..603c1457130e 100644
--- a/fs/btrfs/tree-mod-log.c
+++ b/fs/btrfs/tree-mod-log.c
@@ -243,7 +243,7 @@ static struct tree_mod_elem *alloc_tree_mod_elem(const struct extent_buffer *eb,
ASSERT(op != BTRFS_MOD_LOG_MOVE_KEYS);
ASSERT(op != BTRFS_MOD_LOG_ROOT_REPLACE);
- tm = kzalloc(sizeof(*tm), GFP_NOFS);
+ tm = kzalloc_obj(*tm, GFP_NOFS);
if (!tm)
return NULL;
@@ -301,7 +301,7 @@ static struct tree_mod_elem *tree_mod_log_alloc_move(const struct extent_buffer
{
struct tree_mod_elem *tm;
- tm = kzalloc(sizeof(*tm), GFP_NOFS);
+ tm = kzalloc_obj(*tm, GFP_NOFS);
if (!tm)
return ERR_PTR(-ENOMEM);
@@ -328,7 +328,7 @@ int btrfs_tree_mod_log_insert_move(const struct extent_buffer *eb,
if (!tree_mod_need_log(eb->fs_info, eb))
return 0;
- tm_list = kcalloc(nr_items, sizeof(struct tree_mod_elem *), GFP_NOFS);
+ tm_list = kzalloc_objs(struct tree_mod_elem *, nr_items, GFP_NOFS);
if (!tm_list) {
ret = -ENOMEM;
goto lock;
@@ -439,8 +439,8 @@ int btrfs_tree_mod_log_insert_root(struct extent_buffer *old_root,
if (log_removal && btrfs_header_level(old_root) > 0) {
nritems = btrfs_header_nritems(old_root);
- tm_list = kcalloc(nritems, sizeof(struct tree_mod_elem *),
- GFP_NOFS);
+ tm_list = kzalloc_objs(struct tree_mod_elem *, nritems,
+ GFP_NOFS);
if (!tm_list) {
ret = -ENOMEM;
goto lock;
@@ -455,7 +455,7 @@ int btrfs_tree_mod_log_insert_root(struct extent_buffer *old_root,
}
}
- tm = kzalloc(sizeof(*tm), GFP_NOFS);
+ tm = kzalloc_obj(*tm, GFP_NOFS);
if (!tm) {
ret = -ENOMEM;
goto lock;
@@ -595,8 +595,7 @@ int btrfs_tree_mod_log_eb_copy(struct extent_buffer *dst,
if (btrfs_header_level(dst) == 0 && btrfs_header_level(src) == 0)
return 0;
- tm_list = kcalloc(nr_items * 2, sizeof(struct tree_mod_elem *),
- GFP_NOFS);
+ tm_list = kzalloc_objs(struct tree_mod_elem *, nr_items * 2, GFP_NOFS);
if (!tm_list) {
ret = -ENOMEM;
goto lock;
@@ -714,7 +713,7 @@ int btrfs_tree_mod_log_free_eb(struct extent_buffer *eb)
return 0;
nritems = btrfs_header_nritems(eb);
- tm_list = kcalloc(nritems, sizeof(struct tree_mod_elem *), GFP_NOFS);
+ tm_list = kzalloc_objs(struct tree_mod_elem *, nritems, GFP_NOFS);
if (!tm_list) {
ret = -ENOMEM;
goto lock;
diff --git a/fs/btrfs/ulist.c b/fs/btrfs/ulist.c
index 7e16a253fb35..7898076ce41c 100644
--- a/fs/btrfs/ulist.c
+++ b/fs/btrfs/ulist.c
@@ -98,7 +98,7 @@ void ulist_reinit(struct ulist *ulist)
*/
struct ulist *ulist_alloc(gfp_t gfp_mask)
{
- struct ulist *ulist = kmalloc(sizeof(*ulist), gfp_mask);
+ struct ulist *ulist = kmalloc_obj(*ulist, gfp_mask);
if (!ulist)
return NULL;
@@ -111,7 +111,7 @@ struct ulist *ulist_alloc(gfp_t gfp_mask)
void ulist_prealloc(struct ulist *ulist, gfp_t gfp_mask)
{
if (!ulist->prealloc)
- ulist->prealloc = kzalloc(sizeof(*ulist->prealloc), gfp_mask);
+ ulist->prealloc = kzalloc_obj(*ulist->prealloc, gfp_mask);
}
/*
@@ -219,7 +219,7 @@ int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
node = ulist->prealloc;
ulist->prealloc = NULL;
} else {
- node = kmalloc(sizeof(*node), gfp_mask);
+ node = kmalloc_obj(*node, gfp_mask);
if (!node)
return -ENOMEM;
}
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 50f7aae70418..71ff7006ca6b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -382,7 +382,7 @@ static struct btrfs_fs_devices *alloc_fs_devices(const u8 *fsid)
{
struct btrfs_fs_devices *fs_devs;
- fs_devs = kzalloc(sizeof(*fs_devs), GFP_KERNEL);
+ fs_devs = kzalloc_obj(*fs_devs, GFP_KERNEL);
if (!fs_devs)
return ERR_PTR(-ENOMEM);
@@ -4456,7 +4456,7 @@ again:
if (chunk_type & BTRFS_BLOCK_GROUP_METADATA_REMAP) {
mutex_unlock(&fs_info->reclaim_bgs_lock);
- rci = kmalloc(sizeof(struct remap_chunk_info), GFP_NOFS);
+ rci = kmalloc_obj(struct remap_chunk_info, GFP_NOFS);
if (!rci) {
ret = -ENOMEM;
goto error;
@@ -5004,7 +5004,7 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
return 0;
}
- bctl = kzalloc(sizeof(*bctl), GFP_NOFS);
+ bctl = kzalloc_obj(*bctl, GFP_NOFS);
if (!bctl)
return -ENOMEM;
@@ -6338,7 +6338,7 @@ struct btrfs_io_context *alloc_btrfs_io_context(struct btrfs_fs_info *fs_info,
{
struct btrfs_io_context *bioc;
- bioc = kzalloc(struct_size(bioc, stripes, total_stripes), GFP_NOFS);
+ bioc = kzalloc_flex(*bioc, stripes, total_stripes, GFP_NOFS);
if (!bioc)
return NULL;
@@ -6471,7 +6471,7 @@ struct btrfs_discard_stripe *btrfs_map_discard(struct btrfs_fs_info *fs_info,
stripe_nr /= map->num_stripes;
}
- stripes = kcalloc(*num_stripes, sizeof(*stripes), GFP_NOFS);
+ stripes = kzalloc_objs(*stripes, *num_stripes, GFP_NOFS);
if (!stripes) {
ret = -ENOMEM;
goto out_free_map;
@@ -7202,7 +7202,7 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
if (WARN_ON(!devid && !fs_info))
return ERR_PTR(-EINVAL);
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev)
return ERR_PTR(-ENOMEM);
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index 0a8fcee16428..5a0913a31991 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -75,7 +75,7 @@ struct list_head *zlib_alloc_workspace(struct btrfs_fs_info *fs_info, unsigned i
struct workspace *workspace;
int workspacesize;
- workspace = kzalloc(sizeof(*workspace), GFP_KERNEL);
+ workspace = kzalloc_obj(*workspace, GFP_KERNEL);
if (!workspace)
return ERR_PTR(-ENOMEM);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index ad8621587fd2..fcdfb831b484 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -377,7 +377,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
if (device->zone_info)
return 0;
- zone_info = kzalloc(sizeof(*zone_info), GFP_KERNEL);
+ zone_info = kzalloc_obj(*zone_info, GFP_KERNEL);
if (!zone_info)
return -ENOMEM;
@@ -454,7 +454,8 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
goto out;
}
- zones = kvcalloc(BTRFS_REPORT_NR_ZONES, sizeof(struct blk_zone), GFP_KERNEL);
+ zones = kvzalloc_objs(struct blk_zone, BTRFS_REPORT_NR_ZONES,
+ GFP_KERNEL);
if (!zones) {
ret = -ENOMEM;
goto out;
diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
index 32fd7f5454d3..a7a41dd320d9 100644
--- a/fs/btrfs/zstd.c
+++ b/fs/btrfs/zstd.c
@@ -185,7 +185,7 @@ int zstd_alloc_workspace_manager(struct btrfs_fs_info *fs_info)
struct list_head *ws;
ASSERT(fs_info->compr_wsm[BTRFS_COMPRESS_ZSTD] == NULL);
- zwsm = kzalloc(sizeof(*zwsm), GFP_KERNEL);
+ zwsm = kzalloc_obj(*zwsm, GFP_KERNEL);
if (!zwsm)
return -ENOMEM;
zstd_calc_ws_mem_sizes();
@@ -373,7 +373,7 @@ struct list_head *zstd_alloc_workspace(struct btrfs_fs_info *fs_info, int level)
const u32 blocksize = fs_info->sectorsize;
struct workspace *workspace;
- workspace = kzalloc(sizeof(*workspace), GFP_KERNEL);
+ workspace = kzalloc_obj(*workspace, GFP_KERNEL);
if (!workspace)
return ERR_PTR(-ENOMEM);
diff --git a/fs/buffer.c b/fs/buffer.c
index ed724a902657..22b43642ba57 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -358,8 +358,7 @@ static void end_buffer_async_read_io(struct buffer_head *bh, int uptodate)
/* Decrypt (with fscrypt) and/or verify (with fsverity) if needed. */
if (uptodate && (decrypt || vi)) {
- struct postprocess_bh_ctx *ctx =
- kmalloc(sizeof(*ctx), GFP_ATOMIC);
+ struct postprocess_bh_ctx *ctx = kmalloc_obj(*ctx, GFP_ATOMIC);
if (ctx) {
ctx->bh = bh;
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 1806bff8e59b..99795864bcb3 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -102,7 +102,7 @@ static int cachefiles_daemon_open(struct inode *inode, struct file *file)
return -EBUSY;
/* allocate a cache record */
- cache = kzalloc(sizeof(struct cachefiles_cache), GFP_KERNEL);
+ cache = kzalloc_obj(struct cachefiles_cache, GFP_KERNEL);
if (!cache) {
cachefiles_open = 0;
return -ENOMEM;
diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c
index 3e0576d9db1d..7b9d547ecee6 100644
--- a/fs/cachefiles/io.c
+++ b/fs/cachefiles/io.c
@@ -132,7 +132,7 @@ static int cachefiles_read(struct netfs_cache_resources *cres,
}
ret = -ENOMEM;
- ki = kzalloc(sizeof(struct cachefiles_kiocb), GFP_KERNEL);
+ ki = kzalloc_obj(struct cachefiles_kiocb, GFP_KERNEL);
if (!ki)
goto presubmission_error;
@@ -298,7 +298,7 @@ int __cachefiles_write(struct cachefiles_object *object,
file, file_inode(file)->i_ino, start_pos, len,
i_size_read(file_inode(file)));
- ki = kzalloc(sizeof(struct cachefiles_kiocb), GFP_KERNEL);
+ ki = kzalloc_obj(struct cachefiles_kiocb, GFP_KERNEL);
if (!ki) {
if (term_func)
term_func(term_func_priv, -ENOMEM);
diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c
index a7ed86fa98bb..b251fff2bed0 100644
--- a/fs/cachefiles/ondemand.c
+++ b/fs/cachefiles/ondemand.c
@@ -734,8 +734,8 @@ int cachefiles_ondemand_init_obj_info(struct cachefiles_object *object,
if (!cachefiles_in_ondemand_mode(volume->cache))
return 0;
- object->ondemand = kzalloc(sizeof(struct cachefiles_ondemand_info),
- GFP_KERNEL);
+ object->ondemand = kzalloc_obj(struct cachefiles_ondemand_info,
+ GFP_KERNEL);
if (!object->ondemand)
return -ENOMEM;
diff --git a/fs/cachefiles/volume.c b/fs/cachefiles/volume.c
index 90ba926f488e..655de0cef530 100644
--- a/fs/cachefiles/volume.c
+++ b/fs/cachefiles/volume.c
@@ -28,7 +28,7 @@ void cachefiles_acquire_volume(struct fscache_volume *vcookie)
_enter("");
- volume = kzalloc(sizeof(struct cachefiles_volume), GFP_KERNEL);
+ volume = kzalloc_obj(struct cachefiles_volume, GFP_KERNEL);
if (!volume)
return;
volume->vcookie = vcookie;
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index ce09ff3e020f..e87b3bb94ee8 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -470,7 +470,7 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file)
if (rreq->origin != NETFS_READAHEAD)
return 0;
- priv = kzalloc(sizeof(*priv), GFP_NOFS);
+ priv = kzalloc_obj(*priv, GFP_NOFS);
if (!priv)
return -ENOMEM;
@@ -1186,9 +1186,7 @@ static inline
void __ceph_allocate_page_array(struct ceph_writeback_ctl *ceph_wbc,
unsigned int max_pages)
{
- ceph_wbc->pages = kmalloc_array(max_pages,
- sizeof(*ceph_wbc->pages),
- GFP_NOFS);
+ ceph_wbc->pages = kmalloc_objs(*ceph_wbc->pages, max_pages, GFP_NOFS);
if (!ceph_wbc->pages) {
ceph_wbc->from_pool = true;
ceph_wbc->pages = mempool_alloc(ceph_wb_pagevec_pool, GFP_NOFS);
@@ -2506,7 +2504,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
}
pool_ns_len = pool_ns ? pool_ns->len : 0;
- perm = kmalloc(struct_size(perm, pool_ns, pool_ns_len + 1), GFP_NOFS);
+ perm = kmalloc_flex(*perm, pool_ns, pool_ns_len + 1, GFP_NOFS);
if (!perm) {
err = -ENOMEM;
goto out_unlock;
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 2f663972da99..5d7c2ffae8fa 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2395,7 +2395,7 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
mutex_lock(&mdsc->mutex);
max_sessions = mdsc->max_sessions;
- sessions = kcalloc(max_sessions, sizeof(s), GFP_KERNEL);
+ sessions = kzalloc_objs(s, max_sessions, GFP_KERNEL);
if (!sessions) {
mutex_unlock(&mdsc->mutex);
err = -ENOMEM;
diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c
index 9a115282f67d..643c8ba28ae7 100644
--- a/fs/ceph/crypto.c
+++ b/fs/ceph/crypto.c
@@ -50,7 +50,7 @@ static int ceph_crypt_set_context(struct inode *inode, const void *ctx,
if (len > FSCRYPT_SET_CONTEXT_MAX_SIZE)
return -EINVAL;
- cfa = kzalloc(sizeof(*cfa), GFP_KERNEL);
+ cfa = kzalloc_obj(*cfa, GFP_KERNEL);
if (!cfa)
return -ENOMEM;
@@ -112,7 +112,7 @@ int ceph_fscrypt_prepare_context(struct inode *dir, struct inode *inode,
if (!encrypted)
return 0;
- as->fscrypt_auth = kzalloc(sizeof(*as->fscrypt_auth), GFP_KERNEL);
+ as->fscrypt_auth = kzalloc_obj(*as->fscrypt_auth, GFP_KERNEL);
if (!as->fscrypt_auth)
return -ENOMEM;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 72cc67ab4ead..fdbf4aeaa408 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -140,7 +140,7 @@ static ssize_t iter_get_bvecs_alloc(struct iov_iter *iter, size_t maxsize,
* __iter_get_bvecs() may populate only part of the array -- zero it
* out.
*/
- bv = kvmalloc_array(npages, sizeof(*bv), GFP_KERNEL | __GFP_ZERO);
+ bv = kvmalloc_objs(*bv, npages, GFP_KERNEL | __GFP_ZERO);
if (!bv)
return -ENOMEM;
@@ -1344,7 +1344,7 @@ static void ceph_aio_complete_req(struct ceph_osd_request *req)
struct ceph_aio_work *aio_work;
BUG_ON(!aio_req->write);
- aio_work = kmalloc(sizeof(*aio_work), GFP_NOFS);
+ aio_work = kmalloc_obj(*aio_work, GFP_NOFS);
if (aio_work) {
INIT_WORK(&aio_work->work, ceph_aio_retry_work);
aio_work->req = req;
@@ -1572,7 +1572,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
*/
if (pos == iocb->ki_pos && !is_sync_kiocb(iocb) &&
(len == count || pos + count <= i_size_read(inode))) {
- aio_req = kzalloc(sizeof(*aio_req), GFP_KERNEL);
+ aio_req = kzalloc_obj(*aio_req, GFP_KERNEL);
if (aio_req) {
aio_req->iocb = iocb;
aio_req->write = write;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 2966f88310e3..d76f9a79dc0c 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -321,7 +321,7 @@ static struct ceph_inode_frag *__get_or_create_frag(struct ceph_inode_info *ci,
return frag;
}
- frag = kmalloc(sizeof(*frag), GFP_NOFS);
+ frag = kmalloc_obj(*frag, GFP_NOFS);
if (!frag)
return ERR_PTR(-ENOMEM);
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index c45bd19d4b1c..8933f05f5144 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -973,7 +973,7 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
if (mds >= mdsc->mdsmap->possible_max_rank)
return ERR_PTR(-EINVAL);
- s = kzalloc(sizeof(*s), GFP_NOFS);
+ s = kzalloc_obj(*s, GFP_NOFS);
if (!s)
return ERR_PTR(-ENOMEM);
@@ -4230,9 +4230,8 @@ static void handle_session(struct ceph_mds_session *session,
goto skip_cap_auths;
}
- cap_auths = kcalloc(cap_auths_num,
- sizeof(struct ceph_mds_cap_auth),
- GFP_KERNEL);
+ cap_auths = kzalloc_objs(struct ceph_mds_cap_auth,
+ cap_auths_num, GFP_KERNEL);
if (!cap_auths) {
pr_err_client(cl, "No memory for cap_auths\n");
return;
@@ -4731,9 +4730,9 @@ encode_again:
num_flock_locks = 0;
}
if (num_fcntl_locks + num_flock_locks > 0) {
- flocks = kmalloc_array(num_fcntl_locks + num_flock_locks,
- sizeof(struct ceph_filelock),
- GFP_NOFS);
+ flocks = kmalloc_objs(struct ceph_filelock,
+ num_fcntl_locks + num_flock_locks,
+ GFP_NOFS);
if (!flocks) {
err = -ENOMEM;
goto out_err;
@@ -5534,12 +5533,12 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
struct ceph_mds_client *mdsc;
int err;
- mdsc = kzalloc(sizeof(struct ceph_mds_client), GFP_NOFS);
+ mdsc = kzalloc_obj(struct ceph_mds_client, GFP_NOFS);
if (!mdsc)
return -ENOMEM;
mdsc->fsc = fsc;
mutex_init(&mdsc->mutex);
- mdsc->mdsmap = kzalloc(sizeof(*mdsc->mdsmap), GFP_NOFS);
+ mdsc->mdsmap = kzalloc_obj(*mdsc->mdsmap, GFP_NOFS);
if (!mdsc->mdsmap) {
err = -ENOMEM;
goto err_mdsc;
diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
index b228e5ecfb92..d8e46eb7e5eb 100644
--- a/fs/ceph/mdsmap.c
+++ b/fs/ceph/mdsmap.c
@@ -127,7 +127,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p,
u16 mdsmap_ev;
u32 target;
- m = kzalloc(sizeof(*m), GFP_NOFS);
+ m = kzalloc_obj(*m, GFP_NOFS);
if (!m)
return ERR_PTR(-ENOMEM);
@@ -169,7 +169,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p,
*/
m->possible_max_rank = max(m->m_num_active_mds, m->m_max_mds);
- m->m_info = kcalloc(m->possible_max_rank, sizeof(*m->m_info), GFP_NOFS);
+ m->m_info = kzalloc_objs(*m->m_info, m->possible_max_rank, GFP_NOFS);
if (!m->m_info)
goto nomem;
diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
index d90eda19bcc4..514da29469b8 100644
--- a/fs/ceph/quota.c
+++ b/fs/ceph/quota.c
@@ -103,7 +103,7 @@ find_quotarealm_inode(struct ceph_mds_client *mdsc, u64 ino)
}
if (!qri || (qri->ino != ino)) {
/* Not found, create a new one and insert it */
- qri = kmalloc(sizeof(*qri), GFP_KERNEL);
+ qri = kmalloc_obj(*qri, GFP_KERNEL);
if (qri) {
qri->ino = ino;
qri->inode = NULL;
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index 521507ea8260..52b4c2684f92 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -118,7 +118,7 @@ static struct ceph_snap_realm *ceph_create_snap_realm(
lockdep_assert_held_write(&mdsc->snap_rwsem);
- realm = kzalloc(sizeof(*realm), GFP_NOFS);
+ realm = kzalloc_obj(*realm, GFP_NOFS);
if (!realm)
return ERR_PTR(-ENOMEM);
@@ -1216,7 +1216,7 @@ struct ceph_snapid_map* ceph_get_snapid_map(struct ceph_mds_client *mdsc,
return exist;
}
- sm = kmalloc(sizeof(*sm), GFP_NOFS);
+ sm = kmalloc_obj(*sm, GFP_NOFS);
if (!sm)
return NULL;
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 7c1c1dac320d..57320e830eda 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -809,7 +809,7 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
struct ceph_fs_client *fsc;
int err;
- fsc = kzalloc(sizeof(*fsc), GFP_KERNEL);
+ fsc = kzalloc_obj(*fsc, GFP_KERNEL);
if (!fsc) {
err = -ENOMEM;
goto fail;
@@ -1429,7 +1429,7 @@ static int ceph_init_fs_context(struct fs_context *fc)
struct ceph_parse_opts_ctx *pctx;
struct ceph_mount_options *fsopt;
- pctx = kzalloc(sizeof(*pctx), GFP_KERNEL);
+ pctx = kzalloc_obj(*pctx, GFP_KERNEL);
if (!pctx)
return -ENOMEM;
@@ -1437,7 +1437,7 @@ static int ceph_init_fs_context(struct fs_context *fc)
if (!pctx->copts)
goto nomem;
- pctx->opts = kzalloc(sizeof(*pctx->opts), GFP_KERNEL);
+ pctx->opts = kzalloc_obj(*pctx->opts, GFP_KERNEL);
if (!pctx->opts)
goto nomem;
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index ad1f30bea175..5f87f62091a1 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -819,15 +819,15 @@ start:
xattr_version = ci->i_xattrs.version;
spin_unlock(&ci->i_ceph_lock);
- xattrs = kcalloc(numattr, sizeof(struct ceph_inode_xattr *),
- GFP_NOFS);
+ xattrs = kzalloc_objs(struct ceph_inode_xattr *, numattr,
+ GFP_NOFS);
err = -ENOMEM;
if (!xattrs)
goto bad_lock;
for (i = 0; i < numattr; i++) {
- xattrs[i] = kmalloc(sizeof(struct ceph_inode_xattr),
- GFP_NOFS);
+ xattrs[i] = kmalloc_obj(struct ceph_inode_xattr,
+ GFP_NOFS);
if (!xattrs[i])
goto bad_lock;
}
@@ -1220,7 +1220,7 @@ int __ceph_setxattr(struct inode *inode, const char *name,
goto out;
}
- xattr = kmalloc(sizeof(struct ceph_inode_xattr), GFP_NOFS);
+ xattr = kmalloc_obj(struct ceph_inode_xattr, GFP_NOFS);
if (!xattr)
goto out;
diff --git a/fs/char_dev.c b/fs/char_dev.c
index bf7b32650e54..49b2641bbe03 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -115,7 +115,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
return ERR_PTR(-EINVAL);
}
- cd = kzalloc(sizeof(struct char_device_struct), GFP_KERNEL);
+ cd = kzalloc_obj(struct char_device_struct, GFP_KERNEL);
if (cd == NULL)
return ERR_PTR(-ENOMEM);
@@ -636,7 +636,7 @@ static struct kobj_type ktype_cdev_dynamic = {
*/
struct cdev *cdev_alloc(void)
{
- struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
+ struct cdev *p = kzalloc_obj(struct cdev, GFP_KERNEL);
if (p) {
INIT_LIST_HEAD(&p->list);
kobject_init(&p->kobj, &ktype_cdev_dynamic);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index ca9990017265..329cefb16fb5 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -362,7 +362,7 @@ static int coda_venus_readdir(struct file *coda_file, struct dir_context *ctx)
cii = ITOC(file_inode(coda_file));
- vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
+ vdir = kmalloc_obj(*vdir, GFP_KERNEL);
if (!vdir) return -ENOMEM;
if (!dir_emit_dots(coda_file, ctx))
diff --git a/fs/coda/file.c b/fs/coda/file.c
index a390b5d21196..a40ba8d0b14b 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -175,7 +175,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
if (ret)
return ret;
- cvm_ops = kmalloc(sizeof(struct coda_vm_ops), GFP_KERNEL);
+ cvm_ops = kmalloc_obj(struct coda_vm_ops, GFP_KERNEL);
if (!cvm_ops)
return -ENOMEM;
@@ -231,7 +231,7 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
unsigned short coda_flags = coda_flags_to_cflags(flags);
struct coda_file_info *cfi;
- cfi = kmalloc(sizeof(struct coda_file_info), GFP_KERNEL);
+ cfi = kmalloc_obj(struct coda_file_info, GFP_KERNEL);
if (!cfi)
return -ENOMEM;
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 08450d006016..d95ae651f528 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -381,7 +381,7 @@ static int coda_init_fs_context(struct fs_context *fc)
{
struct coda_fs_context *ctx;
- ctx = kzalloc(sizeof(struct coda_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct coda_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index cd6a3721f6f6..0abde29b4f47 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -724,7 +724,7 @@ static int coda_upcall(struct venus_comm *vcp,
}
/* Format the request message. */
- req = kmalloc(sizeof(struct upc_req), GFP_KERNEL);
+ req = kmalloc_obj(struct upc_req, GFP_KERNEL);
if (!req) {
error = -ENOMEM;
goto exit;
@@ -788,10 +788,10 @@ static int coda_upcall(struct venus_comm *vcp,
}
error = -ENOMEM;
- sig_req = kmalloc(sizeof(struct upc_req), GFP_KERNEL);
+ sig_req = kmalloc_obj(struct upc_req, GFP_KERNEL);
if (!sig_req) goto exit;
- sig_inputArgs = kvzalloc(sizeof(*sig_inputArgs), GFP_KERNEL);
+ sig_inputArgs = kvzalloc_obj(*sig_inputArgs, GFP_KERNEL);
if (!sig_inputArgs) {
kfree(sig_req);
goto exit;
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index ba95f636a5ab..f437b1ab3b68 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -159,7 +159,7 @@ static struct configfs_fragment *new_fragment(void)
{
struct configfs_fragment *p;
- p = kmalloc(sizeof(struct configfs_fragment), GFP_KERNEL);
+ p = kmalloc_obj(struct configfs_fragment, GFP_KERNEL);
if (p) {
atomic_set(&p->frag_count, 1);
init_rwsem(&p->frag_sem);
@@ -1847,7 +1847,7 @@ configfs_register_default_group(struct config_group *parent_group,
int ret;
struct config_group *group;
- group = kzalloc(sizeof(*group), GFP_KERNEL);
+ group = kzalloc_obj(*group, GFP_KERNEL);
if (!group)
return ERR_PTR(-ENOMEM);
config_group_init_type_name(group, name, item_type);
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index affe4742bbb5..a83d1981e96f 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -296,7 +296,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
int error;
error = -ENOMEM;
- buffer = kzalloc(sizeof(struct configfs_buffer), GFP_KERNEL);
+ buffer = kzalloc_obj(struct configfs_buffer, GFP_KERNEL);
if (!buffer)
goto out;
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index bcda3372e141..e7d8500fee7d 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -47,7 +47,7 @@ int configfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
sd_iattr = sd->s_iattr;
if (!sd_iattr) {
/* setting attributes for the first time, allocate now */
- sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
+ sd_iattr = kzalloc_obj(struct iattr, GFP_KERNEL);
if (!sd_iattr)
return -ENOMEM;
/* assign default attributes */
diff --git a/fs/coredump.c b/fs/coredump.c
index 4ce7c80b39c8..c5b81cacbabb 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -262,7 +262,7 @@ static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,
switch (cn->core_type) {
case COREDUMP_PIPE: {
int argvs = sizeof(core_pattern) / 2;
- (*argv) = kmalloc_array(argvs, sizeof(**argv), GFP_KERNEL);
+ (*argv) = kmalloc_objs(**argv, argvs, GFP_KERNEL);
if (!(*argv))
return false;
(*argv)[(*argc)++] = 0;
@@ -1736,7 +1736,8 @@ static bool dump_vma_snapshot(struct coredump_params *cprm)
gate_vma = get_gate_vma(mm);
cprm->vma_count = mm->map_count + (gate_vma ? 1 : 0);
- cprm->vma_meta = kvmalloc_array(cprm->vma_count, sizeof(*cprm->vma_meta), GFP_KERNEL);
+ cprm->vma_meta = kvmalloc_objs(*cprm->vma_meta, cprm->vma_count,
+ GFP_KERNEL);
if (!cprm->vma_meta) {
mmap_write_unlock(mm);
return false;
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 41b1a869cf13..10403cb81182 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -619,7 +619,7 @@ static int cramfs_blkdev_fill_super(struct super_block *sb, struct fs_context *f
struct cramfs_super super;
int i, err;
- sbi = kzalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct cramfs_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
@@ -640,7 +640,7 @@ static int cramfs_mtd_fill_super(struct super_block *sb, struct fs_context *fc)
struct cramfs_super super;
int err;
- sbi = kzalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct cramfs_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c
index ed6e926226b5..e286d9fd17f3 100644
--- a/fs/crypto/inline_crypt.c
+++ b/fs/crypto/inline_crypt.c
@@ -32,7 +32,7 @@ static struct block_device **fscrypt_get_devices(struct super_block *sb,
if (devs)
return devs;
}
- devs = kmalloc(sizeof(*devs), GFP_KERNEL);
+ devs = kmalloc_obj(*devs, GFP_KERNEL);
if (!devs)
return ERR_PTR(-ENOMEM);
devs[0] = sb->s_bdev;
@@ -169,7 +169,7 @@ int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key,
unsigned int i;
int err;
- blk_key = kmalloc(sizeof(*blk_key), GFP_KERNEL);
+ blk_key = kmalloc_obj(*blk_key, GFP_KERNEL);
if (!blk_key)
return -ENOMEM;
diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
index 5e939ea3ac28..855314a28b18 100644
--- a/fs/crypto/keyring.c
+++ b/fs/crypto/keyring.c
@@ -209,7 +209,7 @@ static int allocate_filesystem_keyring(struct super_block *sb)
if (sb->s_master_keys)
return 0;
- keyring = kzalloc(sizeof(*keyring), GFP_KERNEL);
+ keyring = kzalloc_obj(*keyring, GFP_KERNEL);
if (!keyring)
return -ENOMEM;
spin_lock_init(&keyring->lock);
@@ -434,7 +434,7 @@ static int add_new_master_key(struct super_block *sb,
struct fscrypt_master_key *mk;
int err;
- mk = kzalloc(sizeof(*mk), GFP_KERNEL);
+ mk = kzalloc_obj(*mk, GFP_KERNEL);
if (!mk)
return -ENOMEM;
diff --git a/fs/crypto/keysetup_v1.c b/fs/crypto/keysetup_v1.c
index c4d05168522b..93fc2ab7ee97 100644
--- a/fs/crypto/keysetup_v1.c
+++ b/fs/crypto/keysetup_v1.c
@@ -221,7 +221,7 @@ fscrypt_get_direct_key(const struct fscrypt_inode_info *ci, const u8 *raw_key)
return dk;
/* Nope, allocate one. */
- dk = kzalloc(sizeof(*dk), GFP_KERNEL);
+ dk = kzalloc_obj(*dk, GFP_KERNEL);
if (!dk)
return ERR_PTR(-ENOMEM);
dk->dk_sb = ci->ci_inode->i_sb;
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index bbb2f5ced988..49309e9da4ea 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -813,7 +813,7 @@ int fscrypt_parse_test_dummy_encryption(const struct fs_parameter *param,
if (param->type == fs_value_is_string && *param->string)
arg = param->string;
- policy = kzalloc(sizeof(*policy), GFP_KERNEL);
+ policy = kzalloc_obj(*policy, GFP_KERNEL);
if (!policy)
return -ENOMEM;
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 3ec3324c2060..70b8dcd3599d 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -82,7 +82,7 @@ static int __debugfs_file_get(struct dentry *dentry, enum dbgfs_get_mode mode)
if (WARN_ON(mode == DBGFS_GET_ALREADY))
return -EINVAL;
- fsd = kmalloc(sizeof(*fsd), GFP_KERNEL);
+ fsd = kmalloc_obj(*fsd, GFP_KERNEL);
if (!fsd)
return -ENOMEM;
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 4005d21cf009..a9e161f6fb7d 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -310,7 +310,7 @@ static int debugfs_init_fs_context(struct fs_context *fc)
{
struct debugfs_fs_info *fsi;
- fsi = kzalloc(sizeof(struct debugfs_fs_info), GFP_KERNEL);
+ fsi = kzalloc_obj(struct debugfs_fs_info, GFP_KERNEL);
if (!fsi)
return -ENOMEM;
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 9f3de528c358..93af356408ee 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -420,7 +420,7 @@ static int devpts_init_fs_context(struct fs_context *fc)
{
struct pts_fs_info *fsi;
- fsi = kzalloc(sizeof(struct pts_fs_info), GFP_KERNEL);
+ fsi = kzalloc_obj(struct pts_fs_info, GFP_KERNEL);
if (!fsi)
return -ENOMEM;
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 82cc3215663f..0f80fda98227 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -426,9 +426,9 @@ static struct config_group *make_cluster(struct config_group *g,
struct dlm_spaces *sps = NULL;
struct dlm_comms *cms = NULL;
- cl = kzalloc(sizeof(struct dlm_cluster), GFP_NOFS);
- sps = kzalloc(sizeof(struct dlm_spaces), GFP_NOFS);
- cms = kzalloc(sizeof(struct dlm_comms), GFP_NOFS);
+ cl = kzalloc_obj(struct dlm_cluster, GFP_NOFS);
+ sps = kzalloc_obj(struct dlm_spaces, GFP_NOFS);
+ cms = kzalloc_obj(struct dlm_comms, GFP_NOFS);
if (!cl || !sps || !cms)
goto fail;
@@ -480,8 +480,8 @@ static struct config_group *make_space(struct config_group *g, const char *name)
struct dlm_space *sp = NULL;
struct dlm_nodes *nds = NULL;
- sp = kzalloc(sizeof(struct dlm_space), GFP_NOFS);
- nds = kzalloc(sizeof(struct dlm_nodes), GFP_NOFS);
+ sp = kzalloc_obj(struct dlm_space, GFP_NOFS);
+ nds = kzalloc_obj(struct dlm_nodes, GFP_NOFS);
if (!sp || !nds)
goto fail;
@@ -531,7 +531,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
if (rv)
return ERR_PTR(rv);
- cm = kzalloc(sizeof(struct dlm_comm), GFP_NOFS);
+ cm = kzalloc_obj(struct dlm_comm, GFP_NOFS);
if (!cm)
return ERR_PTR(-ENOMEM);
@@ -577,7 +577,7 @@ static struct config_item *make_node(struct config_group *g, const char *name)
if (rv)
return ERR_PTR(rv);
- nd = kzalloc(sizeof(struct dlm_node), GFP_NOFS);
+ nd = kzalloc_obj(struct dlm_node, GFP_NOFS);
if (!nd)
return ERR_PTR(-ENOMEM);
@@ -602,7 +602,7 @@ static void drop_node(struct config_group *g, struct config_item *i)
struct dlm_node *nd = config_item_to_node(i);
struct dlm_member_gone *mb_gone;
- mb_gone = kzalloc(sizeof(*mb_gone), GFP_KERNEL);
+ mb_gone = kzalloc_obj(*mb_gone, GFP_KERNEL);
if (!mb_gone)
return;
@@ -701,7 +701,7 @@ static ssize_t comm_addr_store(struct config_item *item, const char *buf,
if (cm->addr_count >= DLM_MAX_ADDR_COUNT)
return -ENOSPC;
- addr = kzalloc(sizeof(*addr), GFP_NOFS);
+ addr = kzalloc_obj(*addr, GFP_NOFS);
if (!addr)
return -ENOMEM;
@@ -946,7 +946,7 @@ int dlm_config_nodes(char *lsname, struct dlm_config_node **nodes_out,
count = sp->members_count + sp->members_gone_count;
- nodes = kcalloc(count, sizeof(struct dlm_config_node), GFP_NOFS);
+ nodes = kzalloc_objs(struct dlm_config_node, count, GFP_NOFS);
if (!nodes) {
rv = -ENOMEM;
goto out;
diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c
index 01c292379f5b..aa08e8f446a1 100644
--- a/fs/dlm/dir.c
+++ b/fs/dlm/dir.c
@@ -276,7 +276,7 @@ static struct dlm_dir_dump *init_dir_dump(struct dlm_ls *ls, int nodeid)
drop_dir_ctx(ls, nodeid);
}
- dd = kzalloc(sizeof(*dd), GFP_ATOMIC);
+ dd = kzalloc_obj(*dd, GFP_ATOMIC);
if (!dd)
return NULL;
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 47a09d6748cb..3b6e6a29eab8 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -5050,7 +5050,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
int wait_type, local_unlock_result, local_cancel_result;
int dir_nodeid;
- ms_local = kmalloc(sizeof(*ms_local), GFP_KERNEL);
+ ms_local = kmalloc_obj(*ms_local, GFP_KERNEL);
if (!ms_local)
return;
@@ -6288,7 +6288,7 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
if (lkb_dflags & BIT(DLM_DFL_USER_BIT))
return -EOPNOTSUPP;
- lksb = kzalloc(sizeof(*lksb), GFP_NOFS);
+ lksb = kzalloc_obj(*lksb, GFP_NOFS);
if (!lksb)
return -ENOMEM;
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index ddaa76558706..a9c98b4f378f 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -427,7 +427,7 @@ static int new_lockspace(const char *name, const char *cluster,
error = -ENOMEM;
- ls = kzalloc(sizeof(*ls), GFP_NOFS);
+ ls = kzalloc_obj(*ls, GFP_NOFS);
if (!ls)
goto out;
memcpy(ls->ls_name, name, namelen);
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index b3958008ba3f..5b6142787919 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -305,7 +305,7 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)
if (con || !alloc)
return con;
- con = kzalloc(sizeof(*con), alloc);
+ con = kzalloc_obj(*con, alloc);
if (!con)
return NULL;
@@ -838,7 +838,7 @@ static struct processqueue_entry *new_processqueue_entry(int nodeid,
{
struct processqueue_entry *pentry;
- pentry = kmalloc(sizeof(*pentry), GFP_NOFS);
+ pentry = kmalloc_obj(*pentry, GFP_NOFS);
if (!pentry)
return NULL;
@@ -1052,7 +1052,7 @@ static int accept_from_sock(void)
struct connection *othercon = newcon->othercon;
if (!othercon) {
- othercon = kzalloc(sizeof(*othercon), GFP_NOFS);
+ othercon = kzalloc_obj(*othercon, GFP_NOFS);
if (!othercon) {
log_print("failed to allocate incoming socket");
up_write(&newcon->sock_lock);
diff --git a/fs/dlm/member.c b/fs/dlm/member.c
index c1b5598997b7..812d889f1ce5 100644
--- a/fs/dlm/member.c
+++ b/fs/dlm/member.c
@@ -211,7 +211,7 @@ int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size,
}
array_size = max + need;
- array = kcalloc(array_size, sizeof(*array), GFP_NOFS);
+ array = kzalloc_objs(*array, array_size, GFP_NOFS);
if (!array)
return -ENOMEM;
@@ -323,7 +323,7 @@ static int dlm_add_member(struct dlm_ls *ls, struct dlm_config_node *node)
struct dlm_member *memb;
int error;
- memb = kzalloc(sizeof(*memb), GFP_NOFS);
+ memb = kzalloc_obj(*memb, GFP_NOFS);
if (!memb)
return -ENOMEM;
@@ -423,7 +423,7 @@ static void make_member_array(struct dlm_ls *ls)
}
ls->ls_total_weight = total;
- array = kmalloc_array(total, sizeof(*array), GFP_NOFS);
+ array = kmalloc_objs(*array, total, GFP_NOFS);
if (!array)
return;
@@ -511,7 +511,7 @@ void dlm_lsop_recover_done(struct dlm_ls *ls)
return;
num = ls->ls_num_nodes;
- slots = kcalloc(num, sizeof(*slots), GFP_KERNEL);
+ slots = kzalloc_objs(*slots, num, GFP_KERNEL);
if (!slots)
return;
@@ -726,7 +726,7 @@ int dlm_ls_start(struct dlm_ls *ls)
struct dlm_config_node *nodes = NULL;
int error, count;
- rv = kzalloc(sizeof(*rv), GFP_NOFS);
+ rv = kzalloc_obj(*rv, GFP_NOFS);
if (!rv)
return -ENOMEM;
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index 2c101bbe261a..d54bdd8fc4f2 100644
--- a/fs/dlm/midcomms.c
+++ b/fs/dlm/midcomms.c
@@ -351,7 +351,7 @@ int dlm_midcomms_addr(int nodeid, struct sockaddr_storage *addr)
}
srcu_read_unlock(&nodes_srcu, idx);
- node = kmalloc(sizeof(*node), GFP_NOFS);
+ node = kmalloc_obj(*node, GFP_NOFS);
if (!node)
return -ENOMEM;
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 9ca83ef70ed1..e9598b3fe5d0 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -102,7 +102,7 @@ static int do_lock_cancel(const struct dlm_plock_info *orig_info)
struct plock_op *op;
int rv;
- op = kzalloc(sizeof(*op), GFP_NOFS);
+ op = kzalloc_obj(*op, GFP_NOFS);
if (!op)
return -ENOMEM;
@@ -131,7 +131,7 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
if (!ls)
return -EINVAL;
- op = kzalloc(sizeof(*op), GFP_NOFS);
+ op = kzalloc_obj(*op, GFP_NOFS);
if (!op) {
rv = -ENOMEM;
goto out;
@@ -148,7 +148,7 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
op->info.owner = (__u64)(long) fl->c.flc_owner;
/* async handling */
if (fl->fl_lmops && fl->fl_lmops->lm_grant) {
- op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
+ op_data = kzalloc_obj(*op_data, GFP_NOFS);
if (!op_data) {
dlm_release_plock_op(op);
rv = -ENOMEM;
@@ -297,7 +297,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
if (!ls)
return -EINVAL;
- op = kzalloc(sizeof(*op), GFP_NOFS);
+ op = kzalloc_obj(*op, GFP_NOFS);
if (!op) {
rv = -ENOMEM;
goto out;
@@ -430,7 +430,7 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file,
if (!ls)
return -EINVAL;
- op = kzalloc(sizeof(*op), GFP_NOFS);
+ op = kzalloc_obj(*op, GFP_NOFS);
if (!op) {
rv = -ENOMEM;
goto out;
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 51daf4acbe31..a8ed4c8fdc5b 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -262,7 +262,7 @@ static int device_user_lock(struct dlm_user_proc *proc,
goto out;
}
- ua = kzalloc(sizeof(struct dlm_user_args), GFP_NOFS);
+ ua = kzalloc_obj(struct dlm_user_args, GFP_NOFS);
if (!ua)
goto out;
ua->proc = proc;
@@ -307,7 +307,7 @@ static int device_user_unlock(struct dlm_user_proc *proc,
if (!ls)
return -ENOENT;
- ua = kzalloc(sizeof(struct dlm_user_args), GFP_NOFS);
+ ua = kzalloc_obj(struct dlm_user_args, GFP_NOFS);
if (!ua)
goto out;
ua->proc = proc;
@@ -645,7 +645,7 @@ static int device_open(struct inode *inode, struct file *file)
if (!ls)
return -ENOENT;
- proc = kzalloc(sizeof(struct dlm_user_proc), GFP_NOFS);
+ proc = kzalloc_obj(struct dlm_user_proc, GFP_NOFS);
if (!proc) {
dlm_put_lockspace(ls);
return -ENOMEM;
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 5459f18b3cca..6ada136f3f3f 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1793,7 +1793,7 @@ int ecryptfs_encrypt_and_encode_filename(
& ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)) {
struct ecryptfs_filename *filename;
- filename = kzalloc(sizeof(*filename), GFP_KERNEL);
+ filename = kzalloc_obj(*filename, GFP_KERNEL);
if (!filename) {
rc = -ENOMEM;
goto out;
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index a41c82d610a7..04b6d296a3fa 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -623,7 +623,7 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes,
struct key *auth_tok_key = NULL;
int rc = 0;
- s = kzalloc(sizeof(*s), GFP_KERNEL);
+ s = kzalloc_obj(*s, GFP_KERNEL);
if (!s)
return -ENOMEM;
@@ -860,7 +860,7 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
(*packet_size) = 0;
(*filename_size) = 0;
(*filename) = NULL;
- s = kzalloc(sizeof(*s), GFP_KERNEL);
+ s = kzalloc_obj(*s, GFP_KERNEL);
if (!s)
return -ENOMEM;
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 7d51e6b60f53..dcfa607fbf15 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -610,7 +610,7 @@ static int ecryptfs_init_fs_context(struct fs_context *fc)
struct ecryptfs_fs_context *ctx;
struct ecryptfs_sb_info *sbi = NULL;
- ctx = kzalloc(sizeof(struct ecryptfs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct ecryptfs_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL);
diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
index 6318f3500e5c..6cf3052e9370 100644
--- a/fs/ecryptfs/messaging.c
+++ b/fs/ecryptfs/messaging.c
@@ -131,7 +131,7 @@ ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, struct file *file)
{
int rc = 0;
- (*daemon) = kzalloc(sizeof(**daemon), GFP_KERNEL);
+ (*daemon) = kzalloc_obj(**daemon, GFP_KERNEL);
if (!(*daemon)) {
rc = -ENOMEM;
goto out;
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 9da992925920..14c2752831c8 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -44,7 +44,7 @@ static int efivarfs_ops_notifier(struct notifier_block *nb, unsigned long event,
static struct inode *efivarfs_alloc_inode(struct super_block *sb)
{
- struct efivar_entry *entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ struct efivar_entry *entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return NULL;
@@ -505,7 +505,7 @@ static int efivarfs_init_fs_context(struct fs_context *fc)
if (!efivar_is_available())
return -EOPNOTSUPP;
- sfi = kzalloc(sizeof(*sfi), GFP_KERNEL);
+ sfi = kzalloc_obj(*sfi, GFP_KERNEL);
if (!sfi)
return -ENOMEM;
diff --git a/fs/efs/super.c b/fs/efs/super.c
index c59086b7eabf..54252bccd6a3 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -243,7 +243,7 @@ static int efs_fill_super(struct super_block *s, struct fs_context *fc)
struct buffer_head *bh;
struct inode *root;
- sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
+ sb = kzalloc_obj(struct efs_sb_info, GFP_KERNEL);
if (!sb)
return -ENOMEM;
s->s_fs_info = sb;
diff --git a/fs/erofs/decompressor_deflate.c b/fs/erofs/decompressor_deflate.c
index 4f26ab767645..787eb8fc6262 100644
--- a/fs/erofs/decompressor_deflate.c
+++ b/fs/erofs/decompressor_deflate.c
@@ -71,7 +71,7 @@ static int z_erofs_load_deflate_config(struct super_block *sb,
++z_erofs_deflate_avail_strms) {
struct z_erofs_deflate *strm;
- strm = kzalloc(sizeof(*strm), GFP_KERNEL);
+ strm = kzalloc_obj(*strm, GFP_KERNEL);
if (!strm)
goto failed;
/* XXX: in-kernel zlib cannot customize windowbits */
diff --git a/fs/erofs/decompressor_lzma.c b/fs/erofs/decompressor_lzma.c
index b4ea6978faae..c1c908d7b6ef 100644
--- a/fs/erofs/decompressor_lzma.c
+++ b/fs/erofs/decompressor_lzma.c
@@ -54,7 +54,7 @@ static int __init z_erofs_lzma_init(void)
z_erofs_lzma_nstrms = num_possible_cpus();
for (i = 0; i < z_erofs_lzma_nstrms; ++i) {
- struct z_erofs_lzma *strm = kzalloc(sizeof(*strm), GFP_KERNEL);
+ struct z_erofs_lzma *strm = kzalloc_obj(*strm, GFP_KERNEL);
if (!strm) {
z_erofs_lzma_exit();
diff --git a/fs/erofs/decompressor_zstd.c b/fs/erofs/decompressor_zstd.c
index beae49165c69..6da93f74431b 100644
--- a/fs/erofs/decompressor_zstd.c
+++ b/fs/erofs/decompressor_zstd.c
@@ -59,7 +59,7 @@ static int __init z_erofs_zstd_init(void)
++z_erofs_zstd_avail_strms) {
struct z_erofs_zstd *strm;
- strm = kzalloc(sizeof(*strm), GFP_KERNEL);
+ strm = kzalloc_obj(*strm, GFP_KERNEL);
if (!strm) {
z_erofs_zstd_exit();
return -ENOMEM;
diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c
index 4d5054dcac95..abe873f01297 100644
--- a/fs/erofs/fileio.c
+++ b/fs/erofs/fileio.c
@@ -68,8 +68,7 @@ static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
{
- struct erofs_fileio_rq *rq = kzalloc(sizeof(*rq),
- GFP_KERNEL | __GFP_NOFAIL);
+ struct erofs_fileio_rq *rq = kzalloc_obj(*rq, GFP_KERNEL | __GFP_NOFAIL);
bio_init(&rq->bio, NULL, rq->bvecs, ARRAY_SIZE(rq->bvecs), REQ_OP_READ);
rq->iocb.ki_filp = mdev->m_dif->file;
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index a2cc0f3fa9d0..0a231063b341 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -70,7 +70,7 @@ static void erofs_fscache_req_put(struct erofs_fscache_rq *req)
static struct erofs_fscache_rq *erofs_fscache_req_alloc(struct address_space *mapping,
loff_t start, size_t len)
{
- struct erofs_fscache_rq *req = kzalloc(sizeof(*req), GFP_KERNEL);
+ struct erofs_fscache_rq *req = kzalloc_obj(*req, GFP_KERNEL);
if (!req)
return NULL;
@@ -101,7 +101,7 @@ static void erofs_fscache_req_end_io(void *priv, ssize_t transferred_or_error)
static struct erofs_fscache_io *erofs_fscache_req_io_alloc(struct erofs_fscache_rq *req)
{
- struct erofs_fscache_io *io = kzalloc(sizeof(*io), GFP_KERNEL);
+ struct erofs_fscache_io *io = kzalloc_obj(*io, GFP_KERNEL);
if (!io)
return NULL;
@@ -181,7 +181,7 @@ struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev)
{
struct erofs_fscache_bio *io;
- io = kmalloc(sizeof(*io), GFP_KERNEL | __GFP_NOFAIL);
+ io = kmalloc_obj(*io, GFP_KERNEL | __GFP_NOFAIL);
bio_init(&io->bio, NULL, io->bvecs, BIO_MAX_VECS, REQ_OP_READ);
io->io.private = mdev->m_dif->fscache->cookie;
io->io.end_io = erofs_fscache_bio_endio;
@@ -417,7 +417,7 @@ static int erofs_fscache_init_domain(struct super_block *sb)
struct erofs_domain *domain;
struct erofs_sb_info *sbi = EROFS_SB(sb);
- domain = kzalloc(sizeof(struct erofs_domain), GFP_KERNEL);
+ domain = kzalloc_obj(struct erofs_domain, GFP_KERNEL);
if (!domain)
return -ENOMEM;
@@ -482,7 +482,7 @@ static struct erofs_fscache *erofs_fscache_acquire_cookie(struct super_block *sb
struct inode *inode;
int ret;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&ctx->node);
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 7827e61424b7..a333456c7d5d 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -226,7 +226,7 @@ static int erofs_scan_devices(struct super_block *sb,
}
} else {
for (id = 0; id < ondisk_extradevs; id++) {
- dif = kzalloc(sizeof(*dif), GFP_KERNEL);
+ dif = kzalloc_obj(*dif, GFP_KERNEL);
if (!dif) {
err = -ENOMEM;
break;
@@ -495,7 +495,7 @@ static int erofs_fc_parse_param(struct fs_context *fc,
return -EINVAL;
break;
case Opt_device:
- dif = kzalloc(sizeof(*dif), GFP_KERNEL);
+ dif = kzalloc_obj(*dif, GFP_KERNEL);
if (!dif)
return -ENOMEM;
dif->path = kstrdup(param->string, GFP_KERNEL);
@@ -903,11 +903,11 @@ static int erofs_init_fs_context(struct fs_context *fc)
{
struct erofs_sb_info *sbi;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
- sbi->devs = kzalloc(sizeof(struct erofs_dev_context), GFP_KERNEL);
+ sbi->devs = kzalloc_obj(struct erofs_dev_context, GFP_KERNEL);
if (!sbi->devs) {
kfree(sbi);
return -ENOMEM;
diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index b7da1ed83160..5997a7ae19d9 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -85,8 +85,8 @@ static int erofs_init_inode_xattrs(struct inode *inode)
}
vi->xattr_name_filter = le32_to_cpu(ih->h_name_filter);
vi->xattr_shared_count = ih->h_shared_count;
- vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
- sizeof(uint), GFP_KERNEL);
+ vi->xattr_shared_xattrs = kmalloc_objs(uint, vi->xattr_shared_count,
+ GFP_KERNEL);
if (!vi->xattr_shared_xattrs) {
erofs_put_metabuf(&buf);
ret = -ENOMEM;
@@ -498,7 +498,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
if (!sbi->xattr_prefix_count)
return 0;
- pfs = kcalloc(sbi->xattr_prefix_count, sizeof(*pfs), GFP_KERNEL);
+ pfs = kzalloc_objs(*pfs, sbi->xattr_prefix_count, GFP_KERNEL);
if (!pfs)
return -ENOMEM;
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index ea9d32e9cb12..3977e42b9516 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -323,8 +323,8 @@ static int erofs_init_percpu_workers(void)
struct kthread_worker *worker;
unsigned int cpu;
- z_erofs_pcpu_workers = kcalloc(num_possible_cpus(),
- sizeof(struct kthread_worker *), GFP_ATOMIC);
+ z_erofs_pcpu_workers = kzalloc_objs(struct kthread_worker *,
+ num_possible_cpus(), GFP_ATOMIC);
if (!z_erofs_pcpu_workers)
return -ENOMEM;
@@ -1144,7 +1144,7 @@ static void z_erofs_do_decompressed_bvec(struct z_erofs_backend *be,
}
/* (cold path) one pcluster is requested multiple times */
- item = kmalloc(sizeof(*item), GFP_KERNEL | __GFP_NOFAIL);
+ item = kmalloc_obj(*item, GFP_KERNEL | __GFP_NOFAIL);
item->bvec = *bvec;
list_add(&item->list, &be->decompressed_secondary_bvecs);
}
@@ -1282,12 +1282,12 @@ static int z_erofs_decompress_pcluster(struct z_erofs_backend *be, bool eio)
if (!be->decompressed_pages)
be->decompressed_pages =
- kvcalloc(be->nr_pages, sizeof(struct page *),
- GFP_KERNEL | __GFP_NOFAIL);
+ kvzalloc_objs(struct page *, be->nr_pages,
+ GFP_KERNEL | __GFP_NOFAIL);
if (!be->compressed_pages)
be->compressed_pages =
- kvcalloc(pclusterpages, sizeof(struct page *),
- GFP_KERNEL | __GFP_NOFAIL);
+ kvzalloc_objs(struct page *, pclusterpages,
+ GFP_KERNEL | __GFP_NOFAIL);
z_erofs_parse_out_bvecs(be);
err2 = z_erofs_parse_in_bvecs(be, &overlapped);
@@ -1590,7 +1590,7 @@ static struct z_erofs_decompressqueue *jobqueue_init(struct super_block *sb,
struct z_erofs_decompressqueue *q;
if (fg && !*fg) {
- q = kvzalloc(sizeof(*q), GFP_KERNEL | __GFP_NOWARN);
+ q = kvzalloc_obj(*q, GFP_KERNEL | __GFP_NOWARN);
if (!q) {
*fg = true;
goto fg_out;
diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c
index 55ff2ab5128e..9a15088744f0 100644
--- a/fs/erofs/zutil.c
+++ b/fs/erofs/zutil.c
@@ -79,7 +79,7 @@ int z_erofs_gbuf_growsize(unsigned int nrpages)
for (i = 0; i < z_erofs_gbuf_count; ++i) {
gbuf = &z_erofs_gbufpool[i];
- tmp_pages = kcalloc(nrpages, sizeof(*tmp_pages), GFP_KERNEL);
+ tmp_pages = kzalloc_objs(*tmp_pages, nrpages, GFP_KERNEL);
if (!tmp_pages)
goto out;
@@ -131,15 +131,15 @@ int __init z_erofs_gbuf_init(void)
/* The last (special) global buffer is the reserved buffer */
total += !!z_erofs_rsv_nrpages;
- z_erofs_gbufpool = kcalloc(total, sizeof(*z_erofs_gbufpool),
- GFP_KERNEL);
+ z_erofs_gbufpool = kzalloc_objs(*z_erofs_gbufpool, total, GFP_KERNEL);
if (!z_erofs_gbufpool)
return -ENOMEM;
if (z_erofs_rsv_nrpages) {
z_erofs_rsvbuf = &z_erofs_gbufpool[total - 1];
- z_erofs_rsvbuf->pages = kcalloc(z_erofs_rsv_nrpages,
- sizeof(*z_erofs_rsvbuf->pages), GFP_KERNEL);
+ z_erofs_rsvbuf->pages = kzalloc_objs(*z_erofs_rsvbuf->pages,
+ z_erofs_rsv_nrpages,
+ GFP_KERNEL);
if (!z_erofs_rsvbuf->pages) {
z_erofs_rsvbuf = NULL;
z_erofs_rsv_nrpages = 0;
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 3219e0d596fe..a0ea7f30c76f 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -388,7 +388,7 @@ static int do_eventfd(unsigned int count, int flags)
if (flags & ~EFD_FLAGS_SET)
return -EINVAL;
- ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kmalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 6c36d9dc6926..4d0c0ce43cb3 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1147,7 +1147,7 @@ static int ep_alloc(struct eventpoll **pep)
{
struct eventpoll *ep;
- ep = kzalloc(sizeof(*ep), GFP_KERNEL);
+ ep = kzalloc_obj(*ep, GFP_KERNEL);
if (unlikely(!ep))
return -ENOMEM;
diff --git a/fs/exec.c b/fs/exec.c
index 2e3a6593c6fd..c367e74cf103 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1402,7 +1402,7 @@ static struct linux_binprm *alloc_bprm(int fd, struct filename *filename, int fl
if (IS_ERR(file))
return ERR_CAST(file);
- bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
+ bprm = kzalloc_obj(*bprm, GFP_KERNEL);
if (!bprm) {
do_close_execat(file);
return ERR_PTR(-ENOMEM);
diff --git a/fs/exfat/balloc.c b/fs/exfat/balloc.c
index 5429041c7eaf..8dd9e39f8ccf 100644
--- a/fs/exfat/balloc.c
+++ b/fs/exfat/balloc.c
@@ -96,8 +96,8 @@ static int exfat_allocate_bitmap(struct super_block *sb,
}
sbi->map_sectors = ((need_map_size - 1) >>
(sb->s_blocksize_bits)) + 1;
- sbi->vol_amap = kvmalloc_array(sbi->map_sectors,
- sizeof(struct buffer_head *), GFP_KERNEL);
+ sbi->vol_amap = kvmalloc_objs(struct buffer_head *, sbi->map_sectors,
+ GFP_KERNEL);
if (!sbi->vol_amap)
return -ENOMEM;
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 2dbf335eafef..3a4853693d8b 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -802,7 +802,7 @@ static int __exfat_get_dentry_set(struct exfat_entry_set_cache *es,
num_bh = EXFAT_B_TO_BLK_ROUND_UP(off + num_entries * DENTRY_SIZE, sb);
if (num_bh > ARRAY_SIZE(es->__bh)) {
- es->bh = kmalloc_array(num_bh, sizeof(*es->bh), GFP_NOFS);
+ es->bh = kmalloc_objs(*es->bh, num_bh, GFP_NOFS);
if (!es->bh) {
brelse(bh);
return -ENOMEM;
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 10e872a99663..42a232394afb 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -815,7 +815,7 @@ static int exfat_init_fs_context(struct fs_context *fc)
{
struct exfat_sb_info *sbi;
- sbi = kzalloc(sizeof(struct exfat_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct exfat_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index b8cfab8f98b9..2bac6dcb1792 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -419,7 +419,7 @@ void ext2_init_block_alloc_info(struct inode *inode)
struct ext2_block_alloc_info *block_i;
struct super_block *sb = inode->i_sb;
- block_i = kmalloc(sizeof(*block_i), GFP_KERNEL);
+ block_i = kmalloc_obj(*block_i, GFP_KERNEL);
if (block_i) {
struct ext2_reserve_window_node *rsv = &block_i->rsv_window_node;
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 121e634c792a..9bb4c63f5628 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -893,12 +893,12 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
__le32 features;
int err;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sbi->s_blockgroup_lock =
- kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
+ kzalloc_obj(struct blockgroup_lock, GFP_KERNEL);
if (!sbi->s_blockgroup_lock) {
kfree(sbi);
return -ENOMEM;
@@ -1122,9 +1122,8 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
}
db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
EXT2_DESC_PER_BLOCK(sb);
- sbi->s_group_desc = kvmalloc_array(db_count,
- sizeof(struct buffer_head *),
- GFP_KERNEL);
+ sbi->s_group_desc = kvmalloc_objs(struct buffer_head *, db_count,
+ GFP_KERNEL);
if (sbi->s_group_desc == NULL) {
ret = -ENOMEM;
ext2_msg(sb, KERN_ERR, "error: not enough memory");
@@ -1670,7 +1669,7 @@ static int ext2_init_fs_context(struct fs_context *fc)
{
struct ext2_fs_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index e8c5525afc67..75179be4a488 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -217,7 +217,7 @@ int ext4_setup_system_zone(struct super_block *sb)
ext4_group_t i;
int ret;
- system_blks = kzalloc(sizeof(*system_blks), GFP_KERNEL);
+ system_blks = kzalloc_obj(*system_blks, GFP_KERNEL);
if (!system_blks)
return -ENOMEM;
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 00c4b3c82b65..b285ce18b183 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -480,8 +480,7 @@ int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
p = &info->root.rb_node;
/* Create and allocate the fname structure */
- new_fn = kzalloc(struct_size(new_fn, name, ent_name->len + 1),
- GFP_KERNEL);
+ new_fn = kzalloc_flex(*new_fn, name, ent_name->len + 1, GFP_KERNEL);
if (!new_fn)
return -ENOMEM;
new_fn->hash = hash;
@@ -673,7 +672,7 @@ static int ext4_dir_open(struct inode *inode, struct file *file)
{
struct dir_private_info *info;
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
file->private_data = info;
diff --git a/fs/ext4/extents-test.c b/fs/ext4/extents-test.c
index 4879e68e465d..913103089799 100644
--- a/fs/ext4/extents-test.c
+++ b/fs/ext4/extents-test.c
@@ -229,7 +229,7 @@ static int extents_kunit_init(struct kunit *test)
sb->s_blocksize = 4096;
sb->s_blocksize_bits = 12;
- sbi = kzalloc(sizeof(struct ext4_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct ext4_sb_info, GFP_KERNEL);
if (sbi == NULL)
return -ENOMEM;
@@ -240,7 +240,7 @@ static int extents_kunit_init(struct kunit *test)
sbi->s_extent_max_zeroout_kb = 32;
/* setup the mock inode */
- k_ctx.k_ei = kzalloc(sizeof(struct ext4_inode_info), GFP_KERNEL);
+ k_ctx.k_ei = kzalloc_obj(struct ext4_inode_info, GFP_KERNEL);
if (k_ctx.k_ei == NULL)
return -ENOMEM;
ei = k_ctx.k_ei;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 3630b27e4fd7..ae3804f36535 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -621,8 +621,7 @@ int ext4_ext_precache(struct inode *inode)
return ret;
}
- path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
- GFP_NOFS);
+ path = kzalloc_objs(struct ext4_ext_path, depth + 1, GFP_NOFS);
if (path == NULL) {
up_read(&ei->i_data_sem);
return -ENOMEM;
@@ -916,8 +915,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
}
if (!path) {
/* account possible depth increase */
- path = kcalloc(depth + 2, sizeof(struct ext4_ext_path),
- gfp_flags);
+ path = kzalloc_objs(struct ext4_ext_path, depth + 2, gfp_flags);
if (unlikely(!path))
return ERR_PTR(-ENOMEM);
path[0].p_maxdepth = depth + 1;
@@ -1105,7 +1103,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
* We need this to handle errors and free blocks
* upon them.
*/
- ablocks = kcalloc(depth, sizeof(ext4_fsblk_t), gfp_flags);
+ ablocks = kzalloc_objs(ext4_fsblk_t, depth, gfp_flags);
if (!ablocks)
return -ENOMEM;
@@ -2947,8 +2945,8 @@ again:
path[k].p_block =
le16_to_cpu(path[k].p_hdr->eh_entries)+1;
} else {
- path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
- GFP_NOFS | __GFP_NOFAIL);
+ path = kzalloc_objs(struct ext4_ext_path, depth + 1,
+ GFP_NOFS | __GFP_NOFAIL);
path[0].p_maxdepth = path[0].p_depth = depth;
path[0].p_hdr = ext_inode_hdr(inode);
i = 0;
diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c
index 22fc333244ef..8b1138d2dc8e 100644
--- a/fs/ext4/fsmap.c
+++ b/fs/ext4/fsmap.c
@@ -348,7 +348,7 @@ static inline int ext4_getfsmap_fill(struct list_head *meta_list,
{
struct ext4_fsmap *fsm;
- fsm = kmalloc(sizeof(*fsm), GFP_NOFS);
+ fsm = kmalloc_obj(*fsm, GFP_NOFS);
if (!fsm)
return -ENOMEM;
fsm->fmr_device = 0;
diff --git a/fs/ext4/mballoc-test.c b/fs/ext4/mballoc-test.c
index 4abb40d4561c..6b448aad6f63 100644
--- a/fs/ext4/mballoc-test.c
+++ b/fs/ext4/mballoc-test.c
@@ -34,7 +34,7 @@ static struct inode *mbt_alloc_inode(struct super_block *sb)
{
struct ext4_inode_info *ei;
- ei = kmalloc(sizeof(struct ext4_inode_info), GFP_KERNEL);
+ ei = kmalloc_obj(struct ext4_inode_info, GFP_KERNEL);
if (!ei)
return NULL;
@@ -73,11 +73,11 @@ static int mbt_mb_init(struct super_block *sb)
int ret;
/* needed by ext4_mb_init->bdev_nonrot(sb->s_bdev) */
- sb->s_bdev = kzalloc(sizeof(*sb->s_bdev), GFP_KERNEL);
+ sb->s_bdev = kzalloc_obj(*sb->s_bdev, GFP_KERNEL);
if (sb->s_bdev == NULL)
return -ENOMEM;
- sb->s_bdev->bd_queue = kzalloc(sizeof(struct request_queue), GFP_KERNEL);
+ sb->s_bdev->bd_queue = kzalloc_obj(struct request_queue, GFP_KERNEL);
if (sb->s_bdev->bd_queue == NULL) {
kfree(sb->s_bdev);
return -ENOMEM;
@@ -137,7 +137,7 @@ static struct super_block *mbt_ext4_alloc_super_block(void)
struct super_block *sb;
struct ext4_sb_info *sbi;
- fsb = kzalloc(sizeof(*fsb), GFP_KERNEL);
+ fsb = kzalloc_obj(*fsb, GFP_KERNEL);
if (fsb == NULL)
return NULL;
@@ -148,7 +148,7 @@ static struct super_block *mbt_ext4_alloc_super_block(void)
sbi = &fsb->sbi;
sbi->s_blockgroup_lock =
- kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
+ kzalloc_obj(struct blockgroup_lock, GFP_KERNEL);
if (!sbi->s_blockgroup_lock)
goto out_deactivate;
@@ -252,8 +252,7 @@ static int mbt_ctx_init(struct super_block *sb)
struct mbt_ctx *ctx = MBT_CTX(sb);
ext4_group_t i, ngroups = ext4_get_groups_count(sb);
- ctx->grp_ctx = kcalloc(ngroups, sizeof(struct mbt_grp_ctx),
- GFP_KERNEL);
+ ctx->grp_ctx = kzalloc_objs(struct mbt_grp_ctx, ngroups, GFP_KERNEL);
if (ctx->grp_ctx == NULL)
return -ENOMEM;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index b99d1a7e580e..4d0bf2fcf2d3 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3754,8 +3754,7 @@ int ext4_mb_init(struct super_block *sb)
} while (i < MB_NUM_ORDERS(sb));
sbi->s_mb_avg_fragment_size =
- kmalloc_array(MB_NUM_ORDERS(sb), sizeof(struct xarray),
- GFP_KERNEL);
+ kmalloc_objs(struct xarray, MB_NUM_ORDERS(sb), GFP_KERNEL);
if (!sbi->s_mb_avg_fragment_size) {
ret = -ENOMEM;
goto out;
@@ -3764,8 +3763,7 @@ int ext4_mb_init(struct super_block *sb)
xa_init(&sbi->s_mb_avg_fragment_size[i]);
sbi->s_mb_largest_free_orders =
- kmalloc_array(MB_NUM_ORDERS(sb), sizeof(struct xarray),
- GFP_KERNEL);
+ kmalloc_objs(struct xarray, MB_NUM_ORDERS(sb), GFP_KERNEL);
if (!sbi->s_mb_largest_free_orders) {
ret = -ENOMEM;
goto out;
@@ -3817,8 +3815,9 @@ int ext4_mb_init(struct super_block *sb)
sbi->s_mb_nr_global_goals = umin(num_possible_cpus(),
DIV_ROUND_UP(sbi->s_groups_count, 4));
- sbi->s_mb_last_groups = kcalloc(sbi->s_mb_nr_global_goals,
- sizeof(ext4_group_t), GFP_KERNEL);
+ sbi->s_mb_last_groups = kzalloc_objs(ext4_group_t,
+ sbi->s_mb_nr_global_goals,
+ GFP_KERNEL);
if (sbi->s_mb_last_groups == NULL) {
ret = -ENOMEM;
goto out;
diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
index c9b93b670b0f..2dbaf3c01168 100644
--- a/fs/ext4/orphan.c
+++ b/fs/ext4/orphan.c
@@ -598,8 +598,7 @@ int ext4_init_orphan_info(struct super_block *sb)
}
oi->of_blocks = inode->i_size >> sb->s_blocksize_bits;
oi->of_csum_seed = EXT4_I(inode)->i_csum_seed;
- oi->of_binfo = kvmalloc_array(oi->of_blocks,
- sizeof(struct ext4_orphan_block),
+ oi->of_binfo = kvmalloc_objs(struct ext4_orphan_block, oi->of_blocks,
GFP_KERNEL);
if (!oi->of_binfo) {
ret = -ENOMEM;
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 76842f0957b5..780679645b6e 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -32,7 +32,7 @@ static void ext4_rcu_ptr_callback(struct rcu_head *head)
void ext4_kvfree_array_rcu(void *to_free)
{
- struct ext4_rcu_ptr *ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
+ struct ext4_rcu_ptr *ptr = kzalloc_obj(*ptr, GFP_KERNEL);
if (ptr) {
ptr->ptr = to_free;
@@ -242,7 +242,7 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned int flexbg_size,
unsigned int max_resize_bg;
struct ext4_new_flex_group_data *flex_gd;
- flex_gd = kmalloc(sizeof(*flex_gd), GFP_NOFS);
+ flex_gd = kmalloc_obj(*flex_gd, GFP_NOFS);
if (flex_gd == NULL)
goto out3;
@@ -260,9 +260,8 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned int flexbg_size,
if (WARN_ON_ONCE(flex_gd->resize_bg > max_resize_bg))
flex_gd->resize_bg = max_resize_bg;
- flex_gd->groups = kmalloc_array(flex_gd->resize_bg,
- sizeof(struct ext4_new_group_data),
- GFP_NOFS);
+ flex_gd->groups = kmalloc_objs(struct ext4_new_group_data,
+ flex_gd->resize_bg, GFP_NOFS);
if (flex_gd->groups == NULL)
goto out2;
@@ -1031,7 +1030,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
int res, i;
int err;
- primary = kmalloc_array(reserved_gdb, sizeof(*primary), GFP_NOFS);
+ primary = kmalloc_objs(*primary, reserved_gdb, GFP_NOFS);
if (!primary)
return -ENOMEM;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 504148b2142b..63784d9b1874 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2016,7 +2016,7 @@ int ext4_init_fs_context(struct fs_context *fc)
{
struct ext4_fs_context *ctx;
- ctx = kzalloc(sizeof(struct ext4_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct ext4_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
@@ -2496,11 +2496,11 @@ static int parse_apply_sb_mount_options(struct super_block *sb,
if (strscpy_pad(s_mount_opts, sbi->s_es->s_mount_opts) < 0)
return -E2BIG;
- fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL);
+ fc = kzalloc_obj(struct fs_context, GFP_KERNEL);
if (!fc)
return -ENOMEM;
- s_ctx = kzalloc(sizeof(struct ext4_fs_context), GFP_KERNEL);
+ s_ctx = kzalloc_obj(struct ext4_fs_context, GFP_KERNEL);
if (!s_ctx)
goto out_free;
@@ -3962,7 +3962,7 @@ static int ext4_li_info_new(void)
{
struct ext4_lazy_init *eli = NULL;
- eli = kzalloc(sizeof(*eli), GFP_KERNEL);
+ eli = kzalloc_obj(*eli, GFP_KERNEL);
if (!eli)
return -ENOMEM;
@@ -3981,7 +3981,7 @@ static struct ext4_li_request *ext4_li_request_new(struct super_block *sb,
{
struct ext4_li_request *elr;
- elr = kzalloc(sizeof(*elr), GFP_KERNEL);
+ elr = kzalloc_obj(*elr, GFP_KERNEL);
if (!elr)
return NULL;
@@ -4328,7 +4328,7 @@ static struct ext4_sb_info *ext4_alloc_sbi(struct super_block *sb)
{
struct ext4_sb_info *sbi;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return NULL;
@@ -4336,7 +4336,7 @@ static struct ext4_sb_info *ext4_alloc_sbi(struct super_block *sb)
NULL, NULL);
sbi->s_blockgroup_lock =
- kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
+ kzalloc_obj(struct blockgroup_lock, GFP_KERNEL);
if (!sbi->s_blockgroup_lock)
goto err_out;
@@ -4879,9 +4879,7 @@ static int ext4_group_desc_init(struct super_block *sb,
}
}
rcu_assign_pointer(sbi->s_group_desc,
- kvmalloc_array(db_count,
- sizeof(struct buffer_head *),
- GFP_KERNEL));
+ kvmalloc_objs(struct buffer_head *, db_count, GFP_KERNEL));
if (sbi->s_group_desc == NULL) {
ext4_msg(sb, KERN_ERR, "not enough memory");
return -ENOMEM;
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index d2ecc1026c0c..cdf78da85861 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -655,7 +655,7 @@ int __init ext4_init_sysfs(void)
if (!ext4_root)
return -ENOMEM;
- ext4_feat = kzalloc(sizeof(*ext4_feat), GFP_KERNEL);
+ ext4_feat = kzalloc_obj(*ext4_feat, GFP_KERNEL);
if (!ext4_feat) {
ret = -ENOMEM;
goto root_err;
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 4ed8ddf2a60b..7bf9ba19a89d 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -390,7 +390,7 @@ static int ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t size)
int i, ret;
if (bh_count > ARRAY_SIZE(bhs_inline)) {
- bhs = kmalloc_array(bh_count, sizeof(*bhs), GFP_NOFS);
+ bhs = kmalloc_objs(*bhs, bh_count, GFP_NOFS);
if (!bhs)
return -ENOMEM;
}
@@ -2618,8 +2618,8 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
int needs_kvfree = 0;
int error;
- is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS);
- bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS);
+ is = kzalloc_obj(struct ext4_xattr_ibody_find, GFP_NOFS);
+ bs = kzalloc_obj(struct ext4_xattr_block_find, GFP_NOFS);
b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS);
if (!is || !bs || !b_entry_name) {
error = -ENOMEM;
@@ -2876,9 +2876,8 @@ ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array,
/*
* Start with 15 inodes, so it fits into a power-of-two size.
*/
- (*ea_inode_array) = kmalloc(
- struct_size(*ea_inode_array, inodes, EIA_MASK),
- GFP_NOFS);
+ (*ea_inode_array) = kmalloc_flex(**ea_inode_array, inodes,
+ EIA_MASK, GFP_NOFS);
if (*ea_inode_array == NULL)
return -ENOMEM;
(*ea_inode_array)->count = 0;
@@ -2886,10 +2885,9 @@ ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array,
/* expand the array once all 15 + n * 16 slots are full */
struct ext4_xattr_inode_array *new_array = NULL;
- new_array = kmalloc(
- struct_size(*ea_inode_array, inodes,
- (*ea_inode_array)->count + EIA_INCR),
- GFP_NOFS);
+ new_array = kmalloc_flex(**ea_inode_array, inodes,
+ (*ea_inode_array)->count + EIA_INCR,
+ GFP_NOFS);
if (new_array == NULL)
return -ENOMEM;
memcpy(new_array, *ea_inode_array,
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7c8e6eea60df..2a12fe8eb668 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3725,7 +3725,7 @@ static struct block_device **f2fs_get_devices(struct super_block *sb,
if (!f2fs_is_multi_device(sbi))
return NULL;
- devs = kmalloc_array(sbi->s_ndevs, sizeof(*devs), GFP_KERNEL);
+ devs = kmalloc_objs(*devs, sbi->s_ndevs, GFP_KERNEL);
if (!devs)
return ERR_PTR(-ENOMEM);
@@ -4501,7 +4501,7 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi,
struct f2fs_super_block *super;
int err = 0;
- super = kzalloc(sizeof(struct f2fs_super_block), GFP_KERNEL);
+ super = kzalloc_obj(struct f2fs_super_block, GFP_KERNEL);
if (!super)
return -ENOMEM;
@@ -4938,7 +4938,7 @@ try_onemore:
recovery = 0;
/* allocate memory for f2fs-specific super block info */
- sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct f2fs_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
@@ -5509,7 +5509,7 @@ static int f2fs_init_fs_context(struct fs_context *fc)
{
struct f2fs_fs_context *ctx;
- ctx = kzalloc(sizeof(struct f2fs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct f2fs_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 59fa90617b5b..175e8e66c29f 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1554,7 +1554,7 @@ int fat_fill_super(struct super_block *sb, struct fs_context *fc,
* the filesystem, since we're only just about to mount
* it and have no inodes etc active!
*/
- sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct msdos_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
@@ -1905,7 +1905,7 @@ int fat_init_fs_context(struct fs_context *fc, bool is_vfat)
{
struct fat_mount_options *opts;
- opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kzalloc_obj(*opts, GFP_KERNEL);
if (!opts)
return -ENOMEM;
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 2acfe3123a72..87dcdd86272b 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -663,7 +663,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname,
if (len == 0)
return -ENOENT;
- slots = kmalloc_array(MSDOS_SLOTS, sizeof(*slots), GFP_NOFS);
+ slots = kmalloc_objs(*slots, MSDOS_SLOTS, GFP_NOFS);
if (slots == NULL)
return -ENOMEM;
diff --git a/fs/fcntl.c b/fs/fcntl.c
index f93dbca08435..c9c73305011e 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -100,7 +100,7 @@ int file_f_owner_allocate(struct file *file)
if (f_owner)
return 0;
- f_owner = kzalloc(sizeof(struct fown_struct), GFP_KERNEL);
+ f_owner = kzalloc_obj(struct fown_struct, GFP_KERNEL);
if (!f_owner)
return -ENOMEM;
diff --git a/fs/fhandle.c b/fs/fhandle.c
index e15bcf4b0b23..fa4053f9e015 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -46,8 +46,8 @@ static long do_sys_name_to_handle(const struct path *path,
if (f_handle.handle_bytes > MAX_HANDLE_SZ)
return -EINVAL;
- handle = kzalloc(struct_size(handle, f_handle, f_handle.handle_bytes),
- GFP_KERNEL);
+ handle = kzalloc_flex(*handle, f_handle, f_handle.handle_bytes,
+ GFP_KERNEL);
if (!handle)
return -ENOMEM;
@@ -368,8 +368,8 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
if (retval)
goto out_path;
- handle = kmalloc(struct_size(handle, f_handle, f_handle.handle_bytes),
- GFP_KERNEL);
+ handle = kmalloc_flex(*handle, f_handle, f_handle.handle_bytes,
+ GFP_KERNEL);
if (!handle) {
retval = -ENOMEM;
goto out_path;
diff --git a/fs/file.c b/fs/file.c
index 51ddcff0081a..384c83ce768d 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -212,11 +212,11 @@ static struct fdtable *alloc_fdtable(unsigned int slots_wanted)
if (unlikely(nr > INT_MAX / sizeof(struct file *)))
return ERR_PTR(-EMFILE);
- fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT);
+ fdt = kmalloc_obj(struct fdtable, GFP_KERNEL_ACCOUNT);
if (!fdt)
goto out;
fdt->max_fds = nr;
- data = kvmalloc_array(nr, sizeof(struct file *), GFP_KERNEL_ACCOUNT);
+ data = kvmalloc_objs(struct file *, nr, GFP_KERNEL_ACCOUNT);
if (!data)
goto out_fdt;
fdt->fd = data;
diff --git a/fs/freevxfs/vxfs_fshead.c b/fs/freevxfs/vxfs_fshead.c
index c1174a3f8990..c1d90905b7b2 100644
--- a/fs/freevxfs/vxfs_fshead.c
+++ b/fs/freevxfs/vxfs_fshead.c
@@ -58,7 +58,7 @@ vxfs_getfsh(struct inode *ip, int which)
if (bp) {
struct vxfs_fsh *fhp;
- if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL)))
+ if (!(fhp = kmalloc_obj(*fhp, GFP_KERNEL)))
goto out;
memcpy(fhp, bp->b_data, sizeof(*fhp));
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
index fabe60778658..44b4958277ce 100644
--- a/fs/freevxfs/vxfs_super.c
+++ b/fs/freevxfs/vxfs_super.c
@@ -193,7 +193,7 @@ static int vxfs_fill_super(struct super_block *sbp, struct fs_context *fc)
sbp->s_flags |= SB_RDONLY;
- infp = kzalloc(sizeof(*infp), GFP_KERNEL);
+ infp = kzalloc_obj(*infp, GFP_KERNEL);
if (!infp) {
warnf(fc, "vxfs: unable to allocate incore superblock");
return -ENOMEM;
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 68228bf89b82..22a1996c00cd 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -653,7 +653,7 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
if (atomic_read(&isw_nr_in_flight) > WB_FRN_MAX_IN_FLIGHT)
return;
- isw = kzalloc(struct_size(isw, inodes, 2), GFP_ATOMIC);
+ isw = kzalloc_flex(*isw, inodes, 2, GFP_ATOMIC);
if (!isw)
return;
@@ -724,8 +724,7 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb)
int nr;
bool restart = false;
- isw = kzalloc(struct_size(isw, inodes, WB_MAX_INODES_PER_ISW),
- GFP_KERNEL);
+ isw = kzalloc_flex(*isw, inodes, WB_MAX_INODES_PER_ISW, GFP_KERNEL);
if (!isw)
return restart;
@@ -1075,7 +1074,7 @@ restart:
nr_pages = wb_split_bdi_pages(wb, base_work->nr_pages);
- work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ work = kmalloc_obj(*work, GFP_ATOMIC);
if (work) {
*work = *base_work;
work->nr_pages = nr_pages;
@@ -1173,7 +1172,7 @@ int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
dirty = dirty * 10 / 8;
/* issue the writeback work */
- work = kzalloc(sizeof(*work), GFP_NOWAIT);
+ work = kzalloc_obj(*work, GFP_NOWAIT);
if (work) {
work->nr_pages = dirty;
work->sync_mode = WB_SYNC_NONE;
diff --git a/fs/fs_context.c b/fs/fs_context.c
index 81ed94f46cac..a37b0a093505 100644
--- a/fs/fs_context.c
+++ b/fs/fs_context.c
@@ -264,7 +264,7 @@ static struct fs_context *alloc_fs_context(struct file_system_type *fs_type,
struct fs_context *fc;
int ret = -ENOMEM;
- fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL_ACCOUNT);
+ fc = kzalloc_obj(struct fs_context, GFP_KERNEL_ACCOUNT);
if (!fc)
return ERR_PTR(-ENOMEM);
diff --git a/fs/fsopen.c b/fs/fsopen.c
index 614922623675..a23f003ae056 100644
--- a/fs/fsopen.c
+++ b/fs/fsopen.c
@@ -102,7 +102,7 @@ static int fscontext_create_fd(struct fs_context *fc, unsigned int o_flags)
static int fscontext_alloc_log(struct fs_context *fc)
{
- fc->log.log = kzalloc(sizeof(*fc->log.log), GFP_KERNEL);
+ fc->log.log = kzalloc_obj(*fc->log.log, GFP_KERNEL);
if (!fc->log.log)
return -ENOMEM;
refcount_set(&fc->log.log->usage, 1);
diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c
index 4afda419dd14..45a78ee15e3c 100644
--- a/fs/fuse/backing.c
+++ b/fs/fuse/backing.c
@@ -112,7 +112,7 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)
if (backing_sb->s_stack_depth >= fc->max_stack_depth)
goto out_fput;
- fb = kmalloc(sizeof(struct fuse_backing), GFP_KERNEL);
+ fb = kmalloc_obj(struct fuse_backing, GFP_KERNEL);
res = -ENOMEM;
if (!fb)
goto out_fput;
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index 28c96961e85d..0aace951541b 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -362,7 +362,7 @@ static void cuse_process_init_reply(struct fuse_mount *fm,
/* devt determined, create device */
rc = -ENOMEM;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev)
goto err_region;
@@ -443,7 +443,7 @@ static int cuse_send_init(struct cuse_conn *cc)
if (!folio)
goto err;
- ia = kzalloc(sizeof(*ia), GFP_KERNEL);
+ ia = kzalloc_obj(*ia, GFP_KERNEL);
if (!ia)
goto err_free_folio;
@@ -505,7 +505,7 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
int rc;
/* set up cuse_conn */
- cc = kzalloc(sizeof(*cc), GFP_KERNEL);
+ cc = kzalloc_obj(*cc, GFP_KERNEL);
if (!cc)
return -ENOMEM;
diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c
index ac6d4c1064cc..7d11eac4f629 100644
--- a/fs/fuse/dax.c
+++ b/fs/fuse/dax.c
@@ -257,7 +257,7 @@ static int dmap_removemapping_list(struct inode *inode, unsigned int num,
int ret, i = 0, nr_alloc;
nr_alloc = min_t(unsigned int, num, FUSE_REMOVEMAPPING_MAX_ENTRY);
- remove_one = kmalloc_array(nr_alloc, sizeof(*remove_one), GFP_NOFS);
+ remove_one = kmalloc_objs(*remove_one, nr_alloc, GFP_NOFS);
if (!remove_one)
return -ENOMEM;
@@ -1219,7 +1219,7 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
__func__, nr_pages, nr_ranges);
for (i = 0; i < nr_ranges; i++) {
- range = kzalloc(sizeof(struct fuse_dax_mapping), GFP_KERNEL);
+ range = kzalloc_obj(struct fuse_dax_mapping, GFP_KERNEL);
ret = -ENOMEM;
if (!range)
goto out_err;
@@ -1255,7 +1255,7 @@ int fuse_dax_conn_alloc(struct fuse_conn *fc, enum fuse_dax_mode dax_mode,
if (!dax_dev)
return 0;
- fcd = kzalloc(sizeof(*fcd), GFP_KERNEL);
+ fcd = kzalloc_obj(*fcd, GFP_KERNEL);
if (!fcd)
return -ENOMEM;
@@ -1277,7 +1277,7 @@ bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi)
fi->dax = NULL;
if (fc->dax) {
- fi->dax = kzalloc(sizeof(*fi->dax), GFP_KERNEL_ACCOUNT);
+ fi->dax = kzalloc_obj(*fi->dax, GFP_KERNEL_ACCOUNT);
if (!fi->dax)
return false;
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index a30c8b57d478..3ec0fa236da0 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1598,8 +1598,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
if (IS_ERR(fud))
return PTR_ERR(fud);
- bufs = kvmalloc_array(pipe->max_usage, sizeof(struct pipe_buffer),
- GFP_KERNEL);
+ bufs = kvmalloc_objs(struct pipe_buffer, pipe->max_usage, GFP_KERNEL);
if (!bufs)
return -ENOMEM;
@@ -2311,7 +2310,7 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,
tail = pipe->tail;
count = pipe_occupancy(head, tail);
- bufs = kvmalloc_array(count, sizeof(struct pipe_buffer), GFP_KERNEL);
+ bufs = kvmalloc_objs(struct pipe_buffer, count, GFP_KERNEL);
if (!bufs) {
pipe_unlock(pipe);
return -ENOMEM;
diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 5ceb217ced1b..aee37347b652 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -231,12 +231,12 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc)
struct fuse_ring *res = NULL;
size_t max_payload_size;
- ring = kzalloc(sizeof(*fc->ring), GFP_KERNEL_ACCOUNT);
+ ring = kzalloc_obj(*fc->ring, GFP_KERNEL_ACCOUNT);
if (!ring)
return NULL;
- ring->queues = kcalloc(nr_queues, sizeof(struct fuse_ring_queue *),
- GFP_KERNEL_ACCOUNT);
+ ring->queues = kzalloc_objs(struct fuse_ring_queue *, nr_queues,
+ GFP_KERNEL_ACCOUNT);
if (!ring->queues)
goto out_err;
@@ -274,10 +274,10 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring,
struct fuse_ring_queue *queue;
struct list_head *pq;
- queue = kzalloc(sizeof(*queue), GFP_KERNEL_ACCOUNT);
+ queue = kzalloc_obj(*queue, GFP_KERNEL_ACCOUNT);
if (!queue)
return NULL;
- pq = kcalloc(FUSE_PQ_HASH_SIZE, sizeof(struct list_head), GFP_KERNEL);
+ pq = kzalloc_objs(struct list_head, FUSE_PQ_HASH_SIZE, GFP_KERNEL);
if (!pq) {
kfree(queue);
return NULL;
@@ -1062,7 +1062,7 @@ fuse_uring_create_ring_ent(struct io_uring_cmd *cmd,
}
err = -ENOMEM;
- ent = kzalloc(sizeof(*ent), GFP_KERNEL_ACCOUNT);
+ ent = kzalloc_obj(*ent, GFP_KERNEL_ACCOUNT);
if (!ent)
return ERR_PTR(err);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index f25ee47822ad..7ac6b232ef12 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -473,8 +473,8 @@ static int fuse_dentry_init(struct dentry *dentry)
{
struct fuse_dentry *fd;
- fd = kzalloc(sizeof(struct fuse_dentry),
- GFP_KERNEL_ACCOUNT | __GFP_RECLAIMABLE);
+ fd = kzalloc_obj(struct fuse_dentry,
+ GFP_KERNEL_ACCOUNT | __GFP_RECLAIMABLE);
if (!fd)
return -ENOMEM;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 80765ab6d04a..e29aecdab97e 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -56,13 +56,13 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release)
{
struct fuse_file *ff;
- ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL_ACCOUNT);
+ ff = kzalloc_obj(struct fuse_file, GFP_KERNEL_ACCOUNT);
if (unlikely(!ff))
return NULL;
ff->fm = fm;
if (release) {
- ff->args = kzalloc(sizeof(*ff->args), GFP_KERNEL_ACCOUNT);
+ ff->args = kzalloc_obj(*ff->args, GFP_KERNEL_ACCOUNT);
if (!ff->args) {
kfree(ff);
return NULL;
@@ -684,7 +684,7 @@ static struct fuse_io_args *fuse_io_alloc(struct fuse_io_priv *io,
{
struct fuse_io_args *ia;
- ia = kzalloc(sizeof(*ia), GFP_KERNEL);
+ ia = kzalloc_obj(*ia, GFP_KERNEL);
if (ia) {
ia->io = io;
ia->ap.folios = fuse_folios_alloc(nfolios, GFP_KERNEL,
@@ -2045,7 +2045,7 @@ static struct fuse_writepage_args *fuse_writepage_args_alloc(void)
struct fuse_writepage_args *wpa;
struct fuse_args_pages *ap;
- wpa = kzalloc(sizeof(*wpa), GFP_NOFS);
+ wpa = kzalloc_obj(*wpa, GFP_NOFS);
if (wpa) {
ap = &wpa->ia.ap;
ap->num_folios = 0;
@@ -2834,7 +2834,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
if ((iov_iter_rw(iter) == READ) && (offset >= i_size))
return 0;
- io = kmalloc(sizeof(struct fuse_io_priv), GFP_KERNEL);
+ io = kmalloc_obj(struct fuse_io_priv, GFP_KERNEL);
if (!io)
return -ENOMEM;
spin_lock_init(&io->lock);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 819e50d66622..3db0fe0d764b 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -74,14 +74,14 @@ static struct file_system_type fuseblk_fs_type;
struct fuse_forget_link *fuse_alloc_forget(void)
{
- return kzalloc(sizeof(struct fuse_forget_link), GFP_KERNEL_ACCOUNT);
+ return kzalloc_obj(struct fuse_forget_link, GFP_KERNEL_ACCOUNT);
}
static struct fuse_submount_lookup *fuse_alloc_submount_lookup(void)
{
struct fuse_submount_lookup *sl;
- sl = kzalloc(sizeof(struct fuse_submount_lookup), GFP_KERNEL_ACCOUNT);
+ sl = kzalloc_obj(struct fuse_submount_lookup, GFP_KERNEL_ACCOUNT);
if (!sl)
return NULL;
sl->forget = fuse_alloc_forget();
@@ -684,7 +684,7 @@ static struct fuse_sync_bucket *fuse_sync_bucket_alloc(void)
{
struct fuse_sync_bucket *bucket;
- bucket = kzalloc(sizeof(*bucket), GFP_KERNEL | __GFP_NOFAIL);
+ bucket = kzalloc_obj(*bucket, GFP_KERNEL | __GFP_NOFAIL);
if (bucket) {
init_waitqueue_head(&bucket->waitq);
/* Initial active count */
@@ -1487,7 +1487,7 @@ static struct fuse_init_args *fuse_new_init(struct fuse_mount *fm)
struct fuse_init_args *ia;
u64 flags;
- ia = kzalloc(sizeof(*ia), GFP_KERNEL | __GFP_NOFAIL);
+ ia = kzalloc_obj(*ia, GFP_KERNEL | __GFP_NOFAIL);
ia->in.major = FUSE_KERNEL_VERSION;
ia->in.minor = FUSE_KERNEL_MINOR_VERSION;
@@ -1618,11 +1618,11 @@ struct fuse_dev *fuse_dev_alloc(void)
struct fuse_dev *fud;
struct list_head *pq;
- fud = kzalloc(sizeof(struct fuse_dev), GFP_KERNEL);
+ fud = kzalloc_obj(struct fuse_dev, GFP_KERNEL);
if (!fud)
return NULL;
- pq = kcalloc(FUSE_PQ_HASH_SIZE, sizeof(struct list_head), GFP_KERNEL);
+ pq = kzalloc_objs(struct list_head, FUSE_PQ_HASH_SIZE, GFP_KERNEL);
if (!pq) {
kfree(fud);
return NULL;
@@ -1780,7 +1780,7 @@ static int fuse_get_tree_submount(struct fs_context *fsc)
struct super_block *sb;
int err;
- fm = kzalloc(sizeof(struct fuse_mount), GFP_KERNEL);
+ fm = kzalloc_obj(struct fuse_mount, GFP_KERNEL);
if (!fm)
return -ENOMEM;
@@ -1981,11 +1981,11 @@ static int fuse_get_tree(struct fs_context *fsc)
struct super_block *sb;
int err;
- fc = kmalloc(sizeof(*fc), GFP_KERNEL);
+ fc = kmalloc_obj(*fc, GFP_KERNEL);
if (!fc)
return -ENOMEM;
- fm = kzalloc(sizeof(*fm), GFP_KERNEL);
+ fm = kzalloc_obj(*fm, GFP_KERNEL);
if (!fm) {
kfree(fc);
return -ENOMEM;
@@ -2047,7 +2047,7 @@ static int fuse_init_fs_context(struct fs_context *fsc)
{
struct fuse_fs_context *ctx;
- ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct fuse_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index b2f6486fe1d5..dc96ee0b952a 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -839,7 +839,7 @@ static void virtio_fs_requests_done_work(struct work_struct *work)
if (req->args->may_block) {
struct virtio_fs_req_work *w;
- w = kzalloc(sizeof(*w), GFP_NOFS | __GFP_NOFAIL);
+ w = kzalloc_obj(*w, GFP_NOFS | __GFP_NOFAIL);
INIT_WORK(&w->done_work, virtio_fs_complete_req_work);
w->fsvq = fsvq;
w->req = req;
@@ -947,14 +947,14 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev,
fs->num_request_queues = min_t(unsigned int, fs->num_request_queues,
nr_cpu_ids);
fs->nvqs = VQ_REQUEST + fs->num_request_queues;
- fs->vqs = kcalloc(fs->nvqs, sizeof(fs->vqs[VQ_HIPRIO]), GFP_KERNEL);
+ fs->vqs = kzalloc_objs(fs->vqs[VQ_HIPRIO], fs->nvqs, GFP_KERNEL);
if (!fs->vqs)
return -ENOMEM;
- vqs = kmalloc_array(fs->nvqs, sizeof(vqs[VQ_HIPRIO]), GFP_KERNEL);
+ vqs = kmalloc_objs(vqs[VQ_HIPRIO], fs->nvqs, GFP_KERNEL);
fs->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*fs->mq_map), GFP_KERNEL,
dev_to_node(&vdev->dev));
- vqs_info = kcalloc(fs->nvqs, sizeof(*vqs_info), GFP_KERNEL);
+ vqs_info = kzalloc_objs(*vqs_info, fs->nvqs, GFP_KERNEL);
if (!vqs || !vqs_info || !fs->mq_map) {
ret = -ENOMEM;
goto out;
@@ -1120,7 +1120,7 @@ static int virtio_fs_probe(struct virtio_device *vdev)
struct virtio_fs *fs;
int ret;
- fs = kzalloc(sizeof(*fs), GFP_KERNEL);
+ fs = kzalloc_obj(*fs, GFP_KERNEL);
if (!fs)
return -ENOMEM;
kobject_init(&fs->kobj, &virtio_fs_ktype);
@@ -1240,7 +1240,7 @@ static void virtio_fs_send_forget(struct fuse_iqueue *fiq, struct fuse_forget_li
u64 unique = fuse_get_unique(fiq);
/* Allocate a buffer for the request */
- forget = kmalloc(sizeof(*forget), GFP_NOFS | __GFP_NOFAIL);
+ forget = kmalloc_obj(*forget, GFP_NOFS | __GFP_NOFAIL);
req = &forget->req;
req->ih = (struct fuse_in_header){
@@ -1390,8 +1390,8 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
/* Does the sglist fit on the stack? */
total_sgs = sg_count_fuse_req(req);
if (total_sgs > ARRAY_SIZE(stack_sgs)) {
- sgs = kmalloc_array(total_sgs, sizeof(sgs[0]), gfp);
- sg = kmalloc_array(total_sgs, sizeof(sg[0]), gfp);
+ sgs = kmalloc_objs(sgs[0], total_sgs, gfp);
+ sg = kmalloc_objs(sg[0], total_sgs, gfp);
if (!sgs || !sg) {
ret = -ENOMEM;
goto out;
@@ -1684,11 +1684,11 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
goto out_err;
err = -ENOMEM;
- fc = kzalloc(sizeof(struct fuse_conn), GFP_KERNEL);
+ fc = kzalloc_obj(struct fuse_conn, GFP_KERNEL);
if (!fc)
goto out_err;
- fm = kzalloc(sizeof(struct fuse_mount), GFP_KERNEL);
+ fm = kzalloc_obj(struct fuse_mount, GFP_KERNEL);
if (!fm)
goto out_err;
@@ -1743,7 +1743,7 @@ static int virtio_fs_init_fs_context(struct fs_context *fsc)
if (fsc->purpose == FS_CONTEXT_FOR_SUBMOUNT)
return fuse_init_fs_context_submount(fsc);
- ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct fuse_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
fsc->fs_private = ctx;
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index fdcac8e3f2ba..1cd8ec0bce83 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -2225,7 +2225,7 @@ static int gfs2_add_jextent(struct gfs2_jdesc *jd, u64 lblock, u64 dblock, u64 b
}
}
- jext = kzalloc(sizeof(struct gfs2_journal_extent), GFP_NOFS);
+ jext = kzalloc_obj(struct gfs2_journal_extent, GFP_NOFS);
if (jext == NULL)
return -ENOMEM;
jext->dblock = dblock;
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 509e2f0d97e7..022dbb31e0d9 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1593,7 +1593,7 @@ int gfs2_dir_read(struct inode *inode, struct dir_context *ctx,
error = -ENOMEM;
/* 96 is max number of dirents which can be stuffed into an inode */
- darr = kmalloc_array(96, sizeof(struct gfs2_dirent *), GFP_NOFS);
+ darr = kmalloc_objs(struct gfs2_dirent *, 96, GFP_NOFS);
if (darr) {
g.pdent = (const struct gfs2_dirent **)darr;
g.offset = 0;
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 3e061e8115ec..9704f1ef6ad1 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -637,7 +637,7 @@ int gfs2_open_common(struct inode *inode, struct file *file)
file->f_mode |= FMODE_CAN_ODIRECT;
}
- fp = kzalloc(sizeof(struct gfs2_file), GFP_NOFS);
+ fp = kzalloc_obj(struct gfs2_file, GFP_NOFS);
if (!fp)
return -ENOMEM;
@@ -1029,7 +1029,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb,
*/
if (inode == sdp->sd_rindex) {
- statfs_gh = kmalloc(sizeof(*statfs_gh), GFP_NOFS);
+ statfs_gh = kmalloc_obj(*statfs_gh, GFP_NOFS);
if (!statfs_gh)
return -ENOMEM;
}
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 6fb2731e8be1..2acbabccc8ad 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1764,8 +1764,7 @@ int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs)
default:
if (num_gh <= 4)
break;
- pph = kmalloc_array(num_gh, sizeof(struct gfs2_holder *),
- GFP_NOFS);
+ pph = kmalloc_objs(struct gfs2_holder *, num_gh, GFP_NOFS);
if (!pph)
return -ENOMEM;
}
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index c7d57de7c8f0..f3f649fc5cb1 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -76,7 +76,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
{
struct gfs2_sbd *sdp;
- sdp = kzalloc(sizeof(struct gfs2_sbd), GFP_KERNEL);
+ sdp = kzalloc_obj(struct gfs2_sbd, GFP_KERNEL);
if (!sdp)
return NULL;
@@ -562,7 +562,7 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
break;
error = -ENOMEM;
- jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL);
+ jd = kzalloc_obj(struct gfs2_jdesc, GFP_KERNEL);
if (!jd)
break;
@@ -631,7 +631,7 @@ static int init_statfs(struct gfs2_sbd *sdp)
* per_node metafs directory and save it in the sdp->sd_sc_inodes_list. */
list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
struct local_statfs_inode *lsi =
- kmalloc(sizeof(struct local_statfs_inode), GFP_NOFS);
+ kmalloc_obj(struct local_statfs_inode, GFP_NOFS);
if (!lsi) {
error = -ENOMEM;
goto free_local;
@@ -1637,7 +1637,7 @@ static int gfs2_init_fs_context(struct fs_context *fc)
{
struct gfs2_args *args;
- args = kmalloc(sizeof(*args), GFP_KERNEL);
+ args = kmalloc_obj(*args, GFP_KERNEL);
if (args == NULL)
return -ENOMEM;
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 1c3455093ae8..af3dfeed62fe 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -908,7 +908,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda,
gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota),
&data_blocks, &ind_blocks);
- ghs = kmalloc_array(num_qd, sizeof(struct gfs2_holder), GFP_NOFS);
+ ghs = kmalloc_objs(struct gfs2_holder, num_qd, GFP_NOFS);
if (!ghs)
return -ENOMEM;
@@ -1318,7 +1318,7 @@ int gfs2_quota_sync(struct super_block *sb, int type)
if (sb_rdonly(sdp->sd_vfs))
return 0;
- qda = kcalloc(max_qd, sizeof(struct gfs2_quota_data *), GFP_KERNEL);
+ qda = kzalloc_objs(struct gfs2_quota_data *, max_qd, GFP_KERNEL);
if (!qda)
return -ENOMEM;
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 8c8202c68b64..616c46aa3434 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -69,7 +69,7 @@ int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
return 0;
}
- rr = kmalloc(sizeof(struct gfs2_revoke_replay), GFP_NOFS);
+ rr = kmalloc_obj(struct gfs2_revoke_replay, GFP_NOFS);
if (!rr)
return -ENOMEM;
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 8a97ca734afc..441774cc07ce 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -763,7 +763,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)
if (!length)
return -EINVAL;
- rgd->rd_bits = kcalloc(length, sizeof(struct gfs2_bitmap), GFP_NOFS);
+ rgd->rd_bits = kzalloc_objs(struct gfs2_bitmap, length, GFP_NOFS);
if (!rgd->rd_bits)
return -ENOMEM;
@@ -2699,8 +2699,8 @@ void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
if (rlist->rl_rgrps == rlist->rl_space) {
new_space = rlist->rl_space + 10;
- tmp = kcalloc(new_space, sizeof(struct gfs2_rgrpd *),
- GFP_NOFS | __GFP_NOFAIL);
+ tmp = kzalloc_objs(struct gfs2_rgrpd *, new_space,
+ GFP_NOFS | __GFP_NOFAIL);
if (rlist->rl_rgd) {
memcpy(tmp, rlist->rl_rgd,
@@ -2731,9 +2731,8 @@ void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist,
{
unsigned int x;
- rlist->rl_ghs = kmalloc_array(rlist->rl_rgrps,
- sizeof(struct gfs2_holder),
- GFP_NOFS | __GFP_NOFAIL);
+ rlist->rl_ghs = kmalloc_objs(struct gfs2_holder, rlist->rl_rgrps,
+ GFP_NOFS | __GFP_NOFAIL);
for (x = 0; x < rlist->rl_rgrps; x++)
gfs2_holder_init(rlist->rl_rgd[x]->rd_gl, state, flags,
&rlist->rl_ghs[x]);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index d96160636161..9a655588c0c5 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -336,7 +336,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp)
*/
list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
- lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL);
+ lfcc = kmalloc_obj(struct lfcc, GFP_KERNEL);
if (!lfcc) {
error = -ENOMEM;
goto out;
@@ -860,7 +860,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host
int error = 0, err;
memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
- gha = kmalloc_array(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
+ gha = kmalloc_objs(struct gfs2_holder, slots, GFP_KERNEL);
if (!gha)
return -ENOMEM;
for (x = 0; x < slots; x++)
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index df9c93de94c7..b9f48d6f10a9 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -467,7 +467,7 @@ static int gfs2_iter_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
unsigned char *pos;
unsigned cp_size;
- bh = kcalloc(nptrs, sizeof(struct buffer_head *), GFP_NOFS);
+ bh = kzalloc_objs(struct buffer_head *, nptrs, GFP_NOFS);
if (!bh)
return -ENOMEM;
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 7bc425283d49..b5ee0e072935 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -28,7 +28,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
sector_t start_block;
loff_t offset;
- tree = kzalloc(sizeof(*tree), GFP_KERNEL);
+ tree = kzalloc_obj(*tree, GFP_KERNEL);
if (!tree)
return NULL;
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 0c615c078650..80277979c09c 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -148,7 +148,7 @@ static int hfs_readdir(struct file *file, struct dir_context *ctx)
}
rd = file->private_data;
if (!rd) {
- rd = kmalloc(sizeof(struct hfs_readdir_data), GFP_KERNEL);
+ rd = kmalloc_obj(struct hfs_readdir_data, GFP_KERNEL);
if (!rd) {
err = -ENOMEM;
goto out;
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 97546d6b41f4..78dc9dabb0c1 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -411,7 +411,7 @@ static int hfs_init_fs_context(struct fs_context *fc)
{
struct hfs_sb_info *hsb;
- hsb = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL);
+ hsb = kzalloc_obj(struct hfs_sb_info, GFP_KERNEL);
if (!hsb)
return -ENOMEM;
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index 229f25dc7c49..5016d97290c8 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -139,7 +139,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
struct page *page;
unsigned int size;
- tree = kzalloc(sizeof(*tree), GFP_KERNEL);
+ tree = kzalloc_obj(*tree, GFP_KERNEL);
if (!tree)
return NULL;
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index ca5f74a140ec..9998b28aa8f7 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -263,7 +263,7 @@ next:
}
rd = file->private_data;
if (!rd) {
- rd = kmalloc(sizeof(struct hfsplus_readdir_data), GFP_KERNEL);
+ rd = kmalloc_obj(struct hfsplus_readdir_data, GFP_KERNEL);
if (!rd) {
err = -ENOMEM;
goto out;
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 592d8fbb748c..f60f37caea65 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -698,7 +698,7 @@ static int hfsplus_init_fs_context(struct fs_context *fc)
{
struct hfsplus_sb_info *sbi;
- sbi = kzalloc(sizeof(struct hfsplus_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct hfsplus_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
diff --git a/fs/hfsplus/unicode_test.c b/fs/hfsplus/unicode_test.c
index 5a7a6859efe3..c162c0fea4a8 100644
--- a/fs/hfsplus/unicode_test.c
+++ b/fs/hfsplus/unicode_test.c
@@ -22,7 +22,7 @@ static struct test_mock_string_env *setup_mock_str_env(u32 buf_size)
{
struct test_mock_string_env *env;
- env = kzalloc(sizeof(struct test_mock_string_env), GFP_KERNEL);
+ env = kzalloc_obj(struct test_mock_string_env, GFP_KERNEL);
if (!env)
return NULL;
@@ -393,7 +393,7 @@ static struct test_mock_sb *setup_mock_sb(void)
{
struct test_mock_sb *ptr;
- ptr = kzalloc(sizeof(struct test_mock_sb), GFP_KERNEL);
+ ptr = kzalloc_obj(struct test_mock_sb, GFP_KERNEL);
if (!ptr)
return NULL;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 51d26aa2b93e..2c463a8c0ab4 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -1047,7 +1047,7 @@ static int hostfs_init_fs_context(struct fs_context *fc)
{
struct hostfs_fs_info *fsi;
- fsi = kzalloc(sizeof(*fsi), GFP_KERNEL);
+ fsi = kzalloc_obj(*fsi, GFP_KERNEL);
if (!fsi)
return -ENOMEM;
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index 4ada525c5c43..dde764ebe246 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -33,7 +33,7 @@ int hpfs_add_pos(struct inode *inode, loff_t *pos)
if (hpfs_inode->i_rddir_off[i] == pos)
return 0;
if (!(i&0x0f)) {
- ppos = kmalloc_array(i + 0x11, sizeof(loff_t *), GFP_NOFS);
+ ppos = kmalloc_objs(loff_t *, i + 0x11, GFP_NOFS);
if (!ppos) {
pr_err("out of memory for position list\n");
return -ENOMEM;
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 371aa6de8075..0f17b7710ae5 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -513,7 +513,7 @@ static int hpfs_fill_super(struct super_block *s, struct fs_context *fc)
struct hpfs_dirent *de = NULL;
struct quad_buffer_head qbh;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi) {
return -ENOMEM;
}
@@ -715,7 +715,7 @@ static int hpfs_init_fs_context(struct fs_context *fc)
{
struct hpfs_fc_context *ctx;
- ctx = kzalloc(sizeof(struct hpfs_fc_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct hpfs_fc_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 95a5b23b4808..8e2c1fbdfd86 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1407,7 +1407,7 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc)
struct hugetlbfs_fs_context *ctx = fc->fs_private;
struct hugetlbfs_sb_info *sbinfo;
- sbinfo = kmalloc(sizeof(struct hugetlbfs_sb_info), GFP_KERNEL);
+ sbinfo = kmalloc_obj(struct hugetlbfs_sb_info, GFP_KERNEL);
if (!sbinfo)
return -ENOMEM;
sb->s_fs_info = sbinfo;
@@ -1478,7 +1478,7 @@ static int hugetlbfs_init_fs_context(struct fs_context *fc)
{
struct hugetlbfs_fs_context *ctx;
- ctx = kzalloc(sizeof(struct hugetlbfs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct hugetlbfs_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 1fe19b4ee2f4..a0c46aadb97d 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -229,8 +229,7 @@ static struct iomap_folio_state *ifs_alloc(struct inode *inode,
* The first state tracks per-block uptodate and the
* second tracks per-block dirty state.
*/
- ifs = kzalloc(struct_size(ifs, state,
- BITS_TO_LONGS(2 * nr_blocks)), gfp);
+ ifs = kzalloc_flex(*ifs, state, BITS_TO_LONGS(2 * nr_blocks), gfp);
if (!ifs)
return ifs;
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 8c1fd7573aee..438c00e526c6 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -677,7 +677,7 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
if (!iomi.len)
return NULL;
- dio = kmalloc(sizeof(*dio), GFP_KERNEL);
+ dio = kmalloc_obj(*dio, GFP_KERNEL);
if (!dio)
return ERR_PTR(-ENOMEM);
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index 5f3b6da0e022..4aa8f0734456 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -75,7 +75,7 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
/* Because zlib is not thread-safe, do all the I/O at the top. */
blocknum = block_start >> bufshift;
- bhs = kcalloc(needblocks + 1, sizeof(*bhs), GFP_KERNEL);
+ bhs = kzalloc_objs(*bhs, needblocks + 1, GFP_KERNEL);
if (!bhs) {
*errp = -ENOMEM;
return 0;
@@ -333,8 +333,9 @@ static int zisofs_read_folio(struct file *file, struct folio *folio)
full_page = 0;
pcount = 1;
}
- pages = kcalloc(max_t(unsigned int, zisofs_pages_per_cblock, 1),
- sizeof(*pages), GFP_KERNEL);
+ pages = kzalloc_objs(*pages,
+ max_t(unsigned int, zisofs_pages_per_cblock, 1),
+ GFP_KERNEL);
if (!pages) {
folio_unlock(folio);
return -ENOMEM;
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index b7cbe126faf3..6597d0224835 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -589,7 +589,7 @@ static int isofs_fill_super(struct super_block *s, struct fs_context *fc)
unsigned int vol_desc_start;
int silent = fc->sb_flags & SB_SILENT;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
s->s_fs_info = sbi;
@@ -1557,7 +1557,7 @@ static int isofs_init_fs_context(struct fs_context *fc)
{
struct isofs_options *opt;
- opt = kzalloc(sizeof(*opt), GFP_KERNEL);
+ opt = kzalloc_obj(*opt, GFP_KERNEL);
if (!opt)
return -ENOMEM;
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index c973162d5b31..05ea1e5af80d 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1175,7 +1175,7 @@ static int jbd2_seq_info_open(struct inode *inode, struct file *file)
struct jbd2_stats_proc_session *s;
int rc, size;
- s = kmalloc(sizeof(*s), GFP_KERNEL);
+ s = kmalloc_obj(*s, GFP_KERNEL);
if (s == NULL)
return -ENOMEM;
size = sizeof(struct transaction_stats_s);
@@ -1525,7 +1525,7 @@ static journal_t *journal_init_common(struct block_device *bdev,
int err;
int n;
- journal = kzalloc(sizeof(*journal), GFP_KERNEL);
+ journal = kzalloc_obj(*journal, GFP_KERNEL);
if (!journal)
return ERR_PTR(-ENOMEM);
@@ -1578,8 +1578,7 @@ static journal_t *journal_init_common(struct block_device *bdev,
n = journal->j_blocksize / jbd2_min_tag_size();
journal->j_wbufsize = n;
journal->j_fc_wbuf = NULL;
- journal->j_wbuf = kmalloc_array(n, sizeof(struct buffer_head *),
- GFP_KERNEL);
+ journal->j_wbuf = kmalloc_objs(struct buffer_head *, n, GFP_KERNEL);
if (!journal->j_wbuf)
goto err_cleanup;
@@ -2269,8 +2268,8 @@ jbd2_journal_initialize_fast_commit(journal_t *journal)
/* Are we called twice? */
WARN_ON(journal->j_fc_wbuf != NULL);
- journal->j_fc_wbuf = kmalloc_array(num_fc_blks,
- sizeof(struct buffer_head *), GFP_KERNEL);
+ journal->j_fc_wbuf = kmalloc_objs(struct buffer_head *, num_fc_blks,
+ GFP_KERNEL);
if (!journal->j_fc_wbuf)
return -ENOMEM;
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 1467f6790747..3aa9f82a8ef7 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -231,7 +231,7 @@ struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size)
table->hash_size = hash_size;
table->hash_shift = shift;
table->hash_table =
- kvmalloc_array(hash_size, sizeof(struct list_head), GFP_KERNEL);
+ kvmalloc_objs(struct list_head, hash_size, GFP_KERNEL);
if (!table->hash_table) {
kmem_cache_free(jbd2_revoke_table_cache, table);
table = NULL;
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 888a7ceb6479..b7ece06cad80 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -133,8 +133,7 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
size_t i;
*size = jffs2_acl_size(acl->a_count);
- header = kmalloc(struct_size(header, a_entries, acl->a_count),
- GFP_KERNEL);
+ header = kmalloc_flex(*header, a_entries, acl->a_count, GFP_KERNEL);
if (!header)
return ERR_PTR(-ENOMEM);
header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index fda9f4d6093f..d451c8a1fdac 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -43,7 +43,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
jffs2_dbg(1, "%s(): erase block %#08x (range %#08x-%#08x)\n",
__func__,
jeb->offset, jeb->offset, jeb->offset + c->sector_size);
- instr = kzalloc(sizeof(struct erase_info), GFP_KERNEL);
+ instr = kzalloc_obj(struct erase_info, GFP_KERNEL);
if (!instr) {
pr_warn("kzalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
mutex_lock(&c->erase_free_sem);
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 764bba8ba999..ff469d44b92f 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -562,7 +562,8 @@ int jffs2_do_fill_super(struct super_block *sb, struct fs_context *fc)
return ret;
c->inocache_hashsize = calculate_inocache_hashsize(c->flash_size);
- c->inocache_list = kcalloc(c->inocache_hashsize, sizeof(struct jffs2_inode_cache *), GFP_KERNEL);
+ c->inocache_list = kzalloc_objs(struct jffs2_inode_cache *,
+ c->inocache_hashsize, GFP_KERNEL);
if (!c->inocache_list) {
ret = -ENOMEM;
goto out_wbuf;
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index f987f78a894e..eeca922d4da4 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -1392,7 +1392,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic)
{
struct jffs2_raw_inode n;
- struct jffs2_inode_info *f = kzalloc(sizeof(*f), GFP_KERNEL);
+ struct jffs2_inode_info *f = kzalloc_obj(*f, GFP_KERNEL);
int ret;
if (!f)
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 62879c218d4b..39063e2131d6 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -132,7 +132,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
}
if (jffs2_sum_active()) {
- s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
+ s = kzalloc_obj(struct jffs2_summary, GFP_KERNEL);
if (!s) {
JFFS2_WARNING("Can't allocate memory for summary\n");
ret = -ENOMEM;
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index d83372d3e1a0..b9df829eff56 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -27,7 +27,7 @@ int jffs2_sum_init(struct jffs2_sb_info *c)
{
uint32_t sum_size = min_t(uint32_t, c->sector_size, MAX_SUMMARY_SIZE);
- c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
+ c->summary = kzalloc_obj(struct jffs2_summary, GFP_KERNEL);
if (!c->summary) {
JFFS2_WARNING("Can't allocate memory for summary information!\n");
@@ -115,7 +115,8 @@ int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size)
int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri,
uint32_t ofs)
{
- struct jffs2_sum_inode_mem *temp = kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
+ struct jffs2_sum_inode_mem *temp = kmalloc_obj(struct jffs2_sum_inode_mem,
+ GFP_KERNEL);
if (!temp)
return -ENOMEM;
@@ -159,7 +160,7 @@ int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx,
{
struct jffs2_sum_xattr_mem *temp;
- temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
+ temp = kmalloc_obj(struct jffs2_sum_xattr_mem, GFP_KERNEL);
if (!temp)
return -ENOMEM;
@@ -177,7 +178,7 @@ int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, u
{
struct jffs2_sum_xref_mem *temp;
- temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
+ temp = kmalloc_obj(struct jffs2_sum_xref_mem, GFP_KERNEL);
if (!temp)
return -ENOMEM;
@@ -263,7 +264,8 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
switch (je16_to_cpu(node->u.nodetype)) {
case JFFS2_NODETYPE_INODE: {
struct jffs2_sum_inode_mem *temp =
- kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
+ kmalloc_obj(struct jffs2_sum_inode_mem,
+ GFP_KERNEL);
if (!temp)
goto no_mem;
@@ -314,7 +316,8 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
#ifdef CONFIG_JFFS2_FS_XATTR
case JFFS2_NODETYPE_XATTR: {
struct jffs2_sum_xattr_mem *temp;
- temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
+ temp = kmalloc_obj(struct jffs2_sum_xattr_mem,
+ GFP_KERNEL);
if (!temp)
goto no_mem;
@@ -329,7 +332,8 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
}
case JFFS2_NODETYPE_XREF: {
struct jffs2_sum_xref_mem *temp;
- temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
+ temp = kmalloc_obj(struct jffs2_sum_xref_mem,
+ GFP_KERNEL);
if (!temp)
goto no_mem;
temp->nodetype = node->r.nodetype;
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 4545f885c41e..48fbf1594ce8 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -311,7 +311,7 @@ static int jffs2_init_fs_context(struct fs_context *fc)
{
struct jffs2_sb_info *ctx;
- ctx = kzalloc(sizeof(struct jffs2_sb_info), GFP_KERNEL);
+ ctx = kzalloc_obj(struct jffs2_sb_info, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 3ab3f0ff7ebb..9775b9b84504 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -92,7 +92,7 @@ static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino)
if (jffs2_wbuf_pending_for_ino(c, ino))
return;
- new = kmalloc(sizeof(*new), GFP_KERNEL);
+ new = kmalloc_obj(*new, GFP_KERNEL);
if (!new) {
jffs2_dbg(1, "No memory to allocate inodirty. Fallback to all considered dirty\n");
jffs2_clear_wbuf_ino_list(c);
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index defb4162c3d5..4452e6837b34 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -784,8 +784,8 @@ int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING));
- xref_tmphash = kcalloc(XREF_TMPHASH_SIZE,
- sizeof(struct jffs2_xattr_ref *), GFP_KERNEL);
+ xref_tmphash = kzalloc_objs(struct jffs2_xattr_ref *, XREF_TMPHASH_SIZE,
+ GFP_KERNEL);
if (!xref_tmphash)
return -ENOMEM;
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cdfa699cd7c8..368fcdd8c328 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -161,7 +161,7 @@ int dbMount(struct inode *ipbmap)
* allocate/initialize the in-memory bmap descriptor
*/
/* allocate memory for the in-memory bmap descriptor */
- bmp = kmalloc(sizeof(struct bmap), GFP_KERNEL);
+ bmp = kmalloc_obj(struct bmap, GFP_KERNEL);
if (bmp == NULL)
return -ENOMEM;
@@ -1593,7 +1593,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
max_ranges = nblocks;
do_div(max_ranges, minlen);
range_cnt = min_t(u64, max_ranges + 1, 32 * 1024);
- totrim = kmalloc_array(range_cnt, sizeof(struct range2trim), GFP_NOFS);
+ totrim = kmalloc_objs(struct range2trim, range_cnt, GFP_NOFS);
if (totrim == NULL) {
jfs_error(bmp->db_ipbmap->i_sb, "no memory for trim array\n");
IWRITE_UNLOCK(ipbmap);
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index ecb8e05b8b84..739fcb4a6fc8 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -102,7 +102,7 @@ int diMount(struct inode *ipimap)
* allocate/initialize the in-memory inode map control structure
*/
/* allocate the in-memory inode map control structure. */
- imap = kzalloc(sizeof(struct inomap), GFP_KERNEL);
+ imap = kzalloc_obj(struct inomap, GFP_KERNEL);
if (imap == NULL)
return -ENOMEM;
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index 5b1c5da04163..204cca8dd5d4 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -1087,7 +1087,7 @@ int lmLogOpen(struct super_block *sb)
}
}
- if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) {
+ if (!(log = kzalloc_obj(struct jfs_log, GFP_KERNEL))) {
mutex_unlock(&jfs_log_mutex);
return -ENOMEM;
}
@@ -1156,7 +1156,7 @@ static int open_inline_log(struct super_block *sb)
struct jfs_log *log;
int rc;
- if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL)))
+ if (!(log = kzalloc_obj(struct jfs_log, GFP_KERNEL)))
return -ENOMEM;
INIT_LIST_HEAD(&log->sb_list);
init_waitqueue_head(&log->syncwait);
@@ -1190,7 +1190,7 @@ static int open_dummy_log(struct super_block *sb)
mutex_lock(&jfs_log_mutex);
if (!dummy_log) {
- dummy_log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL);
+ dummy_log = kzalloc_obj(struct jfs_log, GFP_KERNEL);
if (!dummy_log) {
mutex_unlock(&jfs_log_mutex);
return -ENOMEM;
@@ -1818,7 +1818,7 @@ static int lbmLogInit(struct jfs_log * log)
goto error;
buffer = page_address(page);
for (offset = 0; offset < PAGE_SIZE; offset += LOGPSIZE) {
- lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL);
+ lbuf = kmalloc_obj(struct lbuf, GFP_KERNEL);
if (lbuf == NULL) {
if (offset == 0)
__free_page(page);
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 871cf4fb3636..64c6eaa7f3f2 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -98,7 +98,7 @@ static inline int insert_metapage(struct folio *folio, struct metapage *mp)
a = folio->private;
if (!a) {
- a = kzalloc(sizeof(struct meta_anchor), GFP_NOFS);
+ a = kzalloc_obj(struct meta_anchor, GFP_NOFS);
if (!a)
return -ENOMEM;
folio_attach_private(folio, a);
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 3cfb86c5a36e..4c1510091fe2 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -449,7 +449,7 @@ static int jfs_fill_super(struct super_block *sb, struct fs_context *fc)
jfs_info("In jfs_read_super: s_flags=0x%lx", sb->s_flags);
- sbi = kzalloc(sizeof(struct jfs_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct jfs_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
@@ -912,7 +912,7 @@ static int jfs_init_fs_context(struct fs_context *fc)
{
struct jfs_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 29baeeb97871..3d0704e21f71 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -989,7 +989,7 @@ struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
struct kernfs_root *root;
struct kernfs_node *kn;
- root = kzalloc(sizeof(*root), GFP_KERNEL);
+ root = kzalloc_obj(*root, GFP_KERNEL);
if (!root)
return ERR_PTR(-ENOMEM);
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 9adf36e6364b..d338875f0258 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -540,7 +540,7 @@ static int kernfs_get_open_node(struct kernfs_node *kn,
if (!on) {
/* not there, initialize a new one */
- on = kzalloc(sizeof(*on), GFP_KERNEL);
+ on = kzalloc_obj(*on, GFP_KERNEL);
if (!on) {
mutex_unlock(mutex);
return -ENOMEM;
@@ -638,7 +638,7 @@ static int kernfs_fop_open(struct inode *inode, struct file *file)
/* allocate a kernfs_open_file for the file */
error = -ENOMEM;
- of = kzalloc(sizeof(struct kernfs_open_file), GFP_KERNEL);
+ of = kzalloc_obj(struct kernfs_open_file, GFP_KERNEL);
if (!of)
goto err_out;
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 3ac52e141766..dd38e2e21a17 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -370,7 +370,7 @@ int kernfs_get_tree(struct fs_context *fc)
struct kernfs_super_info *info;
int error;
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
@@ -451,7 +451,7 @@ static void __init kernfs_mutex_init(void)
static void __init kernfs_lock_init(void)
{
- kernfs_locks = kmalloc(sizeof(struct kernfs_global_locks), GFP_KERNEL);
+ kernfs_locks = kmalloc_obj(struct kernfs_global_locks, GFP_KERNEL);
WARN_ON(!kernfs_locks);
kernfs_mutex_init();
diff --git a/fs/libfs.c b/fs/libfs.c
index f1860dff86f2..361d5203e464 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -731,7 +731,7 @@ struct pseudo_fs_context *init_pseudo(struct fs_context *fc,
{
struct pseudo_fs_context *ctx;
- ctx = kzalloc(sizeof(struct pseudo_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct pseudo_fs_context, GFP_KERNEL);
if (likely(ctx)) {
ctx->magic = magic;
fc->fs_private = ctx;
@@ -1320,7 +1320,7 @@ int simple_attr_open(struct inode *inode, struct file *file,
{
struct simple_attr *attr;
- attr = kzalloc(sizeof(*attr), GFP_KERNEL);
+ attr = kzalloc_obj(*attr, GFP_KERNEL);
if (!attr)
return -ENOMEM;
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index a7e0519ec024..372fe0cf830f 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -233,7 +233,7 @@ reclaimer(void *ptr)
u32 nsmstate;
struct net *net = host->net;
- req = kmalloc(sizeof(*req), GFP_KERNEL);
+ req = kmalloc_obj(*req, GFP_KERNEL);
if (!req)
return 0;
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index cebcc283b7ce..e189b3ddfedf 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -105,7 +105,7 @@ static struct nlm_lockowner *nlmclnt_find_lockowner(struct nlm_host *host, fl_ow
res = __nlmclnt_find_lockowner(host, owner);
if (res == NULL) {
spin_unlock(&host->h_lock);
- new = kmalloc(sizeof(*new), GFP_KERNEL);
+ new = kmalloc_obj(*new, GFP_KERNEL);
spin_lock(&host->h_lock);
res = __nlmclnt_find_lockowner(host, owner);
if (res == NULL && new != NULL) {
@@ -208,7 +208,7 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host)
struct nlm_rqst *call;
for(;;) {
- call = kzalloc(sizeof(*call), GFP_KERNEL);
+ call = kzalloc_obj(*call, GFP_KERNEL);
if (call != NULL) {
refcount_set(&call->a_count, 1);
locks_init_lock(&call->a_args.lock.fl);
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 5e6877c37f73..12a745a543e0 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -126,7 +126,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni,
}
}
- host = kmalloc(sizeof(*host), GFP_KERNEL);
+ host = kmalloc_obj(*host, GFP_KERNEL);
if (unlikely(host == NULL)) {
dprintk("lockd: %s failed; no memory\n", __func__);
nsm_release(nsm);
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 712df1e025d8..1dee1da9ee0f 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -233,7 +233,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host,
return NULL;
/* Allocate memory for block, and initialize arguments */
- block = kzalloc(sizeof(*block), GFP_KERNEL);
+ block = kzalloc_obj(*block, GFP_KERNEL);
if (block == NULL)
goto failed;
kref_init(&block->b_count);
@@ -380,7 +380,7 @@ static struct nlm_lockowner *nlmsvc_find_lockowner(struct nlm_host *host, pid_t
if (res == NULL) {
spin_unlock(&host->h_lock);
- new = kmalloc(sizeof(*res), GFP_KERNEL);
+ new = kmalloc_obj(*res, GFP_KERNEL);
spin_lock(&host->h_lock);
res = __nlmsvc_find_lockowner(host, pid);
if (res == NULL && new != NULL) {
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 9103896164f6..fcfeaf6d6855 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -128,7 +128,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
nlm_debug_print_fh("creating file for", &lock->fh);
nfserr = nlm_lck_denied_nolocks;
- file = kzalloc(sizeof(*file), GFP_KERNEL);
+ file = kzalloc_obj(*file, GFP_KERNEL);
if (!file)
goto out_free;
diff --git a/fs/mbcache.c b/fs/mbcache.c
index e60a840999aa..19cb8eb6744e 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -358,16 +358,15 @@ struct mb_cache *mb_cache_create(int bucket_bits)
unsigned long bucket_count = 1UL << bucket_bits;
unsigned long i;
- cache = kzalloc(sizeof(struct mb_cache), GFP_KERNEL);
+ cache = kzalloc_obj(struct mb_cache, GFP_KERNEL);
if (!cache)
goto err_out;
cache->c_bucket_bits = bucket_bits;
cache->c_max_entries = bucket_count << 4;
INIT_LIST_HEAD(&cache->c_list);
spin_lock_init(&cache->c_list_lock);
- cache->c_hash = kmalloc_array(bucket_count,
- sizeof(struct hlist_bl_head),
- GFP_KERNEL);
+ cache->c_hash = kmalloc_objs(struct hlist_bl_head, bucket_count,
+ GFP_KERNEL);
if (!cache->c_hash) {
kfree(cache);
goto err_out;
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index c8c6b2135abe..495d31b8cd0e 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -226,7 +226,7 @@ static int minix_fill_super(struct super_block *s, struct fs_context *fc)
int ret = -EINVAL;
int silent = fc->sb_flags & SB_SILENT;
- sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct minix_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
s->s_fs_info = sbi;
diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
index a37991fdb194..6472c4ea3d1e 100644
--- a/fs/mnt_idmapping.c
+++ b/fs/mnt_idmapping.c
@@ -289,7 +289,7 @@ struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns)
struct mnt_idmap *idmap;
int ret;
- idmap = kzalloc(sizeof(struct mnt_idmap), GFP_KERNEL_ACCOUNT);
+ idmap = kzalloc_obj(struct mnt_idmap, GFP_KERNEL_ACCOUNT);
if (!idmap)
return ERR_PTR(-ENOMEM);
diff --git a/fs/namei.c b/fs/namei.c
index 5fe6cac48df8..58f715f7657e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -790,8 +790,8 @@ static bool nd_alloc_stack(struct nameidata *nd)
{
struct saved *p;
- p= kmalloc_array(MAXSYMLINKS, sizeof(struct saved),
- nd->flags & LOOKUP_RCU ? GFP_ATOMIC : GFP_KERNEL);
+ p= kmalloc_objs(struct saved, MAXSYMLINKS,
+ nd->flags & LOOKUP_RCU ? GFP_ATOMIC : GFP_KERNEL);
if (unlikely(!p))
return false;
memcpy(p, nd->internal, sizeof(nd->internal));
diff --git a/fs/namespace.c b/fs/namespace.c
index a67cbe42746d..1cb7fa1a02ed 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -889,7 +889,7 @@ mountpoint:
}
if (!mp)
- mp = kmalloc(sizeof(struct mountpoint), GFP_KERNEL);
+ mp = kmalloc_obj(struct mountpoint, GFP_KERNEL);
if (!mp)
return -ENOMEM;
@@ -2226,7 +2226,7 @@ static inline bool extend_array(struct path **res, struct path **to_free,
if (likely(n < *count))
return true;
- p = kmalloc_array(new_count, sizeof(struct path), GFP_KERNEL);
+ p = kmalloc_objs(struct path, new_count, GFP_KERNEL);
if (p && *count)
memcpy(p, *res, *count * sizeof(struct path));
*count = new_count;
@@ -4187,7 +4187,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a
if (!ucounts)
return ERR_PTR(-ENOSPC);
- new_ns = kzalloc(sizeof(struct mnt_namespace), GFP_KERNEL_ACCOUNT);
+ new_ns = kzalloc_obj(struct mnt_namespace, GFP_KERNEL_ACCOUNT);
if (!new_ns) {
dec_mnt_namespaces(ucounts);
return ERR_PTR(-ENOMEM);
diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
index 37ab6f28b5ad..60073d41a387 100644
--- a/fs/netfs/buffered_read.c
+++ b/fs/netfs/buffered_read.c
@@ -429,7 +429,7 @@ static int netfs_read_gaps(struct file *file, struct folio *folio)
* end get copied to, but the middle is discarded.
*/
ret = -ENOMEM;
- bvec = kmalloc_array(nr_bvec, sizeof(*bvec), GFP_KERNEL);
+ bvec = kmalloc_objs(*bvec, nr_bvec, GFP_KERNEL);
if (!bvec)
goto discard;
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
index f9d62abef2ac..8fe514447df6 100644
--- a/fs/netfs/buffered_write.c
+++ b/fs/netfs/buffered_write.c
@@ -302,7 +302,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
goto copied;
}
- finfo = kzalloc(sizeof(*finfo), GFP_KERNEL);
+ finfo = kzalloc_obj(*finfo, GFP_KERNEL);
if (!finfo) {
iov_iter_revert(iter, copied);
ret = -ENOMEM;
diff --git a/fs/netfs/fscache_cache.c b/fs/netfs/fscache_cache.c
index 8f70f8da064b..e709617b64d5 100644
--- a/fs/netfs/fscache_cache.c
+++ b/fs/netfs/fscache_cache.c
@@ -25,7 +25,7 @@ static struct fscache_cache *fscache_alloc_cache(const char *name)
{
struct fscache_cache *cache;
- cache = kzalloc(sizeof(*cache), GFP_KERNEL);
+ cache = kzalloc_obj(*cache, GFP_KERNEL);
if (cache) {
if (name) {
cache->name = kstrdup(name, GFP_KERNEL);
diff --git a/fs/netfs/fscache_io.c b/fs/netfs/fscache_io.c
index e4308457633c..37f05b4d3469 100644
--- a/fs/netfs/fscache_io.c
+++ b/fs/netfs/fscache_io.c
@@ -223,7 +223,7 @@ void __fscache_write_to_cache(struct fscache_cookie *cookie,
_enter("%llx,%zx", start, len);
- wreq = kzalloc(sizeof(struct fscache_write_request), GFP_NOFS);
+ wreq = kzalloc_obj(struct fscache_write_request, GFP_NOFS);
if (!wreq)
goto abandon;
wreq->mapping = mapping;
diff --git a/fs/netfs/fscache_volume.c b/fs/netfs/fscache_volume.c
index ced14ac78cc1..57a9f12e79aa 100644
--- a/fs/netfs/fscache_volume.c
+++ b/fs/netfs/fscache_volume.c
@@ -230,8 +230,7 @@ static struct fscache_volume *fscache_alloc_volume(const char *volume_key,
if (IS_ERR(cache))
return NULL;
- volume = kzalloc(struct_size(volume, coherency, coherency_len),
- GFP_KERNEL);
+ volume = kzalloc_flex(*volume, coherency, coherency_len, GFP_KERNEL);
if (!volume)
goto err_cache;
diff --git a/fs/netfs/rolling_buffer.c b/fs/netfs/rolling_buffer.c
index 207b6a326651..a17fbf9853a4 100644
--- a/fs/netfs/rolling_buffer.c
+++ b/fs/netfs/rolling_buffer.c
@@ -27,7 +27,7 @@ struct folio_queue *netfs_folioq_alloc(unsigned int rreq_id, gfp_t gfp,
{
struct folio_queue *fq;
- fq = kmalloc(sizeof(*fq), gfp);
+ fq = kmalloc_obj(*fq, gfp);
if (fq) {
netfs_stat(&netfs_n_folioq);
folioq_init(fq, rreq_id);
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 0e4c67373e4f..cb0a645aeb50 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -74,7 +74,7 @@ static inline struct parallel_io *alloc_parallel(void *data)
{
struct parallel_io *rv;
- rv = kmalloc(sizeof(*rv), GFP_NOFS);
+ rv = kmalloc_obj(*rv, GFP_NOFS);
if (rv) {
rv->data = data;
kref_init(&rv->refcnt);
@@ -461,7 +461,7 @@ static struct pnfs_layout_hdr *__bl_alloc_layout_hdr(struct inode *inode,
struct pnfs_block_layout *bl;
dprintk("%s enter\n", __func__);
- bl = kzalloc(sizeof(*bl), gfp_flags);
+ bl = kzalloc_obj(*bl, gfp_flags);
if (!bl)
return NULL;
@@ -619,7 +619,7 @@ bl_alloc_extent(struct xdr_stream *xdr, struct pnfs_layout_hdr *lo,
if (!p)
return -EIO;
- be = kzalloc(sizeof(*be), GFP_NOFS);
+ be = kzalloc_obj(*be, GFP_NOFS);
if (!be)
return -ENOMEM;
@@ -684,7 +684,7 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
dprintk("---> %s\n", __func__);
- lseg = kzalloc(sizeof(*lseg), gfp_mask);
+ lseg = kzalloc_obj(*lseg, gfp_mask);
if (!lseg)
return ERR_PTR(-ENOMEM);
diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c
index 134d7f760a33..cc6327d97a91 100644
--- a/fs/nfs/blocklayout/dev.c
+++ b/fs/nfs/blocklayout/dev.c
@@ -461,8 +461,8 @@ bl_parse_concat(struct nfs_server *server, struct pnfs_block_dev *d,
u64 len = 0;
int ret, i;
- d->children = kcalloc(v->concat.volumes_count,
- sizeof(struct pnfs_block_dev), gfp_mask);
+ d->children = kzalloc_objs(struct pnfs_block_dev,
+ v->concat.volumes_count, gfp_mask);
if (!d->children)
return -ENOMEM;
@@ -490,8 +490,8 @@ bl_parse_stripe(struct nfs_server *server, struct pnfs_block_dev *d,
u64 len = 0;
int ret, i;
- d->children = kcalloc(v->stripe.volumes_count,
- sizeof(struct pnfs_block_dev), gfp_mask);
+ d->children = kzalloc_objs(struct pnfs_block_dev,
+ v->stripe.volumes_count, gfp_mask);
if (!d->children)
return -ENOMEM;
@@ -559,8 +559,7 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
goto out_free_scratch;
nr_volumes = be32_to_cpup(p++);
- volumes = kcalloc(nr_volumes, sizeof(struct pnfs_block_volume),
- gfp_mask);
+ volumes = kzalloc_objs(struct pnfs_block_volume, nr_volumes, gfp_mask);
if (!volumes)
goto out_free_scratch;
@@ -570,7 +569,7 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
goto out_free_volumes;
}
- top = kzalloc(sizeof(*top), gfp_mask);
+ top = kzalloc_obj(*top, gfp_mask);
if (!top)
goto out_free_volumes;
diff --git a/fs/nfs/blocklayout/extent_tree.c b/fs/nfs/blocklayout/extent_tree.c
index 315949a7e92d..7393118c42a2 100644
--- a/fs/nfs/blocklayout/extent_tree.c
+++ b/fs/nfs/blocklayout/extent_tree.c
@@ -201,7 +201,7 @@ __ext_tree_remove(struct rb_root *root,
if (len1 > 0) {
struct pnfs_block_extent *new;
- new = kzalloc(sizeof(*new), GFP_ATOMIC);
+ new = kzalloc_obj(*new, GFP_ATOMIC);
if (!new)
return -ENOMEM;
@@ -384,7 +384,7 @@ ext_tree_split(struct rb_root *root, struct pnfs_block_extent *be,
struct pnfs_block_extent *new;
sector_t orig_len = be->be_length;
- new = kzalloc(sizeof(*new), GFP_ATOMIC);
+ new = kzalloc_obj(*new, GFP_ATOMIC);
if (!new)
return -ENOMEM;
@@ -653,8 +653,9 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg)
count = 0;
arg->layoutupdate_pages =
- kcalloc(DIV_ROUND_UP(buffer_size, PAGE_SIZE),
- sizeof(struct page *), GFP_NOFS);
+ kzalloc_objs(struct page *,
+ DIV_ROUND_UP(buffer_size, PAGE_SIZE),
+ GFP_NOFS);
if (!arg->layoutupdate_pages)
return -ENOMEM;
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c
index ef6729568432..90fa1e4440be 100644
--- a/fs/nfs/cache_lib.c
+++ b/fs/nfs/cache_lib.c
@@ -96,7 +96,7 @@ struct nfs_cache_defer_req *nfs_cache_defer_req_alloc(void)
{
struct nfs_cache_defer_req *dreq;
- dreq = kzalloc(sizeof(*dreq), GFP_KERNEL);
+ dreq = kzalloc_obj(*dreq, GFP_KERNEL);
if (dreq) {
init_completion(&dreq->completion);
refcount_set(&dreq->count, 1);
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 805eb3764186..1c94a97efd31 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -718,7 +718,7 @@ __be32 nfs4_callback_offload(void *data, void *dummy,
struct nfs4_copy_state *copy, *tmp_copy;
bool found = false;
- copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_KERNEL);
+ copy = kzalloc_obj(struct nfs4_copy_state, GFP_KERNEL);
if (!copy)
return cpu_to_be32(NFS4ERR_DELAY);
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index c2fa4a91db26..857393803e71 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -272,7 +272,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
if (n == 0)
goto out;
- args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
+ args->devs = kmalloc_objs(*args->devs, n, GFP_KERNEL);
if (!args->devs) {
status = htonl(NFS4ERR_DELAY);
goto out;
@@ -378,9 +378,9 @@ static __be32 decode_rc_list(struct xdr_stream *xdr,
rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t));
if (unlikely(p == NULL))
goto out;
- rc_list->rcl_refcalls = kmalloc_array(rc_list->rcl_nrefcalls,
- sizeof(*rc_list->rcl_refcalls),
- GFP_KERNEL);
+ rc_list->rcl_refcalls = kmalloc_objs(*rc_list->rcl_refcalls,
+ rc_list->rcl_nrefcalls,
+ GFP_KERNEL);
if (unlikely(rc_list->rcl_refcalls == NULL))
goto out;
for (i = 0; i < rc_list->rcl_nrefcalls; i++) {
@@ -419,9 +419,8 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
args->csa_nrclists = ntohl(*p++);
args->csa_rclists = NULL;
if (args->csa_nrclists) {
- args->csa_rclists = kmalloc_array(args->csa_nrclists,
- sizeof(*args->csa_rclists),
- GFP_KERNEL);
+ args->csa_rclists = kmalloc_objs(*args->csa_rclists,
+ args->csa_nrclists, GFP_KERNEL);
if (unlikely(args->csa_rclists == NULL))
return htonl(NFS4ERR_RESOURCE);
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index fd15731cf361..be6e3b61735d 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -150,7 +150,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
struct nfs_client *clp;
int err = -ENOMEM;
- if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
+ if ((clp = kzalloc_obj(*clp, GFP_KERNEL)) == NULL)
goto error_0;
clp->cl_minorversion = cl_init->minorversion;
@@ -1044,7 +1044,7 @@ struct nfs_server *nfs_alloc_server(void)
{
struct nfs_server *server;
- server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL);
+ server = kzalloc_obj(struct nfs_server, GFP_KERNEL);
if (!server)
return NULL;
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 94103f8d3f21..cf40ced95305 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -442,7 +442,7 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,
struct nfs_delegation *freeme = NULL;
int status = 0;
- delegation = kmalloc(sizeof(*delegation), GFP_KERNEL_ACCOUNT);
+ delegation = kmalloc_obj(*delegation, GFP_KERNEL_ACCOUNT);
if (delegation == NULL)
return -ENOMEM;
nfs4_stateid_copy(&delegation->stateid, stateid);
@@ -1602,8 +1602,9 @@ int nfs4_delegation_hash_alloc(struct nfs_server *server)
delegation_buckets = roundup_pow_of_two(nfs_delegation_watermark / 16);
server->delegation_hash_mask = delegation_buckets - 1;
- server->delegation_hash_table = kmalloc_array(delegation_buckets,
- sizeof(*server->delegation_hash_table), GFP_KERNEL);
+ server->delegation_hash_table = kmalloc_objs(*server->delegation_hash_table,
+ delegation_buckets,
+ GFP_KERNEL);
if (!server->delegation_hash_table)
return -ENOMEM;
for (i = 0; i < delegation_buckets; i++)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index b3f5c9461204..624ee989929d 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -80,7 +80,7 @@ alloc_nfs_open_dir_context(struct inode *dir)
struct nfs_inode *nfsi = NFS_I(dir);
struct nfs_open_dir_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL_ACCOUNT);
if (ctx != NULL) {
ctx->attr_gencount = nfsi->attr_gencount;
ctx->dtsize = min(NFS_SERVER(dir)->dtsize, NFS_INIT_DTSIZE);
@@ -912,7 +912,7 @@ static struct page **nfs_readdir_alloc_pages(size_t npages)
struct page **pages;
size_t i;
- pages = kmalloc_array(npages, sizeof(*pages), GFP_KERNEL);
+ pages = kmalloc_objs(*pages, npages, GFP_KERNEL);
if (!pages)
return NULL;
for (i = 0; i < npages; i++) {
@@ -942,7 +942,7 @@ static int nfs_readdir_xdr_to_array(struct nfs_readdir_descriptor *desc,
unsigned int pglen;
int status = -ENOMEM;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
entry->cookie = nfs_readdir_folio_last_cookie(folio);
@@ -1154,7 +1154,7 @@ static int uncached_readdir(struct nfs_readdir_descriptor *desc)
dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %llu\n",
(unsigned long long)desc->dir_cookie);
- arrays = kcalloc(sz, sizeof(*arrays), GFP_KERNEL);
+ arrays = kzalloc_objs(*arrays, sz, GFP_KERNEL);
if (!arrays)
goto out;
arrays[0] = nfs_readdir_folio_array_alloc(desc->dir_cookie, GFP_KERNEL);
@@ -1245,7 +1245,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)
nfs_revalidate_mapping(inode, file->f_mapping);
res = -ENOMEM;
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ desc = kzalloc_obj(*desc, GFP_KERNEL);
if (!desc)
goto out;
desc->file = file;
@@ -3216,7 +3216,7 @@ found:
void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set,
const struct cred *cred)
{
- struct nfs_access_entry *cache = kmalloc(sizeof(*cache), GFP_KERNEL);
+ struct nfs_access_entry *cache = kmalloc_obj(*cache, GFP_KERNEL);
if (cache == NULL)
return;
RB_CLEAR_NODE(&cache->rb_node);
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index 714975e5c0db..9bce45de1cb4 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -120,7 +120,7 @@ static void nfs_dns_ent_put(struct kref *ref)
static struct cache_head *nfs_dns_ent_alloc(void)
{
- struct nfs_dns_ent *item = kmalloc(sizeof(*item), GFP_KERNEL);
+ struct nfs_dns_ent *item = kmalloc_obj(*item, GFP_KERNEL);
if (item != NULL) {
item->hostname = NULL;
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 5c4551117c58..90a11afa5d05 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -694,15 +694,15 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
goto out_err;
if (fl->num_fh > 0) {
- fl->fh_array = kcalloc(fl->num_fh, sizeof(fl->fh_array[0]),
- gfp_flags);
+ fl->fh_array = kzalloc_objs(fl->fh_array[0], fl->num_fh,
+ gfp_flags);
if (!fl->fh_array)
goto out_err;
}
for (i = 0; i < fl->num_fh; i++) {
/* Do we want to use a mempool here? */
- fl->fh_array[i] = kmalloc(sizeof(struct nfs_fh), gfp_flags);
+ fl->fh_array[i] = kmalloc_obj(struct nfs_fh, gfp_flags);
if (!fl->fh_array[i])
goto out_err;
@@ -763,7 +763,7 @@ filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid,
int rc;
dprintk("--> %s\n", __func__);
- fl = kzalloc(sizeof(*fl), gfp_flags);
+ fl = kzalloc_obj(*fl, gfp_flags);
if (!fl)
return NULL;
@@ -1049,7 +1049,7 @@ filelayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
{
struct nfs4_filelayout *flo;
- flo = kzalloc(sizeof(*flo), gfp_flags);
+ flo = kzalloc_obj(*flo, gfp_flags);
if (flo == NULL)
return NULL;
pnfs_init_ds_commit_info(&flo->commit_info);
diff --git a/fs/nfs/filelayout/filelayoutdev.c b/fs/nfs/filelayout/filelayoutdev.c
index df79aeb68db4..7226989ee4d5 100644
--- a/fs/nfs/filelayout/filelayoutdev.c
+++ b/fs/nfs/filelayout/filelayoutdev.c
@@ -138,7 +138,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
goto out_err_free_stripe_indices;
}
- dsaddr = kzalloc(struct_size(dsaddr, ds_list, num), gfp_flags);
+ dsaddr = kzalloc_flex(*dsaddr, ds_list, num, gfp_flags);
if (!dsaddr)
goto out_err_free_stripe_indices;
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 9056f05a67dc..f67773d52830 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -54,7 +54,7 @@ ff_layout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
{
struct nfs4_flexfile_layout *ffl;
- ffl = kzalloc(sizeof(*ffl), gfp_flags);
+ ffl = kzalloc_obj(*ffl, gfp_flags);
if (ffl) {
pnfs_init_ds_commit_info(&ffl->commit_info);
INIT_LIST_HEAD(&ffl->error_list);
@@ -275,7 +275,7 @@ static struct nfs4_ff_layout_mirror *ff_layout_alloc_mirror(u32 dss_count,
{
struct nfs4_ff_layout_mirror *mirror;
- mirror = kzalloc(sizeof(*mirror), gfp_flags);
+ mirror = kzalloc_obj(*mirror, gfp_flags);
if (mirror == NULL)
return NULL;
@@ -285,8 +285,8 @@ static struct nfs4_ff_layout_mirror *ff_layout_alloc_mirror(u32 dss_count,
mirror->dss_count = dss_count;
mirror->dss =
- kcalloc(dss_count, sizeof(struct nfs4_ff_layout_ds_stripe),
- gfp_flags);
+ kzalloc_objs(struct nfs4_ff_layout_ds_stripe, dss_count,
+ gfp_flags);
if (mirror->dss == NULL) {
kfree(mirror);
return NULL;
@@ -483,8 +483,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
goto out_err_free;
rc = -ENOMEM;
- fls = kzalloc(struct_size(fls, mirror_array, mirror_array_cnt),
- gfp_flags);
+ fls = kzalloc_flex(*fls, mirror_array, mirror_array_cnt, gfp_flags);
if (!fls)
goto out_err_free;
@@ -554,8 +553,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
fh_count = be32_to_cpup(p);
dss_info->fh_versions =
- kcalloc(fh_count, sizeof(struct nfs_fh),
- gfp_flags);
+ kzalloc_objs(struct nfs_fh, fh_count, gfp_flags);
if (dss_info->fh_versions == NULL) {
rc = -ENOMEM;
goto out_err_free;
@@ -2633,7 +2631,7 @@ ff_layout_prepare_layoutreturn(struct nfs4_layoutreturn_args *args)
struct nfs4_flexfile_layoutreturn_args *ff_args;
struct nfs4_flexfile_layout *ff_layout = FF_LAYOUT_FROM_HDR(args->layout);
- ff_args = kmalloc(sizeof(*ff_args), nfs_io_gfp_mask());
+ ff_args = kmalloc_obj(*ff_args, nfs_io_gfp_mask());
if (!ff_args)
goto out_nomem;
ff_args->pages[0] = alloc_page(nfs_io_gfp_mask());
@@ -2674,8 +2672,7 @@ ff_layout_send_layouterror(struct pnfs_layout_segment *lseg)
if (list_empty(&head))
return;
- errors = kmalloc_array(NFS42_LAYOUTERROR_MAX, sizeof(*errors),
- nfs_io_gfp_mask());
+ errors = kmalloc_objs(*errors, NFS42_LAYOUTERROR_MAX, nfs_io_gfp_mask());
if (errors != NULL) {
const struct nfs4_ff_layout_ds_err *pos;
size_t n = 0;
@@ -2943,8 +2940,8 @@ static int ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
const int dev_count = PNFS_LAYOUTSTATS_MAXDEV;
/* For now, send at most PNFS_LAYOUTSTATS_MAXDEV statistics */
- args->devinfo = kmalloc_array(dev_count, sizeof(*args->devinfo),
- nfs_io_gfp_mask());
+ args->devinfo = kmalloc_objs(*args->devinfo, dev_count,
+ nfs_io_gfp_mask());
if (!args->devinfo)
return -ENOMEM;
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index c2d8a13a9dbd..c40395ae0814 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -60,7 +60,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
if (!scratch)
goto out_err;
- new_ds = kzalloc(sizeof(struct nfs4_ff_layout_ds), gfp_flags);
+ new_ds = kzalloc_obj(struct nfs4_ff_layout_ds, gfp_flags);
if (!new_ds)
goto out_scratch;
@@ -99,9 +99,8 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
version_count = be32_to_cpup(p);
dprintk("%s: version count %d\n", __func__, version_count);
- ds_versions = kcalloc(version_count,
- sizeof(struct nfs4_ff_ds_version),
- gfp_flags);
+ ds_versions = kzalloc_objs(struct nfs4_ff_ds_version, version_count,
+ gfp_flags);
if (!ds_versions)
goto out_err_drain_dsaddrs;
@@ -262,7 +261,7 @@ int ff_layout_track_ds_error(struct nfs4_flexfile_layout *flo,
if (IS_ERR_OR_NULL(mirror->dss[dss_id].mirror_ds))
return -EINVAL;
- dserr = kmalloc(sizeof(*dserr), gfp_flags);
+ dserr = kmalloc_obj(*dserr, gfp_flags);
if (!dserr)
return -ENOMEM;
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index 86750f110053..2fc851abd187 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -1692,7 +1692,7 @@ static int nfs_init_fs_context(struct fs_context *fc)
{
struct nfs_fs_context *ctx;
- ctx = kzalloc(sizeof(struct nfs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct nfs_fs_context, GFP_KERNEL);
if (unlikely(!ctx))
return -ENOMEM;
diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c
index 8b0785178731..9b7fdad4a920 100644
--- a/fs/nfs/fscache.c
+++ b/fs/nfs/fscache.c
@@ -288,7 +288,7 @@ static struct nfs_netfs_io_data *nfs_netfs_alloc(struct netfs_io_subrequest *sre
{
struct nfs_netfs_io_data *netfs;
- netfs = kzalloc(sizeof(*netfs), GFP_KERNEL_ACCOUNT);
+ netfs = kzalloc_obj(*netfs, GFP_KERNEL_ACCOUNT);
if (!netfs)
return NULL;
netfs->sreq = sreq;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 331cdecdd966..ea215fc2ed21 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -383,7 +383,7 @@ struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags)
if (!(server->caps & NFS_CAP_SECURITY_LABEL))
return NULL;
- label = kzalloc(sizeof(struct nfs4_label), flags);
+ label = kzalloc_obj(struct nfs4_label, flags);
if (label == NULL)
return ERR_PTR(-ENOMEM);
@@ -1131,7 +1131,7 @@ struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
res = __nfs_find_lock_context(ctx);
rcu_read_unlock();
if (res == NULL) {
- new = kmalloc(sizeof(*new), GFP_KERNEL_ACCOUNT);
+ new = kmalloc_obj(*new, GFP_KERNEL_ACCOUNT);
if (new == NULL)
return ERR_PTR(-ENOMEM);
nfs_init_lock_context(new);
@@ -1209,7 +1209,7 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry,
{
struct nfs_open_context *ctx;
- ctx = kmalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
+ ctx = kmalloc_obj(*ctx, GFP_KERNEL_ACCOUNT);
if (!ctx)
return ERR_PTR(-ENOMEM);
nfs_sb_active(dentry->d_sb);
@@ -1777,7 +1777,7 @@ struct nfs_fattr *nfs_alloc_fattr(void)
{
struct nfs_fattr *fattr;
- fattr = kmalloc(sizeof(*fattr), GFP_KERNEL);
+ fattr = kmalloc_obj(*fattr, GFP_KERNEL);
if (fattr != NULL) {
nfs_fattr_init(fattr);
fattr->label = NULL;
@@ -1807,7 +1807,7 @@ struct nfs_fh *nfs_alloc_fhandle(void)
{
struct nfs_fh *fh;
- fh = kmalloc(sizeof(struct nfs_fh), GFP_KERNEL);
+ fh = kmalloc_obj(struct nfs_fh, GFP_KERNEL);
if (fh != NULL)
fh->size = 0;
return fh;
@@ -2015,7 +2015,7 @@ static void nfs_ooo_merge(struct nfs_inode *nfsi,
return;
if (!nfsi->ooo) {
- nfsi->ooo = kmalloc(sizeof(*nfsi->ooo), GFP_ATOMIC);
+ nfsi->ooo = kmalloc_obj(*nfsi->ooo, GFP_ATOMIC);
if (!nfsi->ooo) {
nfsi->cache_validity |= NFS_INO_DATA_INVAL_DEFER;
return;
diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
index 3b47be4e693a..4c7d16a99ed6 100644
--- a/fs/nfs/localio.c
+++ b/fs/nfs/localio.c
@@ -316,12 +316,11 @@ nfs_local_iocb_alloc(struct nfs_pgio_header *hdr,
{
struct nfs_local_kiocb *iocb;
- iocb = kzalloc(sizeof(*iocb), flags);
+ iocb = kzalloc_obj(*iocb, flags);
if (iocb == NULL)
return NULL;
- iocb->bvec = kmalloc_array(hdr->page_array.npages,
- sizeof(struct bio_vec), flags);
+ iocb->bvec = kmalloc_objs(struct bio_vec, hdr->page_array.npages, flags);
if (iocb->bvec == NULL) {
kfree(iocb);
return NULL;
@@ -1070,7 +1069,7 @@ static struct nfs_local_fsync_ctx *
nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data,
struct nfsd_file *localio, gfp_t flags)
{
- struct nfs_local_fsync_ctx *ctx = kmalloc(sizeof(*ctx), flags);
+ struct nfs_local_fsync_ctx *ctx = kmalloc_obj(*ctx, flags);
if (ctx != NULL) {
ctx->localio = localio;
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index d3d2fbeba89d..eb9cac652550 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -299,7 +299,7 @@ static struct nfs3_createdata *nfs3_alloc_createdata(void)
{
struct nfs3_createdata *data;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (data != NULL) {
data->msg.rpc_argp = &data->arg;
data->msg.rpc_resp = &data->res;
diff --git a/fs/nfs/nfs40client.c b/fs/nfs/nfs40client.c
index fc0c6b48fc94..f44d68faea93 100644
--- a/fs/nfs/nfs40client.c
+++ b/fs/nfs/nfs40client.c
@@ -65,7 +65,7 @@ int nfs40_init_client(struct nfs_client *clp)
struct nfs4_slot_table *tbl;
int ret;
- tbl = kzalloc(sizeof(*tbl), GFP_NOFS);
+ tbl = kzalloc_obj(*tbl, GFP_NOFS);
if (tbl == NULL)
return -ENOMEM;
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 32a2a1a2b216..53f54081942e 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -122,7 +122,7 @@ static int nfs4_proc_async_renew(struct nfs_client *clp, const struct cred *cred
return 0;
if (!refcount_inc_not_zero(&clp->cl_count))
return -EIO;
- data = kmalloc(sizeof(*data), GFP_NOFS);
+ data = kmalloc_obj(*data, GFP_NOFS);
if (data == NULL) {
nfs_put_client(clp);
return -ENOMEM;
@@ -320,7 +320,7 @@ nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp)
if (clp->cl_mvops->minor_version != 0)
return;
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data, GFP_KERNEL);
if (!data)
return;
data->lsp = lsp;
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 3487948d7181..46298606e509 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -247,7 +247,7 @@ static int handle_async_copy(struct nfs42_copy_res *res,
int status = NFS4_OK;
u64 copied;
- copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_KERNEL);
+ copy = kzalloc_obj(struct nfs4_copy_state, GFP_KERNEL);
if (!copy)
return -ENOMEM;
@@ -351,7 +351,7 @@ static int process_copy_commit(struct file *dst, loff_t pos_dst,
struct nfs_commitres cres;
int status = -ENOMEM;
- cres.verf = kzalloc(sizeof(struct nfs_writeverf), GFP_KERNEL);
+ cres.verf = kzalloc_obj(struct nfs_writeverf, GFP_KERNEL);
if (!cres.verf)
goto out;
@@ -461,7 +461,7 @@ static ssize_t _nfs42_proc_copy(struct file *src,
res->commit_res.verf = NULL;
if (args->sync) {
res->commit_res.verf =
- kzalloc(sizeof(struct nfs_writeverf), GFP_KERNEL);
+ kzalloc_obj(struct nfs_writeverf, GFP_KERNEL);
if (!res->commit_res.verf)
return -ENOMEM;
}
@@ -659,7 +659,7 @@ static int nfs42_do_offload_cancel_async(struct file *dst,
if (!(dst_server->caps & NFS_CAP_OFFLOAD_CANCEL))
return -EOPNOTSUPP;
- data = kzalloc(sizeof(struct nfs42_offload_data), GFP_KERNEL);
+ data = kzalloc_obj(struct nfs42_offload_data, GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
@@ -756,7 +756,7 @@ nfs42_proc_offload_status(struct file *dst, nfs4_stateid *stateid, u64 *copied)
if (!(server->caps & NFS_CAP_OFFLOAD_STATUS))
return -EOPNOTSUPP;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
data->seq_server = server;
@@ -838,7 +838,7 @@ int nfs42_proc_copy_notify(struct file *src, struct file *dst,
if (!(src_server->caps & NFS_CAP_COPY_NOTIFY))
return -EOPNOTSUPP;
- args = kzalloc(sizeof(struct nfs42_copy_notify_args), GFP_KERNEL);
+ args = kzalloc_obj(struct nfs42_copy_notify_args, GFP_KERNEL);
if (args == NULL)
return -ENOMEM;
@@ -1087,7 +1087,7 @@ nfs42_alloc_layouterror_data(struct pnfs_layout_segment *lseg, gfp_t gfp_flags)
struct nfs42_layouterror_data *data;
struct inode *inode = lseg->pls_layout->plh_inode;
- data = kzalloc(sizeof(*data), gfp_flags);
+ data = kzalloc_obj(*data, gfp_flags);
if (data) {
data->args.inode = data->inode = nfs_igrab_and_active(inode);
if (data->inode) {
@@ -1535,7 +1535,7 @@ static ssize_t _nfs42_proc_listxattrs(struct inode *inode, void *buf,
xdrlen = server->lxasize;
np = xdrlen / PAGE_SIZE + 1;
- pages = kcalloc(np, sizeof(struct page *), GFP_KERNEL);
+ pages = kzalloc_objs(struct page *, np, GFP_KERNEL);
if (!pages)
goto out_free_scratch;
for (i = 0; i < np; i++) {
@@ -1578,7 +1578,7 @@ ssize_t nfs42_proc_getxattr(struct inode *inode, const char *name,
struct page **pages;
np = nfs_page_array_len(0, buflen ?: XATTR_SIZE_MAX);
- pages = kmalloc_array(np, sizeof(*pages), GFP_KERNEL);
+ pages = kmalloc_objs(*pages, np, GFP_KERNEL);
if (!pages)
return -ENOMEM;
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index e10d83ba835e..432cfeebeba4 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -1159,7 +1159,7 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res)
if (segments == 0)
return 0;
- segs = kmalloc_array(segments, sizeof(*segs), GFP_KERNEL);
+ segs = kmalloc_objs(*segs, segments, GFP_KERNEL);
if (!segs)
return -ENOMEM;
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 51cf4a37d652..c211639949c2 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -99,7 +99,7 @@ nfs4_alloc_ds_server(struct nfs_client *ds_clp, rpc_authflavor_t flavor)
{
struct nfs4_ds_server *dss;
- dss = kmalloc(sizeof(*dss), GFP_NOFS);
+ dss = kmalloc_obj(*dss, GFP_NOFS);
if (dss == NULL)
return ERR_PTR(-ENOMEM);
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 7f43e890d356..bd079b4a6523 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -164,8 +164,7 @@ retry:
*/
if (sync)
return -EOPNOTSUPP;
- cn_resp = kzalloc(sizeof(struct nfs42_copy_notify_res),
- GFP_KERNEL);
+ cn_resp = kzalloc_obj(struct nfs42_copy_notify_res, GFP_KERNEL);
if (unlikely(cn_resp == NULL))
return -ENOMEM;
diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
index 9e1c48c5c0b8..01fb53132279 100644
--- a/fs/nfs/nfs4idmap.c
+++ b/fs/nfs/nfs4idmap.c
@@ -445,7 +445,7 @@ nfs_idmap_new(struct nfs_client *clp)
struct rpc_pipe *pipe;
int error;
- idmap = kzalloc(sizeof(*idmap), GFP_KERNEL);
+ idmap = kzalloc_obj(*idmap, GFP_KERNEL);
if (idmap == NULL)
return -ENOMEM;
@@ -579,7 +579,7 @@ static int nfs_idmap_legacy_upcall(struct key *authkey, void *aux)
/* msg and im are freed in idmap_pipe_destroy_msg */
ret = -ENOMEM;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
goto out1;
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 9a98595bb160..7366f2e6bc12 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -415,7 +415,7 @@ static int nfs_do_refmount(struct fs_context *fc, struct rpc_clnt *client)
if (!page)
return -ENOMEM;
- fs_locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL);
+ fs_locations = kmalloc_obj(struct nfs4_fs_locations, GFP_KERNEL);
if (!fs_locations)
goto out_free;
fs_locations->fattr = nfs_alloc_fattr();
@@ -490,7 +490,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
size_t salen;
int error;
- sap = kmalloc(sizeof(*sap), GFP_KERNEL);
+ sap = kmalloc_obj(*sap, GFP_KERNEL);
if (sap == NULL)
return -ENOMEM;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 180229320731..df9ae871726d 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1370,7 +1370,7 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
struct nfs4_label *label = (c != NULL) ? c->label : NULL;
struct nfs4_opendata *p;
- p = kzalloc(sizeof(*p), gfp_mask);
+ p = kzalloc_obj(*p, gfp_mask);
if (p == NULL)
goto err;
@@ -3774,7 +3774,7 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait)
nfs4_state_protect(clp, NFS_SP4_MACH_CRED_CLEANUP,
&task_setup_data.rpc_client, &msg);
- calldata = kzalloc(sizeof(*calldata), gfp_mask);
+ calldata = kzalloc_obj(*calldata, gfp_mask);
if (calldata == NULL)
goto out;
nfs4_init_sequence(clp, &calldata->arg.seq_args,
@@ -4107,7 +4107,7 @@ static int _nfs4_discover_trunking(struct nfs_server *server,
page = alloc_page(GFP_KERNEL);
if (!page)
goto out_put_cred;
- locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL);
+ locations = kmalloc_obj(struct nfs4_fs_locations, GFP_KERNEL);
if (!locations)
goto out_free;
locations->fattr = nfs_alloc_fattr();
@@ -4341,7 +4341,7 @@ static int nfs4_get_referral(struct rpc_clnt *client, struct inode *dir,
page = alloc_page(GFP_KERNEL);
if (page == NULL)
goto out;
- locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL);
+ locations = kmalloc_obj(struct nfs4_fs_locations, GFP_KERNEL);
if (locations == NULL)
goto out;
@@ -5130,7 +5130,7 @@ static struct nfs4_createdata *nfs4_alloc_createdata(struct inode *dir,
{
struct nfs4_createdata *data;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (data != NULL) {
struct nfs_server *server = NFS_SERVER(dir);
@@ -6023,7 +6023,7 @@ static void nfs4_write_cached_acl(struct inode *inode, struct page **pages,
acl->cached = 1;
_copy_from_pages(acl->data, pages, pgbase, acl_len);
} else {
- acl = kmalloc(sizeof(*acl), GFP_KERNEL);
+ acl = kmalloc_obj(*acl, GFP_KERNEL);
if (acl == NULL)
goto out;
acl->cached = 0;
@@ -6070,7 +6070,7 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf,
buflen = server->rsize;
npages = DIV_ROUND_UP(buflen, PAGE_SIZE) + 1;
- pages = kmalloc_array(npages, sizeof(struct page *), GFP_KERNEL);
+ pages = kmalloc_objs(struct page *, npages, GFP_KERNEL);
if (!pages)
return -ENOMEM;
@@ -6822,7 +6822,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred,
if (nfs_server_capable(inode, NFS_CAP_MOVEABLE))
task_setup_data.flags |= RPC_TASK_MOVEABLE;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
@@ -7026,7 +7026,7 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl,
struct inode *inode = state->inode;
struct nfs_lock_context *l_ctx;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (p == NULL)
return NULL;
l_ctx = nfs_get_lock_context(ctx);
@@ -7260,7 +7260,7 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
struct nfs_server *server = NFS_SERVER(inode);
struct nfs_seqid *(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
- p = kzalloc(sizeof(*p), gfp_mask);
+ p = kzalloc_obj(*p, gfp_mask);
if (p == NULL)
return NULL;
@@ -8706,7 +8706,7 @@ nfs4_run_exchange_id(struct nfs_client *clp, const struct cred *cred,
return ERR_PTR(-EIO);
status = -ENOMEM;
- calldata = kzalloc(sizeof(*calldata), GFP_NOFS);
+ calldata = kzalloc_obj(*calldata, GFP_NOFS);
if (!calldata)
goto out;
@@ -8716,18 +8716,18 @@ nfs4_run_exchange_id(struct nfs_client *clp, const struct cred *cred,
if (status)
goto out_calldata;
- calldata->res.server_owner = kzalloc(sizeof(struct nfs41_server_owner),
- GFP_NOFS);
+ calldata->res.server_owner = kzalloc_obj(struct nfs41_server_owner,
+ GFP_NOFS);
status = -ENOMEM;
if (unlikely(calldata->res.server_owner == NULL))
goto out_calldata;
- calldata->res.server_scope = kzalloc(sizeof(struct nfs41_server_scope),
- GFP_NOFS);
+ calldata->res.server_scope = kzalloc_obj(struct nfs41_server_scope,
+ GFP_NOFS);
if (unlikely(calldata->res.server_scope == NULL))
goto out_server_owner;
- calldata->res.impl_id = kzalloc(sizeof(struct nfs41_impl_id), GFP_NOFS);
+ calldata->res.impl_id = kzalloc_obj(struct nfs41_impl_id, GFP_NOFS);
if (unlikely(calldata->res.impl_id == NULL))
goto out_server_scope;
@@ -9396,7 +9396,7 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
goto out_err;
ret = ERR_PTR(-ENOMEM);
- calldata = kzalloc(sizeof(*calldata), GFP_KERNEL);
+ calldata = kzalloc_obj(*calldata, GFP_KERNEL);
if (calldata == NULL)
goto out_put_clp;
nfs4_init_sequence(clp, &calldata->args, &calldata->res, 0, is_privileged);
@@ -9543,7 +9543,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp,
};
int status = -ENOMEM;
- calldata = kzalloc(sizeof(*calldata), GFP_NOFS);
+ calldata = kzalloc_obj(*calldata, GFP_NOFS);
if (calldata == NULL)
goto out;
calldata->clp = clp;
@@ -10358,7 +10358,7 @@ static int nfs41_free_stateid(struct nfs_server *server,
&task_setup.rpc_client, &msg);
dprintk("NFS call free_stateid %p\n", stateid);
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
data->server = server;
diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
index a2fdd4b80dc4..5c128957a0a4 100644
--- a/fs/nfs/nfs4session.c
+++ b/fs/nfs/nfs4session.c
@@ -106,7 +106,7 @@ static struct nfs4_slot *nfs4_new_slot(struct nfs4_slot_table *tbl,
{
struct nfs4_slot *slot;
- slot = kzalloc(sizeof(*slot), gfp_mask);
+ slot = kzalloc_obj(*slot, gfp_mask);
if (slot) {
slot->table = tbl;
slot->slot_nr = slotid;
@@ -558,7 +558,7 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
{
struct nfs4_session *session;
- session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS);
+ session = kzalloc_obj(struct nfs4_session, GFP_NOFS);
if (!session)
return NULL;
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 963719f35467..7e1f14fad898 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -446,7 +446,7 @@ nfs4_alloc_state_owner(struct nfs_server *server,
{
struct nfs4_state_owner *sp;
- sp = kzalloc(sizeof(*sp), gfp_flags);
+ sp = kzalloc_obj(*sp, gfp_flags);
if (!sp)
return NULL;
sp->so_seqid.owner_id = atomic64_inc_return(&server->owner_ctr);
@@ -612,7 +612,7 @@ nfs4_alloc_open_state(void)
{
struct nfs4_state *state;
- state = kzalloc(sizeof(*state), GFP_KERNEL_ACCOUNT);
+ state = kzalloc_obj(*state, GFP_KERNEL_ACCOUNT);
if (!state)
return NULL;
refcount_set(&state->count, 1);
@@ -815,7 +815,7 @@ static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, f
struct nfs4_lock_state *lsp;
struct nfs_server *server = state->owner->so_server;
- lsp = kzalloc(sizeof(*lsp), GFP_KERNEL_ACCOUNT);
+ lsp = kzalloc_obj(*lsp, GFP_KERNEL_ACCOUNT);
if (lsp == NULL)
return NULL;
nfs4_init_seqid_counter(&lsp->ls_seqid);
@@ -1014,7 +1014,7 @@ struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_m
{
struct nfs_seqid *new;
- new = kmalloc(sizeof(*new), gfp_mask);
+ new = kmalloc_obj(*new, gfp_mask);
if (new == NULL)
return ERR_PTR(-ENOMEM);
new->sequence = counter;
@@ -2054,7 +2054,7 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred
clp->cl_hostname);
page = alloc_page(GFP_KERNEL);
- locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL);
+ locations = kmalloc_obj(struct nfs4_fs_locations, GFP_KERNEL);
fattr = nfs_alloc_fattr();
if (page == NULL || locations == NULL || fattr == NULL) {
dprintk("<-- %s: no memory\n", __func__);
diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c
index 5ec9c83f1ef0..678f1f6c62bc 100644
--- a/fs/nfs/nfs4super.c
+++ b/fs/nfs/nfs4super.c
@@ -100,7 +100,7 @@ static int nfs_referral_loop_protect(void)
struct nfs_referral_count *p, *new;
int ret = -ENOMEM;
- new = kmalloc(sizeof(*new), GFP_KERNEL);
+ new = kmalloc_obj(*new, GFP_KERNEL);
if (!new)
goto out;
new->task = current;
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 6e69ce43a13f..a9373de891c9 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -893,7 +893,8 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,
if (pagecount <= ARRAY_SIZE(pg_array->page_array))
pg_array->pagevec = pg_array->page_array;
else {
- pg_array->pagevec = kcalloc(pagecount, sizeof(struct page *), gfp_flags);
+ pg_array->pagevec = kzalloc_objs(struct page *, pagecount,
+ gfp_flags);
if (!pg_array->pagevec) {
pg_array->npages = 0;
nfs_pgio_error(hdr);
@@ -991,7 +992,7 @@ nfs_pageio_alloc_mirrors(struct nfs_pageio_descriptor *desc,
desc->pg_mirrors_dynamic = NULL;
if (mirror_count == 1)
return desc->pg_mirrors_static;
- ret = kmalloc_array(mirror_count, sizeof(*ret), nfs_io_gfp_mask());
+ ret = kmalloc_objs(*ret, mirror_count, nfs_io_gfp_mask());
if (ret != NULL) {
for (i = 0; i < mirror_count; i++)
nfs_pageio_mirror_init(&ret[i], desc->pg_bsize);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index ff8483d3373a..bc13d1e69449 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1143,7 +1143,7 @@ static struct page **nfs4_alloc_pages(size_t size, gfp_t gfp_flags)
struct page **pages;
int i;
- pages = kmalloc_array(size, sizeof(struct page *), gfp_flags);
+ pages = kmalloc_objs(struct page *, size, gfp_flags);
if (!pages) {
dprintk("%s: can't alloc array of %zu pages\n", __func__, size);
return NULL;
@@ -1175,7 +1175,7 @@ pnfs_alloc_init_layoutget_args(struct inode *ino,
dprintk("--> %s\n", __func__);
- lgp = kzalloc(sizeof(*lgp), gfp_flags);
+ lgp = kzalloc_obj(*lgp, gfp_flags);
if (lgp == NULL)
return NULL;
@@ -1357,7 +1357,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo,
int status = 0;
*pcred = NULL;
- lrp = kzalloc(sizeof(*lrp), nfs_io_gfp_mask());
+ lrp = kzalloc_obj(*lrp, nfs_io_gfp_mask());
if (unlikely(lrp == NULL)) {
status = -ENOMEM;
spin_lock(&ino->i_lock);
@@ -3379,7 +3379,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
status = -ENOMEM;
/* Note kzalloc ensures data->res.seq_res.sr_slot == NULL */
- data = kzalloc(sizeof(*data), nfs_io_gfp_mask());
+ data = kzalloc_obj(*data, nfs_io_gfp_mask());
if (!data)
goto clear_layoutcommitting;
@@ -3450,7 +3450,7 @@ struct nfs4_threshold *pnfs_mdsthreshold_alloc(void)
{
struct nfs4_threshold *thp;
- thp = kzalloc(sizeof(*thp), nfs_io_gfp_mask());
+ thp = kzalloc_obj(*thp, nfs_io_gfp_mask());
if (!thp) {
dprintk("%s mdsthreshold allocation failed\n", __func__);
return NULL;
@@ -3487,7 +3487,7 @@ pnfs_report_layoutstat(struct inode *inode, gfp_t gfp_flags)
pnfs_get_layout_hdr(hdr);
spin_unlock(&inode->i_lock);
- data = kzalloc(sizeof(*data), gfp_flags);
+ data = kzalloc_obj(*data, gfp_flags);
if (!data) {
status = -ENOMEM;
goto out_put;
diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
index bf0f2d67e96c..274abdd6d5f3 100644
--- a/fs/nfs/pnfs_dev.c
+++ b/fs/nfs/pnfs_dev.c
@@ -114,11 +114,11 @@ nfs4_get_device_info(struct nfs_server *server,
dprintk("%s: server %p max_resp_sz %u max_pages %d\n",
__func__, server, max_resp_sz, max_pages);
- pdev = kzalloc(sizeof(*pdev), gfp_flags);
+ pdev = kzalloc_obj(*pdev, gfp_flags);
if (!pdev)
return NULL;
- pages = kcalloc(max_pages, sizeof(struct page *), gfp_flags);
+ pages = kzalloc_objs(struct page *, max_pages, gfp_flags);
if (!pages)
goto out_free_pdev;
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 9976cc16b689..12632a706da8 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -101,7 +101,7 @@ pnfs_alloc_commit_array(size_t n, gfp_t gfp_flags)
struct pnfs_commit_array *p;
struct pnfs_commit_bucket *b;
- p = kmalloc(struct_size(p, buckets, n), gfp_flags);
+ p = kmalloc_flex(*p, buckets, n, gfp_flags);
if (!p)
return NULL;
p->nbuckets = n;
@@ -618,7 +618,7 @@ _data_server_lookup_locked(const struct nfs_net *nn, const struct list_head *dsa
static struct nfs4_pnfs_ds_addr *nfs4_pnfs_ds_addr_alloc(gfp_t gfp_flags)
{
- struct nfs4_pnfs_ds_addr *da = kzalloc(sizeof(*da), gfp_flags);
+ struct nfs4_pnfs_ds_addr *da = kzalloc_obj(*da, gfp_flags);
if (da)
INIT_LIST_HEAD(&da->da_node);
return da;
@@ -730,7 +730,7 @@ nfs4_pnfs_ds_add(const struct net *net, struct list_head *dsaddrs, gfp_t gfp_fla
goto out;
}
- ds = kzalloc(sizeof(*ds), gfp_flags);
+ ds = kzalloc_obj(*ds, gfp_flags);
if (!ds)
goto out;
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 0e440ebf5335..523f44a2a416 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -217,7 +217,7 @@ static struct nfs_createdata *nfs_alloc_createdata(struct inode *dir,
{
struct nfs_createdata *data;
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data, GFP_KERNEL);
if (data != NULL) {
data->arg.fh = NFS_FH(dir);
diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index 7bf650fda1cb..2c723d41b7a7 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -43,7 +43,7 @@ int nfs_sysfs_init(void)
{
int ret;
- nfs_kset = kzalloc(sizeof(*nfs_kset), GFP_KERNEL);
+ nfs_kset = kzalloc_obj(*nfs_kset, GFP_KERNEL);
if (!nfs_kset)
return -ENOMEM;
@@ -172,7 +172,7 @@ static struct nfs_netns_client *nfs_netns_client_alloc(struct kobject *parent,
{
struct nfs_netns_client *p;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (p) {
p->net = net;
p->kobject.kset = nfs_kset;
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 4db818c0f9dd..2a07899c69af 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -175,7 +175,7 @@ nfs_async_unlink(struct dentry *dentry, const struct qstr *name)
int status = -ENOMEM;
void *devname_garbage = NULL;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (data == NULL)
goto out;
data->args.name.name = kstrdup(name->name, GFP_KERNEL);
@@ -355,7 +355,7 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
nfs_server_capable(new_dir, NFS_CAP_MOVEABLE))
task_setup_data.flags |= RPC_TASK_MOVEABLE;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (data == NULL)
return ERR_PTR(-ENOMEM);
task_setup_data.task = &data->task;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 2d0e4a765aeb..1ed4b3590b1a 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -113,7 +113,7 @@ static void nfs_writehdr_free(struct nfs_pgio_header *hdr)
static struct nfs_io_completion *nfs_io_completion_alloc(gfp_t gfp_flags)
{
- return kmalloc(sizeof(struct nfs_io_completion), gfp_flags);
+ return kmalloc_obj(struct nfs_io_completion, gfp_flags);
}
static void nfs_io_completion_init(struct nfs_io_completion *ioc,
diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index afa16d7a8013..e3553ccb6ab4 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -131,7 +131,7 @@ nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
* layouts, so make sure to zero the whole structure.
*/
nfserr = nfserrno(-ENOMEM);
- bl = kzalloc(struct_size(bl, extents, nr_extents_max), GFP_KERNEL);
+ bl = kzalloc_flex(*bl, extents, nr_extents_max, GFP_KERNEL);
if (!bl)
goto out_error;
bl->nr_extents = nr_extents_max;
@@ -208,7 +208,7 @@ nfsd4_block_get_device_info_simple(struct super_block *sb,
struct pnfs_block_deviceaddr *dev;
struct pnfs_block_volume *b;
- dev = kzalloc(struct_size(dev, volumes, 1), GFP_KERNEL);
+ dev = kzalloc_flex(*dev, volumes, 1, GFP_KERNEL);
if (!dev)
return -ENOMEM;
gdp->gd_device = dev;
@@ -319,7 +319,7 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb,
const struct pr_ops *ops;
int ret;
- dev = kzalloc(struct_size(dev, volumes, 1), GFP_KERNEL);
+ dev = kzalloc_flex(*dev, volumes, 1, GFP_KERNEL);
if (!dev)
return -ENOMEM;
gdp->gd_device = dev;
diff --git a/fs/nfsd/blocklayoutxdr.c b/fs/nfsd/blocklayoutxdr.c
index 196ef4245604..3c145146a0c8 100644
--- a/fs/nfsd/blocklayoutxdr.c
+++ b/fs/nfsd/blocklayoutxdr.c
@@ -164,7 +164,7 @@ nfsd4_block_decode_layoutupdate(struct xdr_stream *xdr, struct iomap **iomapp,
if (len != expected)
return nfserr_bad_xdr;
- iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL);
+ iomaps = kzalloc_objs(*iomaps, nr_iomaps, GFP_KERNEL);
if (!iomaps)
return nfserr_delay;
@@ -258,7 +258,7 @@ nfsd4_scsi_decode_layoutupdate(struct xdr_stream *xdr, struct iomap **iomapp,
if (len != expected)
return nfserr_bad_xdr;
- iomaps = kcalloc(nr_iomaps, sizeof(*iomaps), GFP_KERNEL);
+ iomaps = kzalloc_objs(*iomaps, nr_iomaps, GFP_KERNEL);
if (!iomaps)
return nfserr_delay;
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 09fe268fe2c7..8fb394afc3f5 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -234,7 +234,7 @@ static inline void expkey_update(struct cache_head *cnew,
static struct cache_head *expkey_alloc(void)
{
- struct svc_expkey *i = kmalloc(sizeof(*i), GFP_KERNEL);
+ struct svc_expkey *i = kmalloc_obj(*i, GFP_KERNEL);
if (i)
return &i->h;
else
@@ -479,9 +479,8 @@ fsloc_parse(char **mesg, char *buf, struct nfsd4_fs_locations *fsloc)
if (fsloc->locations_count == 0)
return 0;
- fsloc->locations = kcalloc(fsloc->locations_count,
- sizeof(struct nfsd4_fs_location),
- GFP_KERNEL);
+ fsloc->locations = kzalloc_objs(struct nfsd4_fs_location,
+ fsloc->locations_count, GFP_KERNEL);
if (!fsloc->locations)
return -ENOMEM;
for (i=0; i < fsloc->locations_count; i++) {
@@ -871,11 +870,11 @@ static void export_update(struct cache_head *cnew, struct cache_head *citem)
static struct cache_head *svc_export_alloc(void)
{
- struct svc_export *i = kmalloc(sizeof(*i), GFP_KERNEL);
+ struct svc_export *i = kmalloc_obj(*i, GFP_KERNEL);
if (!i)
return NULL;
- i->ex_stats = kmalloc(sizeof(*(i->ex_stats)), GFP_KERNEL);
+ i->ex_stats = kmalloc_obj(*(i->ex_stats), GFP_KERNEL);
if (!i->ex_stats) {
kfree(i);
return NULL;
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 93798575b807..6b4eeb28c88b 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -899,7 +899,7 @@ nfsd_alloc_fcache_disposal(void)
{
struct nfsd_fcache_disposal *l;
- l = kmalloc(sizeof(*l), GFP_KERNEL);
+ l = kmalloc_obj(*l, GFP_KERNEL);
if (!l)
return NULL;
spin_lock_init(&l->lock);
diff --git a/fs/nfsd/flexfilelayout.c b/fs/nfsd/flexfilelayout.c
index 0f1a35400cd5..a65d55bcdc02 100644
--- a/fs/nfsd/flexfilelayout.c
+++ b/fs/nfsd/flexfilelayout.c
@@ -36,7 +36,7 @@ nfsd4_ff_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
* Zero it out for the stateid - don't want junk in there!
*/
error = -ENOMEM;
- fl = kzalloc(sizeof(*fl), GFP_KERNEL);
+ fl = kzalloc_obj(*fl, GFP_KERNEL);
if (!fl)
goto out_error;
args->lg_content = fl;
@@ -86,7 +86,7 @@ nfsd4_ff_proc_getdeviceinfo(struct super_block *sb, struct svc_rqst *rqstp,
u16 port;
char addr[INET6_ADDRSTRLEN];
- da = kzalloc(sizeof(struct pnfs_ff_device_addr), GFP_KERNEL);
+ da = kzalloc_obj(struct pnfs_ff_device_addr, GFP_KERNEL);
if (!da)
return nfserrno(-ENOMEM);
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index e00b2aea8da2..88782df7c3a1 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -1378,7 +1378,7 @@ void nfsd41_cb_referring_call(struct nfsd4_callback *cb,
}
}
if (!found) {
- rcl = kmalloc(sizeof(*rcl), GFP_KERNEL);
+ rcl = kmalloc_obj(*rcl, GFP_KERNEL);
if (!rcl)
return;
memcpy(rcl->rcl_sessionid.data, sessionid->data,
@@ -1397,7 +1397,7 @@ void nfsd41_cb_referring_call(struct nfsd4_callback *cb,
}
}
if (!found) {
- rc = kmalloc(sizeof(*rc), GFP_KERNEL);
+ rc = kmalloc_obj(*rc, GFP_KERNEL);
if (!rc)
goto out;
rc->rc_sequenceid = seqno;
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index c319c31b0f64..6415b847a939 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -97,7 +97,7 @@ ent_put(struct kref *ref)
static struct cache_head *
ent_alloc(void)
{
- struct ent *e = kmalloc(sizeof(*e), GFP_KERNEL);
+ struct ent *e = kmalloc_obj(*e, GFP_KERNEL);
if (e)
return &e->h;
else
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 37ab3a69c4b6..7dbb1dc184db 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -451,7 +451,7 @@ do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, stru
int accmode;
__be32 status;
- *resfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
+ *resfh = kmalloc_obj(struct svc_fh, GFP_KERNEL);
if (!*resfh)
return nfserr_jukebox;
fh_init(*resfh, NFS4_FHSIZE);
@@ -1630,7 +1630,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
__be32 status = 0;
*nsui = NULL;
- work = kzalloc(sizeof(*work), GFP_KERNEL);
+ work = kzalloc_obj(*work, GFP_KERNEL);
try_again:
spin_lock(&nn->nfsd_ssc_lock);
list_for_each_entry_safe(ni, tmp, &nn->nfsd_ssc_mount_list, nsui_list) {
@@ -2160,7 +2160,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
memcpy(&copy->fh, &cstate->current_fh.fh_handle,
sizeof(struct knfsd_fh));
if (nfsd4_copy_is_async(copy)) {
- async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
+ async_copy = kzalloc_obj(struct nfsd4_copy, GFP_KERNEL);
if (!async_copy)
goto out_err;
async_copy->cp_nn = nn;
@@ -2171,7 +2171,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
if (atomic_inc_return(&nn->pending_async_copies) >
(int)rqstp->rq_pool->sp_nrthreads)
goto out_dec_async_copy_err;
- async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL);
+ async_copy->cp_src = kmalloc_obj(*async_copy->cp_src,
+ GFP_KERNEL);
if (!async_copy->cp_src)
goto out_dec_async_copy_err;
if (!nfs4_init_copy_state(nn, copy))
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 1e6b2dd47ba7..87de08c7f405 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -203,7 +203,7 @@ nfsd4_build_namelist(struct dir_context *__ctx, const char *name, int namlen,
if (namlen != HEXDIR_LEN - 1)
return true;
- entry = kmalloc(sizeof(struct name_list), GFP_KERNEL);
+ entry = kmalloc_obj(struct name_list, GFP_KERNEL);
if (entry == NULL)
return false;
memcpy(entry->name, name, HEXDIR_LEN - 1);
@@ -478,9 +478,8 @@ nfs4_legacy_state_init(struct net *net)
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int i;
- nn->reclaim_str_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
- sizeof(struct list_head),
- GFP_KERNEL);
+ nn->reclaim_str_hashtbl = kmalloc_objs(struct list_head,
+ CLIENT_HASH_SIZE, GFP_KERNEL);
if (!nn->reclaim_str_hashtbl)
return -ENOMEM;
@@ -898,7 +897,7 @@ __nfsd4_init_cld_pipe(struct net *net)
if (nn->cld_net)
return 0;
- cn = kzalloc(sizeof(*cn), GFP_KERNEL);
+ cn = kzalloc_obj(*cn, GFP_KERNEL);
if (!cn) {
ret = -ENOMEM;
goto err;
@@ -960,7 +959,7 @@ alloc_cld_upcall(struct nfsd_net *nn)
struct cld_upcall *new, *tmp;
struct cld_net *cn = nn->cld_net;
- new = kzalloc(sizeof(*new), GFP_KERNEL);
+ new = kzalloc_obj(*new, GFP_KERNEL);
if (!new)
return new;
@@ -1356,9 +1355,8 @@ nfs4_cld_state_init(struct net *net)
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int i;
- nn->reclaim_str_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
- sizeof(struct list_head),
- GFP_KERNEL);
+ nn->reclaim_str_hashtbl = kmalloc_objs(struct list_head,
+ CLIENT_HASH_SIZE, GFP_KERNEL);
if (!nn->reclaim_str_hashtbl)
return -ENOMEM;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index f5cb067a1e50..fb5b2ff4201e 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -299,7 +299,7 @@ find_or_allocate_block(struct nfs4_lockowner *lo, struct knfsd_fh *fh,
nbl = find_blocked_lock(lo, fh, nn);
if (!nbl) {
- nbl = kmalloc(sizeof(*nbl), GFP_KERNEL);
+ nbl = kmalloc_obj(*nbl, GFP_KERNEL);
if (nbl) {
INIT_LIST_HEAD(&nbl->nbl_list);
INIT_LIST_HEAD(&nbl->nbl_lru);
@@ -974,7 +974,7 @@ struct nfs4_cpntf_state *nfs4_alloc_init_cpntf_state(struct nfsd_net *nn,
{
struct nfs4_cpntf_state *cps;
- cps = kzalloc(sizeof(struct nfs4_cpntf_state), GFP_KERNEL);
+ cps = kzalloc_obj(struct nfs4_cpntf_state, GFP_KERNEL);
if (!cps)
return NULL;
cps->cpntf_time = ktime_get_boottime_seconds();
@@ -2032,7 +2032,7 @@ static struct nfsd4_slot *nfsd4_alloc_slot(struct nfsd4_channel_attrs *fattrs,
size = fattrs->maxresp_cached < NFSD_MIN_HDR_SEQ_SZ ?
0 : fattrs->maxresp_cached - NFSD_MIN_HDR_SEQ_SZ;
- slot = kzalloc(struct_size(slot, sl_data, size), gfp);
+ slot = kzalloc_flex(*slot, sl_data, size, gfp);
if (!slot)
return NULL;
slot->sl_index = index;
@@ -2047,7 +2047,7 @@ static struct nfsd4_session *alloc_session(struct nfsd4_channel_attrs *fattrs,
struct nfsd4_slot *slot;
int i;
- new = kzalloc(sizeof(*new), GFP_KERNEL);
+ new = kzalloc_obj(*new, GFP_KERNEL);
if (!new)
return NULL;
xa_init(&new->se_slots);
@@ -2108,7 +2108,7 @@ static struct nfsd4_conn *alloc_conn(struct svc_rqst *rqstp, u32 flags)
{
struct nfsd4_conn *conn;
- conn = kmalloc(sizeof(struct nfsd4_conn), GFP_KERNEL);
+ conn = kmalloc_obj(struct nfsd4_conn, GFP_KERNEL);
if (!conn)
return NULL;
svc_xprt_get(rqstp->rq_xprt);
@@ -2357,9 +2357,8 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name,
xdr_netobj_dup(&clp->cl_name, &name, GFP_KERNEL);
if (clp->cl_name.data == NULL)
goto err_no_name;
- clp->cl_ownerstr_hashtbl = kmalloc_array(OWNER_HASH_SIZE,
- sizeof(struct list_head),
- GFP_KERNEL);
+ clp->cl_ownerstr_hashtbl = kmalloc_objs(struct list_head,
+ OWNER_HASH_SIZE, GFP_KERNEL);
if (!clp->cl_ownerstr_hashtbl)
goto err_no_hashtbl;
clp->cl_callback_wq = alloc_ordered_workqueue("nfsd4_callbacks", 0);
@@ -3309,7 +3308,7 @@ static struct nfs4_client *create_client(struct xdr_netobj name,
free_client(clp);
return NULL;
}
- clp->cl_ra = kzalloc(sizeof(*clp->cl_ra), GFP_KERNEL);
+ clp->cl_ra = kzalloc_obj(*clp->cl_ra, GFP_KERNEL);
if (!clp->cl_ra) {
free_client(clp);
return NULL;
@@ -8823,7 +8822,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
static inline struct nfs4_client_reclaim *
alloc_reclaim(void)
{
- return kmalloc(sizeof(struct nfs4_client_reclaim), GFP_KERNEL);
+ return kmalloc_obj(struct nfs4_client_reclaim, GFP_KERNEL);
}
bool
@@ -8960,19 +8959,16 @@ static int nfs4_state_create_net(struct net *net)
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int i;
- nn->conf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
- sizeof(struct list_head),
- GFP_KERNEL);
+ nn->conf_id_hashtbl = kmalloc_objs(struct list_head, CLIENT_HASH_SIZE,
+ GFP_KERNEL);
if (!nn->conf_id_hashtbl)
goto err;
- nn->unconf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
- sizeof(struct list_head),
- GFP_KERNEL);
+ nn->unconf_id_hashtbl = kmalloc_objs(struct list_head, CLIENT_HASH_SIZE,
+ GFP_KERNEL);
if (!nn->unconf_id_hashtbl)
goto err_unconf_id;
- nn->sessionid_hashtbl = kmalloc_array(SESSION_HASH_SIZE,
- sizeof(struct list_head),
- GFP_KERNEL);
+ nn->sessionid_hashtbl = kmalloc_objs(struct list_head,
+ SESSION_HASH_SIZE, GFP_KERNEL);
if (!nn->sessionid_hashtbl)
goto err_sessionid;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5172dbd0cb05..c96d31b7846e 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -124,7 +124,7 @@ svcxdr_tmpalloc(struct nfsd4_compoundargs *argp, size_t len)
{
struct svcxdr_tmpbuf *tb;
- tb = kmalloc(struct_size(tb, buf, len), GFP_KERNEL);
+ tb = kmalloc_flex(*tb, buf, len, GFP_KERNEL);
if (!tb)
return NULL;
tb->next = argp->to_free;
@@ -2184,7 +2184,7 @@ nfsd4_decode_copy(struct nfsd4_compoundargs *argp, union nfsd4_op_u *u)
if (status)
return status;
- ns_dummy = kmalloc(sizeof(struct nl4_server), GFP_KERNEL);
+ ns_dummy = kmalloc_obj(struct nl4_server, GFP_KERNEL);
if (ns_dummy == NULL)
return nfserr_jukebox;
for (i = 0; i < count - 1; i++) {
@@ -3956,7 +3956,7 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
}
if ((attrmask[0] & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) &&
!fhp) {
- tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
+ tempfh = kmalloc_obj(struct svc_fh, GFP_KERNEL);
status = nfserr_jukebox;
if (!tempfh)
goto out;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 89fe2c0e8d44..777b7bb9aeca 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -477,7 +477,7 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
return strlen(buf);
}
- nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL);
+ nthreads = kzalloc_objs(int, npools, GFP_KERNEL);
rv = -ENOMEM;
if (nthreads == NULL)
goto out_free;
@@ -1596,7 +1596,7 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info)
mutex_lock(&nfsd_mutex);
- nthreads = kcalloc(nrpools, sizeof(int), GFP_KERNEL);
+ nthreads = kzalloc_objs(int, nrpools, GFP_KERNEL);
if (!nthreads) {
ret = -ENOMEM;
goto out_unlock;
diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c
index 6b506995818d..e7eebb04f9a4 100644
--- a/fs/nilfs2/alloc.c
+++ b/fs/nilfs2/alloc.c
@@ -54,7 +54,7 @@ int nilfs_palloc_init_blockgroup(struct inode *inode, unsigned int entry_size)
{
struct nilfs_mdt_info *mi = NILFS_MDT(inode);
- mi->mi_bgl = kmalloc(sizeof(*mi->mi_bgl), GFP_NOFS);
+ mi->mi_bgl = kmalloc_obj(*mi->mi_bgl, GFP_NOFS);
if (!mi->mi_bgl)
return -ENOMEM;
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index a9c61d0492cb..4d5a6aa5214c 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -370,7 +370,7 @@ static int nilfs_scan_dsync_log(struct the_nilfs *nilfs, sector_t start_blocknr,
if (unlikely(!binfo))
goto out;
- rb = kmalloc(sizeof(*rb), GFP_NOFS);
+ rb = kmalloc_obj(*rb, GFP_NOFS);
if (unlikely(!rb)) {
err = -ENOMEM;
goto out;
@@ -414,7 +414,7 @@ struct nilfs_segment_entry {
static int nilfs_segment_list_add(struct list_head *head, __u64 segnum)
{
- struct nilfs_segment_entry *ent = kmalloc(sizeof(*ent), GFP_NOFS);
+ struct nilfs_segment_entry *ent = kmalloc_obj(*ent, GFP_NOFS);
if (unlikely(!ent))
return -ENOMEM;
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index deee16bc9d4e..21c5539c7e84 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -2701,7 +2701,7 @@ static struct nilfs_sc_info *nilfs_segctor_new(struct super_block *sb,
struct the_nilfs *nilfs = sb->s_fs_info;
struct nilfs_sc_info *sci;
- sci = kzalloc(sizeof(*sci), GFP_KERNEL);
+ sci = kzalloc_obj(*sci, GFP_KERNEL);
if (!sci)
return NULL;
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index badc2cbc895e..55fac3f83232 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1292,7 +1292,7 @@ static int nilfs_init_fs_context(struct fs_context *fc)
{
struct nilfs_fs_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index d0bcf744c553..f481532ea8e9 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -56,7 +56,7 @@ struct the_nilfs *alloc_nilfs(struct super_block *sb)
{
struct the_nilfs *nilfs;
- nilfs = kzalloc(sizeof(*nilfs), GFP_KERNEL);
+ nilfs = kzalloc_obj(*nilfs, GFP_KERNEL);
if (!nilfs)
return NULL;
@@ -877,7 +877,7 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno)
if (root)
return root;
- new = kzalloc(sizeof(*root), GFP_KERNEL);
+ new = kzalloc_obj(*root, GFP_KERNEL);
if (!new)
return NULL;
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index d0b9b984002f..c2dcb25151de 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -1573,7 +1573,7 @@ static struct fsnotify_event *fanotify_alloc_overflow_event(void)
{
struct fanotify_event *oevent;
- oevent = kmalloc(sizeof(*oevent), GFP_KERNEL_ACCOUNT);
+ oevent = kmalloc_obj(*oevent, GFP_KERNEL_ACCOUNT);
if (!oevent)
return NULL;
diff --git a/fs/notify/group.c b/fs/notify/group.c
index 18446b7b0d49..b56d1c1d9644 100644
--- a/fs/notify/group.c
+++ b/fs/notify/group.c
@@ -117,7 +117,7 @@ static struct fsnotify_group *__fsnotify_alloc_group(
{
struct fsnotify_group *group;
- group = kzalloc(sizeof(struct fsnotify_group), gfp);
+ group = kzalloc_obj(struct fsnotify_group, gfp);
if (!group)
return ERR_PTR(-ENOMEM);
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index b372fb2c56bd..5e1845f2c25d 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -660,7 +660,7 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)
if (IS_ERR(group))
return group;
- oevent = kmalloc(sizeof(struct inotify_event_info), GFP_KERNEL_ACCOUNT);
+ oevent = kmalloc_obj(struct inotify_event_info, GFP_KERNEL_ACCOUNT);
if (unlikely(!oevent)) {
fsnotify_destroy_group(group);
return ERR_PTR(-ENOMEM);
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 8e6997e9aebb..691d36104ae2 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -644,7 +644,7 @@ static int fsnotify_attach_info_to_sb(struct super_block *sb)
struct fsnotify_sb_info *sbinfo;
/* sb info is freed on fsnotify_sb_delete() */
- sbinfo = kzalloc(sizeof(*sbinfo), GFP_KERNEL);
+ sbinfo = kzalloc_obj(*sbinfo, GFP_KERNEL);
if (!sbinfo)
return -ENOMEM;
diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c
index db7d0ecfb469..60b362f388d9 100644
--- a/fs/ntfs3/bitmap.c
+++ b/fs/ntfs3/bitmap.c
@@ -519,7 +519,7 @@ static int wnd_rescan(struct wnd_bitmap *wnd)
vbo = 0;
/* Allocate in memory instead of stack. Not critical if failed. */
- ra = kzalloc(sizeof(*ra), GFP_NOFS);
+ ra = kzalloc_obj(*ra, GFP_NOFS);
if (ra) {
file_ra_state_init(ra, mapping);
ra->ra_pages = (wnd->nbits / 8 + PAGE_SIZE - 1) >> PAGE_SHIFT;
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index f53037e0ecb6..7eecf1e01f74 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -1006,7 +1006,7 @@ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from)
return -EOPNOTSUPP;
}
- pages = kmalloc_array(pages_per_frame, sizeof(struct page *), GFP_NOFS);
+ pages = kmalloc_objs(struct page *, pages_per_frame, GFP_NOFS);
if (!pages)
return -ENOMEM;
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index bd0fa481e4b3..2e901d073fe9 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -316,7 +316,7 @@ bool ni_add_subrecord(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi)
{
struct mft_inode *m;
- m = kzalloc(sizeof(struct mft_inode), GFP_NOFS);
+ m = kzalloc_obj(struct mft_inode, GFP_NOFS);
if (!m)
return false;
@@ -1915,7 +1915,7 @@ int ni_read_folio_cmpr(struct ntfs_inode *ni, struct folio *folio)
idx = (vbo - frame_vbo) >> PAGE_SHIFT;
pages_per_frame = frame_size >> PAGE_SHIFT;
- pages = kcalloc(pages_per_frame, sizeof(struct page *), GFP_NOFS);
+ pages = kzalloc_objs(struct page *, pages_per_frame, GFP_NOFS);
if (!pages) {
err = -ENOMEM;
goto out;
@@ -1998,7 +1998,7 @@ int ni_decompress_file(struct ntfs_inode *ni)
frame_bits = ni_ext_compress_bits(ni);
frame_size = 1u << frame_bits;
pages_per_frame = frame_size >> PAGE_SHIFT;
- pages = kcalloc(pages_per_frame, sizeof(struct page *), GFP_NOFS);
+ pages = kzalloc_objs(struct page *, pages_per_frame, GFP_NOFS);
if (!pages) {
err = -ENOMEM;
goto out;
diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
index 10863c83c315..272e45276143 100644
--- a/fs/ntfs3/fslog.c
+++ b/fs/ntfs3/fslog.c
@@ -2473,7 +2473,7 @@ static int read_log_rec_lcb(struct ntfs_log *log, u64 lsn, u32 ctx_mode,
if (!verify_client_lsn(log, cr, lsn))
return -EINVAL;
- lcb = kzalloc(sizeof(struct lcb), GFP_NOFS);
+ lcb = kzalloc_obj(struct lcb, GFP_NOFS);
if (!lcb)
return -ENOMEM;
lcb->client = log->client_id;
@@ -3117,8 +3117,7 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
/* Read from disk. */
err = mi_get(sbi, rno, &mi);
if (err && op == InitializeFileRecordSegment) {
- mi = kzalloc(sizeof(struct mft_inode),
- GFP_NOFS);
+ mi = kzalloc_obj(struct mft_inode, GFP_NOFS);
if (!mi)
return -ENOMEM;
err = mi_format_new(mi, sbi, rno, 0, false);
@@ -3779,7 +3778,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
u16 t16;
u32 t32;
- log = kzalloc(sizeof(struct ntfs_log), GFP_NOFS);
+ log = kzalloc_obj(struct ntfs_log, GFP_NOFS);
if (!log)
return -ENOMEM;
@@ -4725,7 +4724,7 @@ next_open_attribute:
goto next_dirty_page;
}
- oa = kzalloc(sizeof(struct OpenAttr), GFP_NOFS);
+ oa = kzalloc_obj(struct OpenAttr, GFP_NOFS);
if (!oa) {
err = -ENOMEM;
goto out;
diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 2416c61050f1..97f06c26fe1a 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -940,7 +940,7 @@ static struct indx_node *indx_new(struct ntfs_index *indx,
u16 fn;
u32 eo;
- r = kzalloc(sizeof(struct indx_node), GFP_NOFS);
+ r = kzalloc_obj(struct indx_node, GFP_NOFS);
if (!r)
return ERR_PTR(-ENOMEM);
@@ -1046,7 +1046,7 @@ int indx_read_ra(struct ntfs_index *indx, struct ntfs_inode *ni, CLST vbn,
const struct INDEX_NAMES *name;
if (!in) {
- in = kzalloc(sizeof(struct indx_node), GFP_NOFS);
+ in = kzalloc_obj(struct indx_node, GFP_NOFS);
if (!in)
return -ENOMEM;
} else {
diff --git a/fs/ntfs3/lib/lzx_decompress.c b/fs/ntfs3/lib/lzx_decompress.c
index 4d5701024f83..9196bf30011a 100644
--- a/fs/ntfs3/lib/lzx_decompress.c
+++ b/fs/ntfs3/lib/lzx_decompress.c
@@ -572,7 +572,7 @@ static int lzx_decompress_block(const struct lzx_decompressor *d,
*/
struct lzx_decompressor *lzx_allocate_decompressor(void)
{
- return kmalloc(sizeof(struct lzx_decompressor), GFP_NOFS);
+ return kmalloc_obj(struct lzx_decompressor, GFP_NOFS);
}
/*
diff --git a/fs/ntfs3/lib/xpress_decompress.c b/fs/ntfs3/lib/xpress_decompress.c
index 769c6d3dde67..402cf21aede2 100644
--- a/fs/ntfs3/lib/xpress_decompress.c
+++ b/fs/ntfs3/lib/xpress_decompress.c
@@ -39,7 +39,7 @@ struct xpress_decompressor {
*/
struct xpress_decompressor *xpress_allocate_decompressor(void)
{
- return kmalloc(sizeof(struct xpress_decompressor), GFP_NOFS);
+ return kmalloc_obj(struct xpress_decompressor, GFP_NOFS);
}
/*
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 921b526eb0f4..daf5a1f47275 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -730,7 +730,7 @@ int indx_used_bit(struct ntfs_index *indx, struct ntfs_inode *ni, size_t *bit);
void fnd_clear(struct ntfs_fnd *fnd);
static inline struct ntfs_fnd *fnd_get(void)
{
- return kzalloc(sizeof(struct ntfs_fnd), GFP_NOFS);
+ return kzalloc_obj(struct ntfs_fnd, GFP_NOFS);
}
static inline void fnd_put(struct ntfs_fnd *fnd)
{
@@ -996,7 +996,7 @@ static inline void run_init(struct runs_tree *run)
static inline struct runs_tree *run_alloc(void)
{
- return kzalloc(sizeof(struct runs_tree), GFP_NOFS);
+ return kzalloc_obj(struct runs_tree, GFP_NOFS);
}
static inline void run_close(struct runs_tree *run)
diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c
index 167093e8d287..32bdb034c2a3 100644
--- a/fs/ntfs3/record.c
+++ b/fs/ntfs3/record.c
@@ -71,7 +71,7 @@ static __le16 mi_new_attt_id(struct ntfs_inode *ni, struct mft_inode *mi)
int mi_get(struct ntfs_sb_info *sbi, CLST rno, struct mft_inode **mi)
{
int err;
- struct mft_inode *m = kzalloc(sizeof(struct mft_inode), GFP_NOFS);
+ struct mft_inode *m = kzalloc_obj(struct mft_inode, GFP_NOFS);
if (!m)
return -ENOMEM;
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 27411203082a..174a7cb202a0 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1828,7 +1828,7 @@ static int __ntfs_init_fs_context(struct fs_context *fc)
struct ntfs_mount_options *opts;
struct ntfs_sb_info *sbi;
- opts = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS);
+ opts = kzalloc_obj(struct ntfs_mount_options, GFP_NOFS);
if (!opts)
return -ENOMEM;
@@ -1847,7 +1847,7 @@ static int __ntfs_init_fs_context(struct fs_context *fc)
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
goto ok;
- sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
+ sbi = kzalloc_obj(struct ntfs_sb_info, GFP_NOFS);
if (!sbi)
goto free_opts;
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index b7db177d17d6..ce8ce1470981 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -686,7 +686,7 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh,
BUG_ON(le16_to_cpu(root_el->l_tree_depth) >= OCFS2_MAX_PATH_DEPTH);
- path = kzalloc(sizeof(*path), GFP_NOFS);
+ path = kzalloc_obj(*path, GFP_NOFS);
if (path) {
path->p_tree_depth = le16_to_cpu(root_el->l_tree_depth);
get_bh(root_bh);
@@ -1202,8 +1202,7 @@ static int ocfs2_add_branch(handle_t *handle,
}
/* allocate the number of new eb blocks we need */
- new_eb_bhs = kcalloc(new_blocks, sizeof(struct buffer_head *),
- GFP_KERNEL);
+ new_eb_bhs = kzalloc_objs(struct buffer_head *, new_blocks, GFP_KERNEL);
if (!new_eb_bhs) {
status = -ENOMEM;
mlog_errno(status);
@@ -6493,7 +6492,7 @@ int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
int ret = 0;
struct ocfs2_cached_block_free *item;
- item = kzalloc(sizeof(*item), GFP_NOFS);
+ item = kzalloc_obj(*item, GFP_NOFS);
if (item == NULL) {
ret = -ENOMEM;
mlog_errno(ret);
@@ -6619,7 +6618,7 @@ ocfs2_find_per_slot_free_list(int type,
fl = fl->f_next_suballocator;
}
- fl = kmalloc(sizeof(*fl), GFP_NOFS);
+ fl = kmalloc_obj(*fl, GFP_NOFS);
if (fl) {
fl->f_inode_type = type;
fl->f_slot = slot;
@@ -6794,7 +6793,7 @@ int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
goto out;
}
- item = kzalloc(sizeof(*item), GFP_NOFS);
+ item = kzalloc_obj(*item, GFP_NOFS);
if (item == NULL) {
ret = -ENOMEM;
mlog_errno(ret);
@@ -6984,8 +6983,8 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle,
if (range_start >= range_end)
return 0;
- folios = kcalloc(ocfs2_pages_per_cluster(sb),
- sizeof(struct folio *), GFP_NOFS);
+ folios = kzalloc_objs(struct folio *, ocfs2_pages_per_cluster(sb),
+ GFP_NOFS);
if (folios == NULL) {
ret = -ENOMEM;
mlog_errno(ret);
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 76c86f1c2b1c..17ba79f443ee 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -823,7 +823,7 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp,
u32 cend;
struct ocfs2_write_ctxt *wc;
- wc = kzalloc(sizeof(struct ocfs2_write_ctxt), GFP_NOFS);
+ wc = kzalloc_obj(struct ocfs2_write_ctxt, GFP_NOFS);
if (!wc)
return -ENOMEM;
@@ -1325,8 +1325,7 @@ retry:
if (new == NULL) {
spin_unlock(&oi->ip_lock);
- new = kmalloc(sizeof(struct ocfs2_unwritten_extent),
- GFP_NOFS);
+ new = kmalloc_obj(struct ocfs2_unwritten_extent, GFP_NOFS);
if (new == NULL) {
ret = -ENOMEM;
goto out;
@@ -2080,7 +2079,7 @@ ocfs2_dio_alloc_write_ctx(struct buffer_head *bh, int *alloc)
if (bh->b_private)
return bh->b_private;
- dwc = kmalloc(sizeof(struct ocfs2_dio_write_ctxt), GFP_NOFS);
+ dwc = kmalloc_obj(struct ocfs2_dio_write_ctxt, GFP_NOFS);
if (dwc == NULL)
return NULL;
INIT_LIST_HEAD(&dwc->dw_zero_list);
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 8e9cbc334cf4..91fb76a43900 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1677,8 +1677,8 @@ static int o2hb_map_slot_data(struct o2hb_region *reg)
if (reg->hr_tmp_block == NULL)
return -ENOMEM;
- reg->hr_slots = kcalloc(reg->hr_blocks,
- sizeof(struct o2hb_disk_slot), GFP_KERNEL);
+ reg->hr_slots = kzalloc_objs(struct o2hb_disk_slot, reg->hr_blocks,
+ GFP_KERNEL);
if (reg->hr_slots == NULL)
return -ENOMEM;
@@ -1694,8 +1694,8 @@ static int o2hb_map_slot_data(struct o2hb_region *reg)
"at %u blocks per page\n",
reg->hr_num_pages, reg->hr_blocks, spp);
- reg->hr_slot_data = kcalloc(reg->hr_num_pages, sizeof(struct page *),
- GFP_KERNEL);
+ reg->hr_slot_data = kzalloc_objs(struct page *, reg->hr_num_pages,
+ GFP_KERNEL);
if (!reg->hr_slot_data)
return -ENOMEM;
@@ -2001,7 +2001,7 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
struct o2hb_region *reg = NULL;
int ret;
- reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
+ reg = kzalloc_obj(struct o2hb_region, GFP_KERNEL);
if (reg == NULL)
return ERR_PTR(-ENOMEM);
@@ -2211,7 +2211,7 @@ struct config_group *o2hb_alloc_hb_set(void)
struct o2hb_heartbeat_group *hs = NULL;
struct config_group *ret = NULL;
- hs = kzalloc(sizeof(struct o2hb_heartbeat_group), GFP_KERNEL);
+ hs = kzalloc_obj(struct o2hb_heartbeat_group, GFP_KERNEL);
if (hs == NULL)
goto out;
diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c
index bc27301eab6d..2cb3162aeb89 100644
--- a/fs/ocfs2/cluster/netdebug.c
+++ b/fs/ocfs2/cluster/netdebug.c
@@ -380,7 +380,7 @@ static int sc_common_open(struct file *file, int ctxt)
struct o2net_sock_debug *sd;
struct o2net_sock_container *dummy_sc;
- dummy_sc = kzalloc(sizeof(*dummy_sc), GFP_KERNEL);
+ dummy_sc = kzalloc_obj(*dummy_sc, GFP_KERNEL);
if (!dummy_sc)
return -ENOMEM;
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index c5e83c774d73..6fb8bc38c0f7 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -587,7 +587,7 @@ static struct config_item *o2nm_node_group_make_item(struct config_group *group,
if (strlen(name) > O2NM_MAX_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
- node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL);
+ node = kzalloc_obj(struct o2nm_node, GFP_KERNEL);
if (node == NULL)
return ERR_PTR(-ENOMEM);
@@ -695,8 +695,8 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
if (o2nm_single_cluster)
return ERR_PTR(-ENOSPC);
- cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL);
- ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL);
+ cluster = kzalloc_obj(struct o2nm_cluster, GFP_KERNEL);
+ ns = kzalloc_obj(struct o2nm_node_group, GFP_KERNEL);
o2hb_group = o2hb_alloc_hb_set();
if (cluster == NULL || ns == NULL || o2hb_group == NULL)
goto out;
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 79b281e32f4c..09a1f3b77bb8 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -415,7 +415,7 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node)
int status = 0;
page = alloc_page(GFP_NOFS);
- sc = kzalloc(sizeof(*sc), GFP_NOFS);
+ sc = kzalloc_obj(*sc, GFP_NOFS);
if (sc == NULL || page == NULL)
goto out;
@@ -825,7 +825,7 @@ int o2net_register_handler(u32 msg_type, u32 key, u32 max_len,
goto out;
}
- nmh = kzalloc(sizeof(struct o2net_msg_handler), GFP_NOFS);
+ nmh = kzalloc_obj(struct o2net_msg_handler, GFP_NOFS);
if (nmh == NULL) {
ret = -ENOMEM;
goto out;
@@ -1064,14 +1064,14 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec,
o2net_set_nst_sock_container(&nst, sc);
veclen = caller_veclen + 1;
- vec = kmalloc_array(veclen, sizeof(struct kvec), GFP_ATOMIC);
+ vec = kmalloc_objs(struct kvec, veclen, GFP_ATOMIC);
if (vec == NULL) {
mlog(0, "failed to %zu element kvec!\n", veclen);
ret = -ENOMEM;
goto out;
}
- msg = kmalloc(sizeof(struct o2net_msg), GFP_ATOMIC);
+ msg = kmalloc_obj(struct o2net_msg, GFP_ATOMIC);
if (!msg) {
mlog(0, "failed to allocate a o2net_msg!\n");
ret = -ENOMEM;
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index 1873bbbb7e5b..c4ba968e778b 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -265,7 +265,7 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry,
/*
* There are no other aliases
*/
- dl = kmalloc(sizeof(*dl), GFP_NOFS);
+ dl = kmalloc_obj(*dl, GFP_NOFS);
if (!dl) {
ret = -ENOMEM;
mlog_errno(ret);
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 782afd9fa934..1c8abf2c592c 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2550,8 +2550,7 @@ static struct buffer_head **ocfs2_dx_dir_kmalloc_leaves(struct super_block *sb,
int num_dx_leaves = ocfs2_clusters_to_blocks(sb, 1);
struct buffer_head **dx_leaves;
- dx_leaves = kcalloc(num_dx_leaves, sizeof(struct buffer_head *),
- GFP_NOFS);
+ dx_leaves = kzalloc_objs(struct buffer_head *, num_dx_leaves, GFP_NOFS);
if (dx_leaves && ret_num_leaves)
*ret_num_leaves = num_dx_leaves;
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index cf3ca2f597c2..ff4868619d35 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -1048,7 +1048,7 @@ static int dlm_send_regions(struct dlm_ctxt *dlm, unsigned long *node_map)
if (find_first_bit(node_map, O2NM_MAX_NODES) >= O2NM_MAX_NODES)
goto bail;
- qr = kzalloc(sizeof(struct dlm_query_region), GFP_KERNEL);
+ qr = kzalloc_obj(struct dlm_query_region, GFP_KERNEL);
if (!qr) {
ret = -ENOMEM;
mlog_errno(ret);
@@ -1220,7 +1220,7 @@ static int dlm_send_nodeinfo(struct dlm_ctxt *dlm, unsigned long *node_map)
if (find_first_bit(node_map, O2NM_MAX_NODES) >= O2NM_MAX_NODES)
goto bail;
- qn = kzalloc(sizeof(struct dlm_query_nodeinfo), GFP_KERNEL);
+ qn = kzalloc_obj(struct dlm_query_nodeinfo, GFP_KERNEL);
if (!qn) {
ret = -ENOMEM;
mlog_errno(ret);
@@ -1592,7 +1592,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm)
mlog(0, "%p", dlm);
- ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL);
+ ctxt = kzalloc_obj(*ctxt, GFP_KERNEL);
if (!ctxt) {
status = -ENOMEM;
mlog_errno(status);
@@ -1946,7 +1946,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
int ret;
struct dlm_ctxt *dlm = NULL;
- dlm = kzalloc(sizeof(*dlm), GFP_KERNEL);
+ dlm = kzalloc_obj(*dlm, GFP_KERNEL);
if (!dlm) {
ret = -ENOMEM;
mlog_errno(ret);
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
index 041fd1791ae7..46120eb75d90 100644
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -414,7 +414,7 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie,
if (!lksb) {
/* zero memory only if kernel-allocated */
- lksb = kzalloc(sizeof(*lksb), GFP_NOFS);
+ lksb = kzalloc_obj(*lksb, GFP_NOFS);
if (!lksb) {
kmem_cache_free(dlm_lock_cache, lock);
return NULL;
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 4145e06d2c08..eb62724bbe9b 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -2040,7 +2040,7 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm,
int ignore_higher, u8 request_from, u32 flags)
{
struct dlm_work_item *item;
- item = kzalloc(sizeof(*item), GFP_ATOMIC);
+ item = kzalloc_obj(*item, GFP_ATOMIC);
if (!item)
return -ENOMEM;
@@ -2303,7 +2303,7 @@ int dlm_deref_lockres_handler(struct o2net_msg *msg, u32 len, void *data,
goto done;
}
- item = kzalloc(sizeof(*item), GFP_NOFS);
+ item = kzalloc_obj(*item, GFP_NOFS);
if (!item) {
ret = -ENOMEM;
mlog_errno(ret);
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 843ee02bd85f..128872bd945d 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -743,7 +743,7 @@ static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node)
}
BUG_ON(num == dead_node);
- ndata = kzalloc(sizeof(*ndata), GFP_NOFS);
+ ndata = kzalloc_obj(*ndata, GFP_NOFS);
if (!ndata) {
dlm_destroy_recovery_area(dlm);
return -ENOMEM;
@@ -830,7 +830,7 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data,
}
BUG_ON(lr->dead_node != dlm->reco.dead_node);
- item = kzalloc(sizeof(*item), GFP_NOFS);
+ item = kzalloc_obj(*item, GFP_NOFS);
if (!item) {
dlm_put(dlm);
return -ENOMEM;
@@ -1382,7 +1382,7 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data,
ret = -ENOMEM;
buf = kmalloc(be16_to_cpu(msg->data_len), GFP_NOFS);
- item = kzalloc(sizeof(*item), GFP_NOFS);
+ item = kzalloc_obj(*item, GFP_NOFS);
if (!buf || !item)
goto leave;
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 339f0b11cdc8..45cce261da65 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -134,7 +134,7 @@ static int dlmfs_file_open(struct inode *inode,
* doesn't make sense for LVB writes. */
file->f_flags &= ~O_APPEND;
- fp = kmalloc(sizeof(*fp), GFP_NOFS);
+ fp = kmalloc_obj(*fp, GFP_NOFS);
if (!fp) {
status = -ENOMEM;
goto bail;
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 619ff03b15d6..627d488b0148 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3030,7 +3030,7 @@ struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void)
{
struct ocfs2_dlm_debug *dlm_debug;
- dlm_debug = kmalloc(sizeof(struct ocfs2_dlm_debug), GFP_KERNEL);
+ dlm_debug = kmalloc_obj(struct ocfs2_dlm_debug, GFP_KERNEL);
if (!dlm_debug) {
mlog_errno(-ENOMEM);
goto out;
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index ef147e8b3271..d68229422dda 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -246,7 +246,7 @@ search:
if (new_emi == NULL) {
spin_unlock(&oi->ip_lock);
- new_emi = kmalloc(sizeof(*new_emi), GFP_NOFS);
+ new_emi = kmalloc_obj(*new_emi, GFP_NOFS);
if (new_emi == NULL)
goto out;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index ed961a854983..70879058b0c9 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -54,7 +54,7 @@ static int ocfs2_init_file_private(struct inode *inode, struct file *file)
{
struct ocfs2_file_private *fp;
- fp = kzalloc(sizeof(struct ocfs2_file_private), GFP_KERNEL);
+ fp = kzalloc_obj(struct ocfs2_file_private, GFP_KERNEL);
if (!fp)
return -ENOMEM;
diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
index 3ad7baf67658..be713d7d24a7 100644
--- a/fs/ocfs2/filecheck.c
+++ b/fs/ocfs2/filecheck.c
@@ -169,7 +169,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb)
struct ocfs2_filecheck *fcheck;
struct ocfs2_filecheck_sysfs_entry *entry = &osb->osb_fc_ent;
- fcheck = kmalloc(sizeof(struct ocfs2_filecheck), GFP_NOFS);
+ fcheck = kmalloc_obj(struct ocfs2_filecheck, GFP_NOFS);
if (!fcheck)
return -ENOMEM;
@@ -464,7 +464,7 @@ static ssize_t ocfs2_filecheck_attr_store(struct kobject *kobj,
goto exit;
}
- entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS);
+ entry = kmalloc_obj(struct ocfs2_filecheck_entry, GFP_NOFS);
if (!entry) {
ret = -ENOMEM;
goto exit;
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index b6864602814c..872b826979ec 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -334,7 +334,7 @@ static int ocfs2_info_handle_freeinode(struct inode *inode,
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct inode *inode_alloc = NULL;
- oifi = kzalloc(sizeof(struct ocfs2_info_freeinode), GFP_KERNEL);
+ oifi = kzalloc_obj(struct ocfs2_info_freeinode, GFP_KERNEL);
if (!oifi) {
status = -ENOMEM;
mlog_errno(status);
@@ -620,7 +620,7 @@ static int ocfs2_info_handle_freefrag(struct inode *inode,
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct inode *gb_inode = NULL;
- oiff = kzalloc(sizeof(struct ocfs2_info_freefrag), GFP_KERNEL);
+ oiff = kzalloc_obj(struct ocfs2_info_freefrag, GFP_KERNEL);
if (!oiff) {
status = -ENOMEM;
mlog_errno(status);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 85239807dec7..1b9359304aef 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -114,9 +114,8 @@ int ocfs2_compute_replay_slots(struct ocfs2_super *osb)
if (osb->replay_map)
return 0;
- replay_map = kzalloc(struct_size(replay_map, rm_replay_slots,
- osb->max_slots),
- GFP_KERNEL);
+ replay_map = kzalloc_flex(*replay_map, rm_replay_slots, osb->max_slots,
+ GFP_KERNEL);
if (!replay_map) {
mlog_errno(-ENOMEM);
return -ENOMEM;
@@ -178,8 +177,7 @@ int ocfs2_recovery_init(struct ocfs2_super *osb)
osb->recovery_thread_task = NULL;
init_waitqueue_head(&osb->recovery_event);
- rm = kzalloc(struct_size(rm, rm_entries, osb->max_slots),
- GFP_KERNEL);
+ rm = kzalloc_flex(*rm, rm_entries, osb->max_slots, GFP_KERNEL);
if (!rm) {
mlog_errno(-ENOMEM);
return -ENOMEM;
@@ -878,7 +876,7 @@ int ocfs2_journal_alloc(struct ocfs2_super *osb)
int status = 0;
struct ocfs2_journal *journal;
- journal = kzalloc(sizeof(struct ocfs2_journal), GFP_KERNEL);
+ journal = kzalloc_obj(struct ocfs2_journal, GFP_KERNEL);
if (!journal) {
mlog(ML_ERROR, "unable to alloc journal\n");
status = -ENOMEM;
@@ -1394,7 +1392,7 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal,
{
struct ocfs2_la_recovery_item *item;
- item = kmalloc(sizeof(struct ocfs2_la_recovery_item), GFP_NOFS);
+ item = kmalloc_obj(struct ocfs2_la_recovery_item, GFP_NOFS);
if (!item) {
/* Though we wish to avoid it, we are in fact safe in
* skipping local alloc cleanup as fsck.ocfs2 is more
@@ -1480,7 +1478,7 @@ static int __ocfs2_recovery_thread(void *arg)
}
if (quota_enabled) {
- rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
+ rm_quota = kzalloc_objs(int, osb->max_slots, GFP_NOFS);
if (!rm_quota) {
status = -ENOMEM;
goto bail;
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 56be21c695d6..29fa6fb11ea5 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -1094,7 +1094,7 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
{
int status;
- *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
+ *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL);
if (!(*ac)) {
status = -ENOMEM;
mlog_errno(status);
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index e3cdf8788484..c53de4439d93 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -1011,7 +1011,7 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
goto out_drop;
}
- context = kzalloc(sizeof(struct ocfs2_move_extents_context), GFP_NOFS);
+ context = kzalloc_obj(struct ocfs2_move_extents_context, GFP_NOFS);
if (!context) {
status = -ENOMEM;
mlog_errno(status);
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 4ec6dbed65a8..85ad1a9db734 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1736,7 +1736,7 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
goto bail;
}
- bhs = kcalloc(blocks, sizeof(struct buffer_head *), GFP_KERNEL);
+ bhs = kzalloc_objs(struct buffer_head *, blocks, GFP_KERNEL);
if (!bhs) {
status = -ENOMEM;
mlog_errno(status);
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index de7f12858729..c4e0117d8977 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -298,7 +298,7 @@ static int ocfs2_add_recovery_chunk(struct super_block *sb,
{
struct ocfs2_recovery_chunk *rc;
- rc = kmalloc(sizeof(struct ocfs2_recovery_chunk), GFP_NOFS);
+ rc = kmalloc_obj(struct ocfs2_recovery_chunk, GFP_NOFS);
if (!rc)
return -ENOMEM;
rc->rc_chunk = chunk;
@@ -372,7 +372,7 @@ static struct ocfs2_quota_recovery *ocfs2_alloc_quota_recovery(void)
int type;
struct ocfs2_quota_recovery *rec;
- rec = kmalloc(sizeof(struct ocfs2_quota_recovery), GFP_NOFS);
+ rec = kmalloc_obj(struct ocfs2_quota_recovery, GFP_NOFS);
if (!rec)
return NULL;
for (type = 0; type < OCFS2_MAXQUOTAS; type++)
@@ -692,7 +692,7 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
info->dqi_max_spc_limit = 0x7fffffffffffffffLL;
info->dqi_max_ino_limit = 0x7fffffffffffffffLL;
- oinfo = kmalloc(sizeof(struct ocfs2_mem_dqinfo), GFP_NOFS);
+ oinfo = kmalloc_obj(struct ocfs2_mem_dqinfo, GFP_NOFS);
if (!oinfo) {
mlog(ML_ERROR, "failed to allocate memory for ocfs2 quota"
" info.");
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index c92e0ea85bca..c1cdececdfa4 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -311,7 +311,7 @@ ocfs2_allocate_refcount_tree(struct ocfs2_super *osb, u64 rf_blkno)
{
struct ocfs2_refcount_tree *new;
- new = kzalloc(sizeof(struct ocfs2_refcount_tree), GFP_NOFS);
+ new = kzalloc_obj(struct ocfs2_refcount_tree, GFP_NOFS);
if (!new)
return NULL;
@@ -3397,7 +3397,7 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
BUG_ON(cow_len == 0);
- context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
+ context = kzalloc_obj(struct ocfs2_cow_context, GFP_NOFS);
if (!context) {
ret = -ENOMEM;
mlog_errno(ret);
@@ -3606,7 +3606,7 @@ int ocfs2_refcount_cow_xattr(struct inode *inode,
BUG_ON(cow_len == 0);
- context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
+ context = kzalloc_obj(struct ocfs2_cow_context, GFP_NOFS);
if (!context) {
ret = -ENOMEM;
mlog_errno(ret);
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index ea4a68abc25b..3ea14f00e84a 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -385,8 +385,8 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb,
trace_ocfs2_map_slot_buffers(bytes, si->si_blocks);
- si->si_bh = kcalloc(si->si_blocks, sizeof(struct buffer_head *),
- GFP_KERNEL);
+ si->si_bh = kzalloc_objs(struct buffer_head *, si->si_blocks,
+ GFP_KERNEL);
if (!si->si_bh) {
status = -ENOMEM;
mlog_errno(status);
@@ -425,7 +425,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
struct inode *inode = NULL;
struct ocfs2_slot_info *si;
- si = kzalloc(struct_size(si, si_slots, osb->max_slots), GFP_KERNEL);
+ si = kzalloc_flex(*si, si_slots, osb->max_slots, GFP_KERNEL);
if (!si) {
status = -ENOMEM;
mlog_errno(status);
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
index f58e891aa2da..78a97c37398b 100644
--- a/fs/ocfs2/stack_o2cb.c
+++ b/fs/ocfs2/stack_o2cb.c
@@ -334,7 +334,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
goto out;
}
- priv = kzalloc(sizeof(struct o2dlm_private), GFP_KERNEL);
+ priv = kzalloc_obj(struct o2dlm_private, GFP_KERNEL);
if (!priv) {
rc = -ENOMEM;
goto out_free;
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index be0a5758bd40..11b34407de36 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -593,7 +593,7 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
{
struct ocfs2_control_private *p;
- p = kzalloc(sizeof(struct ocfs2_control_private), GFP_KERNEL);
+ p = kzalloc_obj(struct ocfs2_control_private, GFP_KERNEL);
if (!p)
return -ENOMEM;
p->op_this_node = -1;
@@ -967,7 +967,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
BUG_ON(conn == NULL);
- lc = kzalloc(sizeof(struct ocfs2_live_connection), GFP_KERNEL);
+ lc = kzalloc_obj(struct ocfs2_live_connection, GFP_KERNEL);
if (!lc)
return -ENOMEM;
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index fca2fd07c881..46ff5835da2e 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -328,8 +328,7 @@ int ocfs2_cluster_connect(const char *stack_name,
goto out;
}
- new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection),
- GFP_KERNEL);
+ new_conn = kzalloc_obj(struct ocfs2_cluster_connection, GFP_KERNEL);
if (!new_conn) {
rc = -ENOMEM;
goto out;
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 79d1325b2111..872c7b303a3c 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -1034,7 +1034,7 @@ int ocfs2_reserve_new_metadata_blocks(struct ocfs2_super *osb,
int status;
int slot = ocfs2_get_meta_steal_slot(osb);
- *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
+ *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL);
if (!(*ac)) {
status = -ENOMEM;
mlog_errno(status);
@@ -1105,7 +1105,7 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
int slot = ocfs2_get_inode_steal_slot(osb);
u64 alloc_group;
- *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
+ *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL);
if (!(*ac)) {
status = -ENOMEM;
mlog_errno(status);
@@ -1221,7 +1221,7 @@ static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
int status, ret = 0;
int retried = 0;
- *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
+ *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL);
if (!(*ac)) {
status = -ENOMEM;
mlog_errno(status);
@@ -2245,7 +2245,7 @@ int ocfs2_find_new_inode_loc(struct inode *dir,
BUG_ON(ac->ac_bits_wanted != 1);
BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE);
- res = kzalloc(sizeof(*res), GFP_NOFS);
+ res = kzalloc_obj(*res, GFP_NOFS);
if (res == NULL) {
ret = -ENOMEM;
mlog_errno(ret);
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 3cbafac50cd1..9779f524ff1a 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1200,7 +1200,7 @@ static int ocfs2_init_fs_context(struct fs_context *fc)
{
struct mount_options *mopt;
- mopt = kzalloc(sizeof(struct mount_options), GFP_KERNEL);
+ mopt = kzalloc_obj(struct mount_options, GFP_KERNEL);
if (!mopt)
return -EINVAL;
@@ -1953,7 +1953,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
struct ocfs2_super *osb;
u64 total_blocks;
- osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL);
+ osb = kzalloc_obj(struct ocfs2_super, GFP_KERNEL);
if (!osb) {
status = -ENOMEM;
mlog_errno(status);
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index e434a62dd69f..42ee5db362d3 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -324,7 +324,7 @@ static struct ocfs2_xattr_bucket *ocfs2_xattr_bucket_new(struct inode *inode)
BUG_ON(blks > OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET);
- bucket = kzalloc(sizeof(struct ocfs2_xattr_bucket), GFP_NOFS);
+ bucket = kzalloc_obj(struct ocfs2_xattr_bucket, GFP_NOFS);
if (bucket) {
bucket->bu_inode = inode;
bucket->bu_blocks = blks;
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 701ed85d9831..ba2a581f7ab7 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -464,7 +464,7 @@ static int omfs_fill_super(struct super_block *sb, struct fs_context *fc)
int ret = -EINVAL;
int silent = fc->sb_flags & SB_SILENT;
- sbi = kzalloc(sizeof(struct omfs_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct omfs_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
@@ -612,7 +612,7 @@ static int omfs_init_fs_context(struct fs_context *fc)
{
struct omfs_mount_options *opts;
- opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kzalloc_obj(*opts, GFP_KERNEL);
if (!opts)
return -ENOMEM;
diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c
index 3c32bf9f1296..84db9f0db9df 100644
--- a/fs/orangefs/dir.c
+++ b/fs/orangefs/dir.c
@@ -363,8 +363,7 @@ static int orangefs_dir_iterate(struct file *file,
static int orangefs_dir_open(struct inode *inode, struct file *file)
{
struct orangefs_dir *od;
- file->private_data = kmalloc(sizeof(struct orangefs_dir),
- GFP_KERNEL);
+ file->private_data = kmalloc_obj(struct orangefs_dir, GFP_KERNEL);
if (!file->private_data)
return -ENOMEM;
od = file->private_data;
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index f420f48fc069..50836be41cd2 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -184,16 +184,16 @@ static int orangefs_writepages(struct address_space *mapping,
int error;
struct folio *folio = NULL;
- ow = kzalloc(sizeof(struct orangefs_writepages), GFP_KERNEL);
+ ow = kzalloc_obj(struct orangefs_writepages, GFP_KERNEL);
if (!ow)
return -ENOMEM;
ow->maxpages = orangefs_bufmap_size_query()/PAGE_SIZE;
- ow->folios = kcalloc(ow->maxpages, sizeof(struct folio *), GFP_KERNEL);
+ ow->folios = kzalloc_objs(struct folio *, ow->maxpages, GFP_KERNEL);
if (!ow->folios) {
kfree(ow);
return -ENOMEM;
}
- ow->bv = kcalloc(ow->maxpages, sizeof(struct bio_vec), GFP_KERNEL);
+ ow->bv = kzalloc_objs(struct bio_vec, ow->maxpages, GFP_KERNEL);
if (!ow->bv) {
kfree(ow->folios);
kfree(ow);
@@ -328,7 +328,7 @@ static int orangefs_write_begin(const struct kiocb *iocb,
}
}
- wr = kmalloc(sizeof *wr, GFP_KERNEL);
+ wr = kmalloc_obj(*wr, GFP_KERNEL);
if (!wr)
return -ENOMEM;
@@ -644,7 +644,7 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
}
}
}
- wr = kmalloc(sizeof *wr, GFP_KERNEL);
+ wr = kmalloc_obj(*wr, GFP_KERNEL);
if (!wr) {
ret = VM_FAULT_LOCKED|VM_FAULT_RETRY;
goto out;
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index b562d3dbc76b..bad105dd10fa 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -205,7 +205,7 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
{
struct orangefs_bufmap *bufmap;
- bufmap = kzalloc(sizeof(*bufmap), GFP_KERNEL);
+ bufmap = kzalloc_obj(*bufmap, GFP_KERNEL);
if (!bufmap)
goto out;
@@ -219,8 +219,8 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
goto out_free_bufmap;
bufmap->desc_array =
- kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc),
- GFP_KERNEL);
+ kzalloc_objs(struct orangefs_bufmap_desc, bufmap->desc_count,
+ GFP_KERNEL);
if (!bufmap->desc_array)
goto out_free_index_array;
@@ -228,7 +228,7 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
/* allocate storage to track our page mappings */
bufmap->page_array =
- kcalloc(bufmap->page_count, sizeof(struct page *), GFP_KERNEL);
+ kzalloc_objs(struct page *, bufmap->page_count, GFP_KERNEL);
if (!bufmap->page_array)
goto out_free_desc_array;
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 002092950605..229981c310bd 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -560,7 +560,7 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
goto out;
}
- cdm_array = kcalloc(cdm_element_count, sizeof(*cdm_array), GFP_KERNEL);
+ cdm_array = kzalloc_objs(*cdm_array, cdm_element_count, GFP_KERNEL);
if (!cdm_array) {
rc = -ENOMEM;
goto out;
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index 7ac16a4d2dc6..30bc3c17daa4 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -99,7 +99,7 @@ static int __init orangefs_init(void)
goto cleanup_op;
orangefs_htable_ops_in_progress =
- kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL);
+ kzalloc_objs(struct list_head, hash_table_size, GFP_KERNEL);
if (!orangefs_htable_ops_in_progress) {
ret = -ENOMEM;
goto cleanup_inode;
diff --git a/fs/orangefs/orangefs-sysfs.c b/fs/orangefs/orangefs-sysfs.c
index 369455b354ef..8ea25b71b1fb 100644
--- a/fs/orangefs/orangefs-sysfs.c
+++ b/fs/orangefs/orangefs-sysfs.c
@@ -1170,7 +1170,7 @@ int orangefs_sysfs_init(void)
gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
/* create /sys/fs/orangefs. */
- orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
+ orangefs_obj = kzalloc_obj(*orangefs_obj, GFP_KERNEL);
if (!orangefs_obj)
goto out;
@@ -1185,7 +1185,7 @@ int orangefs_sysfs_init(void)
kobject_uevent(orangefs_obj, KOBJ_ADD);
/* create /sys/fs/orangefs/acache. */
- acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
+ acache_orangefs_obj = kzalloc_obj(*acache_orangefs_obj, GFP_KERNEL);
if (!acache_orangefs_obj) {
rc = -EINVAL;
goto ofs_obj_bail;
@@ -1202,8 +1202,7 @@ int orangefs_sysfs_init(void)
kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
/* create /sys/fs/orangefs/capcache. */
- capcache_orangefs_obj =
- kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
+ capcache_orangefs_obj = kzalloc_obj(*capcache_orangefs_obj, GFP_KERNEL);
if (!capcache_orangefs_obj) {
rc = -EINVAL;
goto acache_obj_bail;
@@ -1219,8 +1218,7 @@ int orangefs_sysfs_init(void)
kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
/* create /sys/fs/orangefs/ccache. */
- ccache_orangefs_obj =
- kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
+ ccache_orangefs_obj = kzalloc_obj(*ccache_orangefs_obj, GFP_KERNEL);
if (!ccache_orangefs_obj) {
rc = -EINVAL;
goto capcache_obj_bail;
@@ -1236,7 +1234,7 @@ int orangefs_sysfs_init(void)
kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
/* create /sys/fs/orangefs/ncache. */
- ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
+ ncache_orangefs_obj = kzalloc_obj(*ncache_orangefs_obj, GFP_KERNEL);
if (!ncache_orangefs_obj) {
rc = -EINVAL;
goto ccache_obj_bail;
@@ -1253,7 +1251,7 @@ int orangefs_sysfs_init(void)
kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
/* create /sys/fs/orangefs/perf_counters. */
- pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
+ pc_orangefs_obj = kzalloc_obj(*pc_orangefs_obj, GFP_KERNEL);
if (!pc_orangefs_obj) {
rc = -EINVAL;
goto ncache_obj_bail;
@@ -1270,7 +1268,7 @@ int orangefs_sysfs_init(void)
kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
/* create /sys/fs/orangefs/stats. */
- stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
+ stats_orangefs_obj = kzalloc_obj(*stats_orangefs_obj, GFP_KERNEL);
if (!stats_orangefs_obj) {
rc = -EINVAL;
goto pc_obj_bail;
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index b46100a4f529..3030509ddeaf 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -578,7 +578,7 @@ int orangefs_init_fs_context(struct fs_context *fc)
{
struct orangefs_sb_info_s *osi;
- osi = kzalloc(sizeof(struct orangefs_sb_info_s), GFP_KERNEL);
+ osi = kzalloc_obj(struct orangefs_sb_info_s, GFP_KERNEL);
if (!osi)
return -ENOMEM;
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c
index a431aa07a229..44712bcdcef7 100644
--- a/fs/orangefs/xattr.c
+++ b/fs/orangefs/xattr.c
@@ -171,7 +171,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
" does not exist!\n",
get_khandle_from_ino(inode),
(char *)new_op->upcall.req.getxattr.key);
- cx = kmalloc(sizeof *cx, GFP_KERNEL);
+ cx = kmalloc_obj(*cx, GFP_KERNEL);
if (cx) {
strscpy(cx->key, name);
cx->length = -1;
@@ -225,7 +225,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
cx->length = length;
cx->timeout = jiffies + HZ;
} else {
- cx = kmalloc(sizeof *cx, GFP_KERNEL);
+ cx = kmalloc_obj(*cx, GFP_KERNEL);
if (cx) {
strscpy(cx->key, name);
memcpy(cx->val, buffer, length);
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 8269431ba3c6..7f7a2c2a7937 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -96,7 +96,7 @@ struct ovl_file {
struct ovl_file *ovl_file_alloc(struct file *realfile)
{
- struct ovl_file *of = kzalloc(sizeof(struct ovl_file), GFP_KERNEL);
+ struct ovl_file *of = kzalloc_obj(struct ovl_file, GFP_KERNEL);
if (unlikely(!of))
return NULL;
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index afb7019fd43a..f30b81ee0d9b 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -481,7 +481,7 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
goto invalid;
if (!*stackp)
- *stackp = kmalloc(sizeof(struct ovl_path), GFP_KERNEL);
+ *stackp = kmalloc_obj(struct ovl_path, GFP_KERNEL);
if (!*stackp) {
dput(origin);
return -ENOMEM;
diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c
index 63b7346c5ee1..af735a0c310a 100644
--- a/fs/overlayfs/params.c
+++ b/fs/overlayfs/params.c
@@ -777,7 +777,7 @@ int ovl_init_fs_context(struct fs_context *fc)
struct ovl_fs_context *ctx;
struct ovl_fs *ofs;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL_ACCOUNT);
if (!ctx)
return -ENOMEM;
@@ -785,12 +785,12 @@ int ovl_init_fs_context(struct fs_context *fc)
* By default we allocate for three lower layers. It's likely
* that it'll cover most users.
*/
- ctx->lower = kmalloc_array(3, sizeof(*ctx->lower), GFP_KERNEL_ACCOUNT);
+ ctx->lower = kmalloc_objs(*ctx->lower, 3, GFP_KERNEL_ACCOUNT);
if (!ctx->lower)
goto out_err;
ctx->capacity = 3;
- ofs = kzalloc(sizeof(struct ovl_fs), GFP_KERNEL);
+ ofs = kzalloc_obj(struct ovl_fs, GFP_KERNEL);
if (!ofs)
goto out_err;
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index bb09142b4e15..953c2cdca1b4 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -180,7 +180,7 @@ static struct ovl_cache_entry *ovl_cache_entry_new(struct ovl_readdir_data *rdd,
{
struct ovl_cache_entry *p;
- p = kmalloc(struct_size(p, name, len + 1), GFP_KERNEL);
+ p = kmalloc_flex(*p, name, len + 1, GFP_KERNEL);
if (!p)
return NULL;
@@ -493,7 +493,7 @@ static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
}
ovl_set_dir_cache(d_inode(dentry), NULL);
- cache = kzalloc(sizeof(struct ovl_dir_cache), GFP_KERNEL);
+ cache = kzalloc_obj(struct ovl_dir_cache, GFP_KERNEL);
if (!cache)
return ERR_PTR(-ENOMEM);
@@ -706,7 +706,7 @@ static struct ovl_dir_cache *ovl_cache_get_impure(const struct path *path)
ovl_dir_cache_free(inode);
ovl_set_dir_cache(inode, NULL);
- cache = kzalloc(sizeof(struct ovl_dir_cache), GFP_KERNEL);
+ cache = kzalloc_obj(struct ovl_dir_cache, GFP_KERNEL);
if (!cache)
return ERR_PTR(-ENOMEM);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index c9f166a1390a..f3a39b7703f5 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1031,7 +1031,7 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
unsigned int i;
size_t nr_merged_lower;
- ofs->fs = kcalloc(ctx->nr + 2, sizeof(struct ovl_sb), GFP_KERNEL);
+ ofs->fs = kzalloc_objs(struct ovl_sb, ctx->nr + 2, GFP_KERNEL);
if (ofs->fs == NULL)
return -ENOMEM;
@@ -1393,7 +1393,7 @@ static int ovl_fill_super_creds(struct fs_context *fc, struct super_block *sb)
}
err = -ENOMEM;
- layers = kcalloc(ctx->nr + 1, sizeof(struct ovl_layer), GFP_KERNEL);
+ layers = kzalloc_objs(struct ovl_layer, ctx->nr + 1, GFP_KERNEL);
if (!layers)
return err;
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 94986d11a166..a28524e83662 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -113,7 +113,7 @@ bool ovl_verify_lower(struct super_block *sb)
struct ovl_path *ovl_stack_alloc(unsigned int n)
{
- return kcalloc(n, sizeof(struct ovl_path), GFP_KERNEL);
+ return kzalloc_objs(struct ovl_path, n, GFP_KERNEL);
}
void ovl_stack_cpy(struct ovl_path *dst, struct ovl_path *src, unsigned int n)
@@ -143,7 +143,7 @@ struct ovl_entry *ovl_alloc_entry(unsigned int numlower)
{
struct ovl_entry *oe;
- oe = kzalloc(struct_size(oe, __lowerstack, numlower), GFP_KERNEL);
+ oe = kzalloc_flex(*oe, __lowerstack, numlower, GFP_KERNEL);
if (oe)
oe->__numlower = numlower;
diff --git a/fs/pipe.c b/fs/pipe.c
index 22647f50b286..b44a756c0b41 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -797,7 +797,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
unsigned long user_bufs;
unsigned int max_size = READ_ONCE(pipe_max_size);
- pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL_ACCOUNT);
+ pipe = kzalloc_obj(struct pipe_inode_info, GFP_KERNEL_ACCOUNT);
if (pipe == NULL)
goto out_free_uid;
@@ -814,8 +814,8 @@ struct pipe_inode_info *alloc_pipe_info(void)
if (too_many_pipe_buffers_hard(user_bufs) && pipe_is_unprivileged_user())
goto out_revert_acct;
- pipe->bufs = kcalloc(pipe_bufs, sizeof(struct pipe_buffer),
- GFP_KERNEL_ACCOUNT);
+ pipe->bufs = kzalloc_objs(struct pipe_buffer, pipe_bufs,
+ GFP_KERNEL_ACCOUNT);
if (pipe->bufs) {
init_waitqueue_head(&pipe->rd_wait);
@@ -1297,8 +1297,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
if (unlikely(nr_slots > (pipe_index_t)-1u))
return -EINVAL;
- bufs = kcalloc(nr_slots, sizeof(*bufs),
- GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
+ bufs = kzalloc_objs(*bufs, nr_slots, GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
if (unlikely(!bufs))
return -ENOMEM;
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 4ef6f9d2b8d6..12591c95c925 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -204,7 +204,7 @@ posix_acl_alloc(unsigned int count, gfp_t flags)
{
struct posix_acl *acl;
- acl = kmalloc(struct_size(acl, a_entries, count), flags);
+ acl = kmalloc_flex(*acl, a_entries, count, flags);
if (acl)
posix_acl_init(acl, count);
return acl;
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 728630b10fdf..55438bc0afc8 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -143,7 +143,7 @@ static int kcore_ram_list(struct list_head *head)
{
struct kcore_list *ent;
- ent = kmalloc(sizeof(*ent), GFP_KERNEL);
+ ent = kmalloc_obj(*ent, GFP_KERNEL);
if (!ent)
return -ENOMEM;
ent->addr = (unsigned long)__va(0);
@@ -178,7 +178,7 @@ get_sparsemem_vmemmap_info(struct kcore_list *ent, struct list_head *head)
end = tmp->addr;
}
if (start < end) {
- vmm = kmalloc(sizeof(*vmm), GFP_KERNEL);
+ vmm = kmalloc_obj(*vmm, GFP_KERNEL);
if (!vmm)
return 0;
vmm->addr = start;
@@ -210,7 +210,7 @@ kclist_add_private(unsigned long pfn, unsigned long nr_pages, void *arg)
p = pfn_to_page(pfn);
- ent = kmalloc(sizeof(*ent), GFP_KERNEL);
+ ent = kmalloc_obj(*ent, GFP_KERNEL);
if (!ent)
return -ENOMEM;
ent->addr = (unsigned long)page_to_virt(p);
diff --git a/fs/proc/root.c b/fs/proc/root.c
index d8ca41d823e4..fb0ccacb08e6 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -249,7 +249,7 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc)
struct proc_fs_info *fs_info;
int ret;
- fs_info = kzalloc(sizeof(*fs_info), GFP_KERNEL);
+ fs_info = kzalloc_obj(*fs_info, GFP_KERNEL);
if (!fs_info)
return -ENOMEM;
@@ -331,7 +331,7 @@ static int proc_init_fs_context(struct fs_context *fc)
{
struct proc_fs_context *ctx;
- ctx = kzalloc(sizeof(struct proc_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct proc_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index d7d52e259055..0418511f69fe 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1534,7 +1534,7 @@ static int smaps_rollup_open(struct inode *inode, struct file *file)
int ret;
struct proc_maps_private *priv;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL_ACCOUNT);
+ priv = kzalloc_obj(*priv, GFP_KERNEL_ACCOUNT);
if (!priv)
return -ENOMEM;
@@ -2981,8 +2981,7 @@ static int pagemap_scan_init_bounce_buffer(struct pagemap_scan_private *p)
p->vec_buf_len = min_t(size_t, PAGEMAP_WALK_SIZE >> PAGE_SHIFT,
p->arg.vec_len);
- p->vec_buf = kmalloc_array(p->vec_buf_len, sizeof(*p->vec_buf),
- GFP_KERNEL);
+ p->vec_buf = kmalloc_objs(*p->vec_buf, p->vec_buf_len, GFP_KERNEL);
if (!p->vec_buf)
return -ENOMEM;
diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c
index fa6b8cb788a1..0c9c8b6fdbb8 100644
--- a/fs/pstore/blk.c
+++ b/fs/pstore/blk.c
@@ -297,7 +297,7 @@ static int __init __best_effort_init(void)
return -EINVAL;
}
- best_effort_dev = kzalloc(sizeof(*best_effort_dev), GFP_KERNEL);
+ best_effort_dev = kzalloc_obj(*best_effort_dev, GFP_KERNEL);
if (!best_effort_dev)
return -ENOMEM;
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 71deffcc3356..8ebcd231e09a 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -70,7 +70,7 @@ static void *pstore_ftrace_seq_start(struct seq_file *s, loff_t *pos)
struct pstore_private *ps = s->private;
struct pstore_ftrace_seq_data *data __free(kfree) = NULL;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return NULL;
@@ -365,7 +365,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
record->psi->name, record->id,
record->compressed ? ".enc.z" : "");
- private = kzalloc(sizeof(*private), GFP_KERNEL);
+ private = kzalloc_obj(*private, GFP_KERNEL);
if (!private)
return -ENOMEM;
@@ -477,7 +477,7 @@ static int pstore_init_fs_context(struct fs_context *fc)
{
struct pstore_context *ctx;
- ctx = kzalloc(sizeof(struct pstore_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct pstore_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index f8b9c9c73997..ff9603bb89db 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -683,7 +683,7 @@ void pstore_get_backend_records(struct pstore_info *psi,
struct pstore_record *record;
int rc;
- record = kzalloc(sizeof(*record), GFP_KERNEL);
+ record = kzalloc_obj(*record, GFP_KERNEL);
if (!record) {
pr_err("out of memory creating record\n");
break;
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 39936d6da0dd..79f801c913bf 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -232,8 +232,8 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record)
*/
struct persistent_ram_zone *tmp_prz, *prz_next;
- tmp_prz = kzalloc(sizeof(struct persistent_ram_zone),
- GFP_KERNEL);
+ tmp_prz = kzalloc_obj(struct persistent_ram_zone,
+ GFP_KERNEL);
if (!tmp_prz)
return -ENOMEM;
prz = tmp_prz;
@@ -539,7 +539,7 @@ static int ramoops_init_przs(const char *name,
goto fail;
}
- prz_ar = kcalloc(*cnt, sizeof(**przs), GFP_KERNEL);
+ prz_ar = kzalloc_objs(**przs, *cnt, GFP_KERNEL);
if (!prz_ar)
goto fail;
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 7b6d6378a3b8..49d022b85d8a 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -229,9 +229,8 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
}
/* allocate workspace instead of using stack VLA */
- prz->ecc_info.par = kmalloc_array(prz->ecc_info.ecc_size,
- sizeof(*prz->ecc_info.par),
- GFP_KERNEL);
+ prz->ecc_info.par = kmalloc_objs(*prz->ecc_info.par,
+ prz->ecc_info.ecc_size, GFP_KERNEL);
if (!prz->ecc_info.par) {
pr_err("cannot allocate ECC parity workspace\n");
return -ENOMEM;
@@ -439,7 +438,7 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size,
return NULL;
}
- pages = kmalloc_array(page_count, sizeof(struct page *), GFP_KERNEL);
+ pages = kmalloc_objs(struct page *, page_count, GFP_KERNEL);
if (!pages) {
pr_err("%s: Failed to allocate array for %u pages\n",
__func__, page_count);
@@ -606,7 +605,7 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
struct persistent_ram_zone *prz;
int ret = -ENOMEM;
- prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
+ prz = kzalloc_obj(struct persistent_ram_zone, GFP_KERNEL);
if (!prz) {
pr_err("failed to allocate persistent ram zone\n");
goto err;
diff --git a/fs/pstore/zone.c b/fs/pstore/zone.c
index eb61ba5bb964..6687d255a36b 100644
--- a/fs/pstore/zone.c
+++ b/fs/pstore/zone.c
@@ -1166,7 +1166,7 @@ static struct pstore_zone *psz_init_zone(enum pstore_type_id type,
return ERR_PTR(-ENOMEM);
}
- zone = kzalloc(sizeof(struct pstore_zone), GFP_KERNEL);
+ zone = kzalloc_obj(struct pstore_zone, GFP_KERNEL);
if (!zone)
return ERR_PTR(-ENOMEM);
@@ -1218,7 +1218,7 @@ static struct pstore_zone **psz_init_zones(enum pstore_type_id type,
return ERR_PTR(-EINVAL);
}
- zones = kcalloc(c, sizeof(*zones), GFP_KERNEL);
+ zones = kzalloc_objs(*zones, c, GFP_KERNEL);
if (!zones) {
pr_err("allocate for zones %s failed\n", name);
return ERR_PTR(-ENOMEM);
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 31d78da203ea..e8c4de5de7be 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -197,7 +197,7 @@ static int qnx4_fill_super(struct super_block *s, struct fs_context *fc)
struct qnx4_sb_info *qs;
int silent = fc->sb_flags & SB_SILENT;
- qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL);
+ qs = kzalloc_obj(struct qnx4_sb_info, GFP_KERNEL);
if (!qs)
return -ENOMEM;
s->s_fs_info = qs;
diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index 88d285005083..de1e1a61810d 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -302,7 +302,7 @@ static int qnx6_fill_super(struct super_block *s, struct fs_context *fc)
int bootblock_offset = QNX6_BOOTBLOCK_SIZE;
int silent = fc->sb_flags & SB_SILENT;
- qs = kzalloc(sizeof(struct qnx6_sb_info), GFP_KERNEL);
+ qs = kzalloc_obj(struct qnx6_sb_info, GFP_KERNEL);
if (!qs)
return -ENOMEM;
s->s_fs_info = qs;
@@ -645,7 +645,7 @@ static int qnx6_init_fs_context(struct fs_context *fc)
{
struct qnx6_context *ctx;
- ctx = kzalloc(sizeof(struct qnx6_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct qnx6_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
fc->ops = &qnx6_context_ops;
diff --git a/fs/qnx6/super_mmi.c b/fs/qnx6/super_mmi.c
index d282c2c73404..d36ade7fc477 100644
--- a/fs/qnx6/super_mmi.c
+++ b/fs/qnx6/super_mmi.c
@@ -100,7 +100,7 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
goto out;
}
- qsb = kmalloc(sizeof(*qsb), GFP_KERNEL);
+ qsb = kmalloc_obj(*qsb, GFP_KERNEL);
if (!qsb) {
pr_err("unable to allocate memory.\n");
goto out;
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index 1fda93dcbc1b..d022b18782c6 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -121,7 +121,7 @@ static int v2_read_file_info(struct super_block *sb, int type)
ret = -EIO;
goto out;
}
- info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_KERNEL);
+ info->dqi_priv = kmalloc_obj(struct qtree_mem_dqinfo, GFP_KERNEL);
if (!info->dqi_priv) {
ret = -ENOMEM;
goto out;
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 505d10a0cb36..d084b6804b65 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -298,7 +298,7 @@ int ramfs_init_fs_context(struct fs_context *fc)
{
struct ramfs_fs_info *fsi;
- fsi = kzalloc(sizeof(*fsi), GFP_KERNEL);
+ fsi = kzalloc_obj(*fsi, GFP_KERNEL);
if (!fsi)
return -ENOMEM;
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 0cd5476a483a..6fd5c0e8a0dd 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -923,7 +923,7 @@ int setup_rmid_lru_list(void)
return 0;
idx_limit = resctrl_arch_system_num_rmid_idx();
- rmid_ptrs = kcalloc(idx_limit, sizeof(struct rmid_entry), GFP_KERNEL);
+ rmid_ptrs = kzalloc_objs(struct rmid_entry, idx_limit, GFP_KERNEL);
if (!rmid_ptrs)
return -ENOMEM;
diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c
index e81d71abfe54..55e71d257324 100644
--- a/fs/resctrl/pseudo_lock.c
+++ b/fs/resctrl/pseudo_lock.c
@@ -154,7 +154,7 @@ static int pseudo_lock_cstates_constrain(struct pseudo_lock_region *plr)
int ret;
for_each_cpu(cpu, &plr->d->hdr.cpu_mask) {
- pm_req = kzalloc(sizeof(*pm_req), GFP_KERNEL);
+ pm_req = kzalloc_obj(*pm_req, GFP_KERNEL);
if (!pm_req) {
rdt_last_cmd_puts("Failure to allocate memory for PM QoS\n");
ret = -ENOMEM;
@@ -270,7 +270,7 @@ static int pseudo_lock_init(struct rdtgroup *rdtgrp)
{
struct pseudo_lock_region *plr;
- plr = kzalloc(sizeof(*plr), GFP_KERNEL);
+ plr = kzalloc_obj(*plr, GFP_KERNEL);
if (!plr)
return -ENOMEM;
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index ba8d503551cd..1135208adafb 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2686,7 +2686,7 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
const char *suffix = "";
int ret, cl;
- s = kzalloc(sizeof(*s), GFP_KERNEL);
+ s = kzalloc_obj(*s, GFP_KERNEL);
if (!s)
return -ENOMEM;
@@ -2966,7 +2966,7 @@ static int rdt_init_fs_context(struct fs_context *fc)
{
struct rdt_fs_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
@@ -3117,7 +3117,7 @@ static struct mon_data *mon_get_kn_priv(enum resctrl_res_level rid, int domid,
return priv;
}
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return NULL;
@@ -3753,7 +3753,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
}
/* allocate the rdtgroup. */
- rdtgrp = kzalloc(sizeof(*rdtgrp), GFP_KERNEL);
+ rdtgrp = kzalloc_obj(*rdtgrp, GFP_KERNEL);
if (!rdtgrp) {
ret = -ENOSPC;
rdt_last_cmd_puts("Kernel out of memory\n");
diff --git a/fs/select.c b/fs/select.c
index 78a1508c84d3..57b0af64cc1e 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -993,8 +993,8 @@ static int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
todo -= walk->len;
len = min(todo, POLLFD_PER_PAGE);
- walk = walk->next = kmalloc(struct_size(walk, entries, len),
- GFP_KERNEL);
+ walk = walk->next = kmalloc_flex(*walk, entries, len,
+ GFP_KERNEL);
if (!walk) {
err = -ENOMEM;
goto out_fds;
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 8894cbde8d3a..4745db2a34d1 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -573,7 +573,7 @@ static void single_stop(struct seq_file *p, void *v)
int single_open(struct file *file, int (*show)(struct seq_file *, void *),
void *data)
{
- struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL_ACCOUNT);
+ struct seq_operations *op = kmalloc_obj(*op, GFP_KERNEL_ACCOUNT);
int res = -ENOMEM;
if (op) {
diff --git a/fs/signalfd.c b/fs/signalfd.c
index d69eab584bc6..0b663f9c1cff 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -264,7 +264,7 @@ static int do_signalfd4(int ufd, sigset_t *mask, int flags)
int fd;
struct signalfd_ctx *ctx __free(kfree) = NULL;
- ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kmalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 2a6b8ce80be2..94574dab56f6 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -556,7 +556,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
continue;
spin_lock(&cfids->cfid_list_lock);
list_for_each_entry(cfid, &cfids->entries, entry) {
- tmp_list = kmalloc(sizeof(*tmp_list), GFP_ATOMIC);
+ tmp_list = kmalloc_obj(*tmp_list, GFP_ATOMIC);
if (tmp_list == NULL) {
/*
* If the malloc() fails, we won't drop all
@@ -698,7 +698,7 @@ static struct cached_fid *init_cached_dir(const char *path)
{
struct cached_fid *cfid;
- cfid = kzalloc(sizeof(*cfid), GFP_ATOMIC);
+ cfid = kzalloc_obj(*cfid, GFP_ATOMIC);
if (!cfid)
return NULL;
cfid->path = kstrdup(path, GFP_ATOMIC);
@@ -813,7 +813,7 @@ struct cached_fids *init_cached_dirs(void)
{
struct cached_fids *cfids;
- cfids = kzalloc(sizeof(*cfids), GFP_KERNEL);
+ cfids = kzalloc_obj(*cfids, GFP_KERNEL);
if (!cfids)
return NULL;
spin_lock_init(&cfids->cfid_list_lock);
diff --git a/fs/smb/client/cifs_swn.c b/fs/smb/client/cifs_swn.c
index 68a1f87c446d..9753a432d099 100644
--- a/fs/smb/client/cifs_swn.c
+++ b/fs/smb/client/cifs_swn.c
@@ -315,7 +315,7 @@ static struct cifs_swn_reg *cifs_get_swn_reg(struct cifs_tcon *tcon)
goto unlock;
}
- reg = kmalloc(sizeof(struct cifs_swn_reg), GFP_ATOMIC);
+ reg = kmalloc_obj(struct cifs_swn_reg, GFP_ATOMIC);
if (reg == NULL) {
ret = -ENOMEM;
goto fail_unlock;
diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index f03eda46f452..85ffb8cfe320 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -805,8 +805,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,
offsetof(struct smb_sid, sub_auth) + sizeof(__le16)))
return;
- ppace = kmalloc_array(num_aces, sizeof(struct smb_ace *),
- GFP_KERNEL);
+ ppace = kmalloc_objs(struct smb_ace *, num_aces, GFP_KERNEL);
if (!ppace)
return;
@@ -1332,8 +1331,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,
if (uid_valid(uid)) { /* chown */
uid_t id;
- nowner_sid_ptr = kzalloc(sizeof(struct smb_sid),
- GFP_KERNEL);
+ nowner_sid_ptr = kzalloc_obj(struct smb_sid, GFP_KERNEL);
if (!nowner_sid_ptr) {
rc = -ENOMEM;
goto chown_chgrp_exit;
@@ -1361,8 +1359,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,
}
if (gid_valid(gid)) { /* chgrp */
gid_t id;
- ngroup_sid_ptr = kzalloc(sizeof(struct smb_sid),
- GFP_KERNEL);
+ ngroup_sid_ptr = kzalloc_obj(struct smb_sid, GFP_KERNEL);
if (!ngroup_sid_ptr) {
rc = -ENOMEM;
goto chown_chgrp_exit;
diff --git a/fs/smb/client/cifsencrypt.c b/fs/smb/client/cifsencrypt.c
index 50b7ec39053c..b717b348e98e 100644
--- a/fs/smb/client/cifsencrypt.c
+++ b/fs/smb/client/cifsencrypt.c
@@ -500,7 +500,7 @@ calc_seckey(struct cifs_ses *ses)
get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
- ctx_arc4 = kmalloc(sizeof(*ctx_arc4), GFP_KERNEL);
+ ctx_arc4 = kmalloc_obj(*ctx_arc4, GFP_KERNEL);
if (!ctx_arc4) {
cifs_dbg(VFS, "Could not allocate arc4 context\n");
return -ENOMEM;
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index afda1d7c1ee1..85a53cd77f9e 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -1016,11 +1016,11 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
} else {
cifs_info("Attempting to mount %s\n", old_ctx->source);
}
- cifs_sb = kzalloc(sizeof(*cifs_sb), GFP_KERNEL);
+ cifs_sb = kzalloc_obj(*cifs_sb, GFP_KERNEL);
if (!cifs_sb)
return ERR_PTR(-ENOMEM);
- cifs_sb->ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
+ cifs_sb->ctx = kzalloc_obj(struct smb3_fs_context, GFP_KERNEL);
if (!cifs_sb->ctx) {
root = ERR_PTR(-ENOMEM);
goto out;
diff --git a/fs/smb/client/compress.c b/fs/smb/client/compress.c
index e0c44b46080e..ae536aa63ef1 100644
--- a/fs/smb/client/compress.c
+++ b/fs/smb/client/compress.c
@@ -229,7 +229,7 @@ static bool is_compressible(const struct iov_iter *data)
if (has_repeated_data(sample, len))
goto out;
- bkt = kcalloc(bkt_size, sizeof(*bkt), GFP_KERNEL);
+ bkt = kzalloc_objs(*bkt, bkt_size, GFP_KERNEL);
if (!bkt) {
WARN_ON_ONCE(1);
ret = false;
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 1b479561cbf9..c7ed2ffb66ee 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -1755,7 +1755,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
if (tcp_ses)
return tcp_ses;
- tcp_ses = kzalloc(sizeof(struct TCP_Server_Info), GFP_KERNEL);
+ tcp_ses = kzalloc_obj(struct TCP_Server_Info, GFP_KERNEL);
if (!tcp_ses) {
rc = -ENOMEM;
goto out_err;
@@ -3674,7 +3674,7 @@ static int mount_setup_tlink(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
struct tcon_link *tlink;
/* hang the tcon off of the superblock */
- tlink = kzalloc(sizeof(*tlink), GFP_KERNEL);
+ tlink = kzalloc_obj(*tlink, GFP_KERNEL);
if (tlink == NULL)
return -ENOMEM;
@@ -3798,7 +3798,7 @@ mchan_mount_alloc(struct cifs_ses *ses)
{
struct mchan_mount *mchan_mount;
- mchan_mount = kzalloc(sizeof(*mchan_mount), GFP_KERNEL);
+ mchan_mount = kzalloc_obj(*mchan_mount, GFP_KERNEL);
if (!mchan_mount)
return ERR_PTR(-ENOMEM);
@@ -4193,7 +4193,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
struct smb3_fs_context *ctx;
char *origin_fullpath = NULL;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (ctx == NULL)
return ERR_PTR(-ENOMEM);
@@ -4367,7 +4367,7 @@ cifs_sb_tlink(struct cifs_sb_info *cifs_sb)
spin_unlock(&cifs_sb->tlink_tree_lock);
if (tlink == NULL) {
- newtlink = kzalloc(sizeof(*tlink), GFP_KERNEL);
+ newtlink = kzalloc_obj(*tlink, GFP_KERNEL);
if (newtlink == NULL)
return ERR_PTR(-ENOMEM);
newtlink->tl_uid = fsuid;
diff --git a/fs/smb/client/dfs.h b/fs/smb/client/dfs.h
index 6b5b5ca0f55c..0401c55517b8 100644
--- a/fs/smb/client/dfs.h
+++ b/fs/smb/client/dfs.h
@@ -46,7 +46,7 @@ static inline struct dfs_ref_walk *ref_walk_alloc(void)
{
struct dfs_ref_walk *rw;
- rw = kmalloc(sizeof(*rw), GFP_KERNEL);
+ rw = kmalloc_obj(*rw, GFP_KERNEL);
if (!rw)
return ERR_PTR(-ENOMEM);
return rw;
diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c
index f2ad0ccd08a7..983132735d72 100644
--- a/fs/smb/client/dfs_cache.c
+++ b/fs/smb/client/dfs_cache.c
@@ -363,7 +363,7 @@ static struct cache_dfs_tgt *alloc_target(const char *name, int path_consumed)
{
struct cache_dfs_tgt *t;
- t = kmalloc(sizeof(*t), GFP_ATOMIC);
+ t = kmalloc_obj(*t, GFP_ATOMIC);
if (!t)
return ERR_PTR(-ENOMEM);
t->name = kstrdup(name, GFP_ATOMIC);
@@ -796,7 +796,7 @@ static int get_targets(struct cache_entry *ce, struct dfs_cache_tgt_list *tl)
INIT_LIST_HEAD(head);
list_for_each_entry(t, &ce->tlist, list) {
- it = kzalloc(sizeof(*it), GFP_ATOMIC);
+ it = kzalloc_obj(*it, GFP_ATOMIC);
if (!it) {
rc = -ENOMEM;
goto err_free_it;
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 88273f82812b..43b5b48f5a67 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -489,7 +489,7 @@ int cifs_posix_open(const char *full_path, struct inode **pinode,
cifs_dbg(FYI, "posix open %s\n", full_path);
- presp_data = kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
+ presp_data = kzalloc_obj(FILE_UNIX_BASIC_INFO, GFP_KERNEL);
if (presp_data == NULL)
return -ENOMEM;
@@ -673,11 +673,11 @@ struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
struct cifs_tcon *tcon = tlink_tcon(tlink);
struct TCP_Server_Info *server = tcon->ses->server;
- cfile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
+ cfile = kzalloc_obj(struct cifsFileInfo, GFP_KERNEL);
if (cfile == NULL)
return cfile;
- fdlocks = kzalloc(sizeof(struct cifs_fid_locks), GFP_KERNEL);
+ fdlocks = kzalloc_obj(struct cifs_fid_locks, GFP_KERNEL);
if (!fdlocks) {
kfree(cfile);
return NULL;
@@ -1458,7 +1458,7 @@ int cifs_close(struct inode *inode, struct file *file)
if (file->private_data != NULL) {
cfile = file->private_data;
file->private_data = NULL;
- dclose = kmalloc(sizeof(struct cifs_deferred_close), GFP_KERNEL);
+ dclose = kmalloc_obj(struct cifs_deferred_close, GFP_KERNEL);
if ((cfile->status_file_deleted == false) &&
(smb2_can_defer_close(inode, dclose))) {
if (test_and_clear_bit(NETFS_ICTX_MODIFIED_ATTR, &cinode->netfs.flags)) {
@@ -1582,7 +1582,7 @@ static struct cifsLockInfo *
cifs_lock_init(__u64 offset, __u64 length, __u8 type, __u16 flags)
{
struct cifsLockInfo *lock =
- kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL);
+ kmalloc_obj(struct cifsLockInfo, GFP_KERNEL);
if (!lock)
return lock;
lock->offset = offset;
@@ -1853,7 +1853,7 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
PAGE_SIZE);
max_num = (max_buf - sizeof(struct smb_hdr)) /
sizeof(LOCKING_ANDX_RANGE);
- buf = kcalloc(max_num, sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL);
+ buf = kzalloc_objs(LOCKING_ANDX_RANGE, max_num, GFP_KERNEL);
if (!buf) {
free_xid(xid);
return -ENOMEM;
@@ -1945,7 +1945,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
* protects locking operations of this inode.
*/
for (i = 0; i < count; i++) {
- lck = kmalloc(sizeof(struct lock_to_push), GFP_KERNEL);
+ lck = kmalloc_obj(struct lock_to_push, GFP_KERNEL);
if (!lck) {
rc = -ENOMEM;
goto err_out;
@@ -2229,7 +2229,7 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
PAGE_SIZE);
max_num = (max_buf - sizeof(struct smb_hdr)) /
sizeof(LOCKING_ANDX_RANGE);
- buf = kcalloc(max_num, sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL);
+ buf = kzalloc_objs(LOCKING_ANDX_RANGE, max_num, GFP_KERNEL);
if (!buf)
return -ENOMEM;
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 412c5b534791..4810f926dccb 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1924,7 +1924,7 @@ int smb3_init_fs_context(struct fs_context *fc)
char *nodename = utsname()->nodename;
int i;
- ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct smb3_fs_context, GFP_KERNEL);
if (unlikely(!ctx))
return -ENOMEM;
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index c23c057162e6..d40f39f9547c 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1841,7 +1841,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
/* set ATTR_HIDDEN and clear ATTR_READONLY, but only if needed */
if (dosattr != origattr) {
- info_buf = kzalloc(sizeof(*info_buf), GFP_KERNEL);
+ info_buf = kzalloc_obj(*info_buf, GFP_KERNEL);
if (info_buf == NULL) {
rc = -ENOMEM;
goto out_close;
@@ -2041,7 +2041,7 @@ psx_del_no_retry:
}
}
} else if ((rc == -EACCES) && (dosattr == 0) && inode) {
- attrs = kzalloc(sizeof(*attrs), GFP_KERNEL);
+ attrs = kzalloc_obj(*attrs, GFP_KERNEL);
if (attrs == NULL) {
rc = -ENOMEM;
goto out_reval;
@@ -2197,7 +2197,7 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode,
struct inode *newinode = NULL;
struct cifs_fattr fattr;
- info = kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
+ info = kzalloc_obj(FILE_UNIX_BASIC_INFO, GFP_KERNEL);
if (info == NULL) {
rc = -ENOMEM;
goto posix_mkdir_out;
@@ -2585,8 +2585,7 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
* with unix extensions enabled.
*/
info_buf_source =
- kmalloc_array(2, sizeof(FILE_UNIX_BASIC_INFO),
- GFP_KERNEL);
+ kmalloc_objs(FILE_UNIX_BASIC_INFO, 2, GFP_KERNEL);
if (info_buf_source == NULL) {
rc = -ENOMEM;
goto cifs_rename_exit;
@@ -3167,7 +3166,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
attrs->ia_valid &= ~ATTR_MODE;
- args = kmalloc(sizeof(*args), GFP_KERNEL);
+ args = kmalloc_obj(*args, GFP_KERNEL);
if (args == NULL) {
rc = -ENOMEM;
goto out;
diff --git a/fs/smb/client/ioctl.c b/fs/smb/client/ioctl.c
index a4aa063cf5ea..6d24184c8735 100644
--- a/fs/smb/client/ioctl.c
+++ b/fs/smb/client/ioctl.c
@@ -133,7 +133,7 @@ static long smb_mnt_get_fsinfo(unsigned int xid, struct cifs_tcon *tcon,
int rc = 0;
struct smb_mnt_fs_info *fsinf;
- fsinf = kzalloc(sizeof(struct smb_mnt_fs_info), GFP_KERNEL);
+ fsinf = kzalloc_obj(struct smb_mnt_fs_info, GFP_KERNEL);
if (fsinf == NULL)
return -ENOMEM;
diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c
index 1773e3b471aa..290d0a0bea53 100644
--- a/fs/smb/client/misc.c
+++ b/fs/smb/client/misc.c
@@ -67,7 +67,7 @@ sesInfoAlloc(void)
{
struct cifs_ses *ret_buf;
- ret_buf = kzalloc(sizeof(struct cifs_ses), GFP_KERNEL);
+ ret_buf = kzalloc_obj(struct cifs_ses, GFP_KERNEL);
if (ret_buf) {
atomic_inc(&sesInfoAllocCount);
spin_lock_init(&ret_buf->ses_lock);
@@ -118,7 +118,7 @@ tcon_info_alloc(bool dir_leases_enabled, enum smb3_tcon_ref_trace trace)
struct cifs_tcon *ret_buf;
static atomic_t tcon_debug_id;
- ret_buf = kzalloc(sizeof(*ret_buf), GFP_KERNEL);
+ ret_buf = kzalloc_obj(*ret_buf, GFP_KERNEL);
if (!ret_buf)
return NULL;
@@ -499,7 +499,8 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode)
cifs_del_deferred_close(cfile);
spin_unlock(&cifs_inode->deferred_lock);
- tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC);
+ tmp_list = kmalloc_obj(struct file_list,
+ GFP_ATOMIC);
if (tmp_list == NULL)
break;
tmp_list->cfile = cfile;
@@ -531,7 +532,8 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon)
cifs_del_deferred_close(cfile);
spin_unlock(&CIFS_I(d_inode(cfile->dentry))->deferred_lock);
- tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC);
+ tmp_list = kmalloc_obj(struct file_list,
+ GFP_ATOMIC);
if (tmp_list == NULL)
break;
tmp_list->cfile = cfile;
@@ -564,7 +566,7 @@ void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon,
cifs_del_deferred_close(cfile);
spin_unlock(&CIFS_I(d_inode(cfile->dentry))->deferred_lock);
- tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC);
+ tmp_list = kmalloc_obj(struct file_list, GFP_ATOMIC);
if (tmp_list == NULL)
break;
tmp_list->cfile = cfile;
@@ -671,8 +673,8 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
cifs_dbg(FYI, "num_referrals: %d dfs flags: 0x%x ...\n",
*num_of_nodes, le32_to_cpu(rsp->DFSFlags));
- *target_nodes = kcalloc(*num_of_nodes, sizeof(struct dfs_info3_param),
- GFP_KERNEL);
+ *target_nodes = kzalloc_objs(struct dfs_info3_param, *num_of_nodes,
+ GFP_KERNEL);
if (*target_nodes == NULL) {
rc = -ENOMEM;
goto parse_DFS_referrals_exit;
diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c
index 67a8555efa1e..53e17fb2b6ee 100644
--- a/fs/smb/client/readdir.c
+++ b/fs/smb/client/readdir.c
@@ -358,7 +358,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,
if (IS_ERR(tlink))
return PTR_ERR(tlink);
- cifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
+ cifsFile = kzalloc_obj(struct cifsFileInfo, GFP_KERNEL);
if (cifsFile == NULL) {
rc = -ENOMEM;
goto error_exit;
@@ -888,7 +888,7 @@ static bool add_cached_dirent(struct cached_dirents *cde,
cde->is_failed = 1;
return false;
}
- de = kzalloc(sizeof(*de), GFP_ATOMIC);
+ de = kzalloc_obj(*de, GFP_ATOMIC);
if (de == NULL) {
cde->is_failed = 1;
return false;
diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
index d523540565ef..e32f9e185499 100644
--- a/fs/smb/client/sess.c
+++ b/fs/smb/client/sess.c
@@ -510,7 +510,7 @@ cifs_ses_add_channel(struct cifs_ses *ses,
* the session and server without caring about memory
* management.
*/
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx) {
rc = -ENOMEM;
goto out_free_xid;
diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c
index 970aeffe936e..689e052c2809 100644
--- a/fs/smb/client/smb1ops.c
+++ b/fs/smb/client/smb1ops.c
@@ -506,7 +506,7 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
int rc;
FILE_ALL_INFO *file_info;
- file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
+ file_info = kmalloc_obj(FILE_ALL_INFO, GFP_KERNEL);
if (file_info == NULL)
return -ENOMEM;
diff --git a/fs/smb/client/smb1session.c b/fs/smb/client/smb1session.c
index 1cf6bd640fde..f5ef07d24b5f 100644
--- a/fs/smb/client/smb1session.c
+++ b/fs/smb/client/smb1session.c
@@ -725,7 +725,7 @@ sess_auth_rawntlmssp_negotiate(struct sess_data *sess_data)
* if memory allocation is successful, caller of this function
* frees it.
*/
- ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL);
+ ses->ntlmssp = kmalloc_obj(struct ntlmssp_auth, GFP_KERNEL);
if (!ses->ntlmssp) {
rc = -ENOMEM;
goto out;
@@ -969,7 +969,7 @@ int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
return -EINVAL;
}
- sess_data = kzalloc(sizeof(struct sess_data), GFP_KERNEL);
+ sess_data = kzalloc_obj(struct sess_data, GFP_KERNEL);
if (!sess_data)
return -ENOMEM;
diff --git a/fs/smb/client/smb2file.c b/fs/smb/client/smb2file.c
index 476c53b3711f..6dba874156aa 100644
--- a/fs/smb/client/smb2file.c
+++ b/fs/smb/client/smb2file.c
@@ -281,7 +281,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
max_num = max_buf / sizeof(struct smb2_lock_element);
- buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL);
+ buf = kzalloc_objs(struct smb2_lock_element, max_num, GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -424,7 +424,7 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
max_num = max_buf / sizeof(struct smb2_lock_element);
- buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL);
+ buf = kzalloc_objs(struct smb2_lock_element, max_num, GFP_KERNEL);
if (!buf) {
free_xid(xid);
return -ENOMEM;
diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 8a30088fed15..195a38fd61e8 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -209,7 +209,7 @@ replay_again:
num_rqst = 0;
server = cifs_pick_channel(ses);
- vars = kzalloc(sizeof(*vars), GFP_ATOMIC);
+ vars = kzalloc_obj(*vars, GFP_ATOMIC);
if (vars == NULL) {
rc = -ENOMEM;
goto out;
diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
index d1ae839e4863..efba7cb9fb70 100644
--- a/fs/smb/client/smb2misc.c
+++ b/fs/smb/client/smb2misc.c
@@ -526,7 +526,7 @@ smb2_queue_pending_open_break(struct tcon_link *tlink, __u8 *lease_key,
{
struct smb2_lease_break_work *lw;
- lw = kmalloc(sizeof(struct smb2_lease_break_work), GFP_KERNEL);
+ lw = kmalloc_obj(struct smb2_lease_break_work, GFP_KERNEL);
if (!lw) {
cifs_put_tlink(tlink);
return;
@@ -798,7 +798,7 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid,
{
struct close_cancelled_open *cancelled;
- cancelled = kzalloc(sizeof(*cancelled), GFP_KERNEL);
+ cancelled = kzalloc_obj(*cancelled, GFP_KERNEL);
if (!cancelled)
return -ENOMEM;
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 7370d7a18cd0..071df7465a8b 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -731,8 +731,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
spin_unlock(&ses->iface_lock);
/* no match. insert the entry in the list */
- info = kmalloc(sizeof(struct cifs_server_iface),
- GFP_KERNEL);
+ info = kmalloc_obj(struct cifs_server_iface, GFP_KERNEL);
if (!info) {
rc = -ENOMEM;
goto out;
@@ -1202,7 +1201,7 @@ replay_again:
ea = NULL;
resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
- vars = kzalloc(sizeof(*vars), GFP_KERNEL);
+ vars = kzalloc_obj(*vars, GFP_KERNEL);
if (!vars) {
rc = -ENOMEM;
goto out_free_path;
@@ -1594,7 +1593,7 @@ replay_again:
oplock = SMB2_OPLOCK_LEVEL_NONE;
server = cifs_pick_channel(ses);
- vars = kzalloc(sizeof(*vars), GFP_ATOMIC);
+ vars = kzalloc_obj(*vars, GFP_ATOMIC);
if (vars == NULL)
return -ENOMEM;
rqst = &vars->rqst[0];
@@ -1889,7 +1888,7 @@ retry:
goto out;
}
- cc_req = kzalloc(struct_size(cc_req, Chunks, chunk_count), GFP_KERNEL);
+ cc_req = kzalloc_flex(*cc_req, Chunks, chunk_count, GFP_KERNEL);
if (!cc_req) {
rc = -ENOMEM;
goto out;
@@ -2850,7 +2849,7 @@ replay_again:
flags |= CIFS_TRANSFORM_REQ;
resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
- vars = kzalloc(sizeof(*vars), GFP_KERNEL);
+ vars = kzalloc_obj(*vars, GFP_KERNEL);
if (!vars) {
rc = -ENOMEM;
goto out_free_path;
@@ -4221,7 +4220,7 @@ smb2_create_lease_buf(u8 *lease_key, u8 oplock, u8 *parent_lease_key, __le32 fla
{
struct create_lease *buf;
- buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL);
+ buf = kzalloc_obj(struct create_lease, GFP_KERNEL);
if (!buf)
return NULL;
@@ -4247,7 +4246,7 @@ smb3_create_lease_buf(u8 *lease_key, u8 oplock, u8 *parent_lease_key, __le32 fla
{
struct create_lease_v2 *buf;
- buf = kzalloc(sizeof(struct create_lease_v2), GFP_KERNEL);
+ buf = kzalloc_obj(struct create_lease_v2, GFP_KERNEL);
if (!buf)
return NULL;
@@ -4931,7 +4930,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
int rc;
struct smb2_decrypt_work *dw;
- dw = kzalloc(sizeof(struct smb2_decrypt_work), GFP_KERNEL);
+ dw = kzalloc_obj(struct smb2_decrypt_work, GFP_KERNEL);
if (!dw)
return -ENOMEM;
INIT_WORK(&dw->decrypt, smb2_decrypt_offload);
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 7f3edf42b9c3..0ebfdfebc5e9 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -1009,8 +1009,7 @@ create_posix_buf(umode_t mode)
{
struct create_posix *buf;
- buf = kzalloc(sizeof(struct create_posix),
- GFP_KERNEL);
+ buf = kzalloc_obj(struct create_posix, GFP_KERNEL);
if (!buf)
return NULL;
@@ -1359,7 +1358,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
cifs_tcon_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
- pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS);
+ pneg_inbuf = kmalloc_obj(*pneg_inbuf, GFP_NOFS);
if (!pneg_inbuf)
return -ENOMEM;
@@ -1786,7 +1785,7 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data)
* If memory allocation is successful, caller of this function
* frees it.
*/
- ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL);
+ ses->ntlmssp = kmalloc_obj(struct ntlmssp_auth, GFP_KERNEL);
if (!ses->ntlmssp) {
rc = -ENOMEM;
goto out_err;
@@ -1984,7 +1983,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
return smb_EIO(smb_eio_trace_null_pointers);
}
- sess_data = kzalloc(sizeof(struct SMB2_sess_data), GFP_KERNEL);
+ sess_data = kzalloc_obj(struct SMB2_sess_data, GFP_KERNEL);
if (!sess_data)
return -ENOMEM;
@@ -2298,7 +2297,7 @@ create_durable_buf(void)
{
create_durable_req_t *buf;
- buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL);
+ buf = kzalloc_obj(create_durable_req_t, GFP_KERNEL);
if (!buf)
return NULL;
@@ -2321,7 +2320,7 @@ create_reconnect_durable_buf(struct cifs_fid *fid)
{
create_durable_req_t *buf;
- buf = kzalloc(sizeof(create_durable_req_t), GFP_KERNEL);
+ buf = kzalloc_obj(create_durable_req_t, GFP_KERNEL);
if (!buf)
return NULL;
@@ -2493,7 +2492,7 @@ create_durable_v2_buf(struct cifs_open_parms *oparms)
struct cifs_fid *pfid = oparms->fid;
struct create_durable_req_v2 *buf;
- buf = kzalloc(sizeof(struct create_durable_req_v2), GFP_KERNEL);
+ buf = kzalloc_obj(struct create_durable_req_v2, GFP_KERNEL);
if (!buf)
return NULL;
@@ -2534,8 +2533,7 @@ create_reconnect_durable_v2_buf(struct cifs_fid *fid)
{
struct create_durable_handle_reconnect_v2 *buf;
- buf = kzalloc(sizeof(struct create_durable_handle_reconnect_v2),
- GFP_KERNEL);
+ buf = kzalloc_obj(struct create_durable_handle_reconnect_v2, GFP_KERNEL);
if (!buf)
return NULL;
@@ -2626,7 +2624,7 @@ create_twarp_buf(__u64 timewarp)
{
struct crt_twarp_ctxt *buf;
- buf = kzalloc(sizeof(struct crt_twarp_ctxt), GFP_KERNEL);
+ buf = kzalloc_obj(struct crt_twarp_ctxt, GFP_KERNEL);
if (!buf)
return NULL;
@@ -2793,7 +2791,7 @@ create_query_id_buf(void)
{
struct crt_query_id_ctxt *buf;
- buf = kzalloc(sizeof(struct crt_query_id_ctxt), GFP_KERNEL);
+ buf = kzalloc_obj(struct crt_query_id_ctxt, GFP_KERNEL);
if (!buf)
return NULL;
@@ -5845,7 +5843,7 @@ replay_again:
if (smb3_encryption_required(tcon))
flags |= CIFS_TRANSFORM_REQ;
- iov = kmalloc_array(num, sizeof(struct kvec), GFP_KERNEL);
+ iov = kmalloc_objs(struct kvec, num, GFP_KERNEL);
if (!iov)
return -ENOMEM;
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index d44847c9d8fc..e2df73c719fd 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -2098,7 +2098,7 @@ static struct smbd_connection *_smbd_get_connection(
char wq_name[80];
struct workqueue_struct *workqueue;
- info = kzalloc(sizeof(struct smbd_connection), GFP_KERNEL);
+ info = kzalloc_obj(struct smbd_connection, GFP_KERNEL);
if (!info)
return NULL;
sc = &info->socket;
@@ -2786,7 +2786,7 @@ static int allocate_mr_list(struct smbdirect_socket *sc)
/* Allocate more MRs (2x) than hardware responder_resources */
for (i = 0; i < sp->responder_resources * 2; i++) {
- mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+ mr = kzalloc_obj(*mr, GFP_KERNEL);
if (!mr) {
ret = -ENOMEM;
goto kzalloc_mr_failed;
@@ -2805,9 +2805,8 @@ static int allocate_mr_list(struct smbdirect_socket *sc)
goto ib_alloc_mr_failed;
}
- mr->sgt.sgl = kcalloc(sp->max_frmr_depth,
- sizeof(struct scatterlist),
- GFP_KERNEL);
+ mr->sgt.sgl = kzalloc_objs(struct scatterlist,
+ sp->max_frmr_depth, GFP_KERNEL);
if (!mr->sgt.sgl) {
ret = -ENOMEM;
log_rdma_mr(ERR, "failed to allocate sgl\n");
diff --git a/fs/smb/server/auth.c b/fs/smb/server/auth.c
index 09af55b71153..580c4d303dc3 100644
--- a/fs/smb/server/auth.c
+++ b/fs/smb/server/auth.c
@@ -239,7 +239,7 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob,
if (sess_key_len > CIFS_KEY_SIZE)
return -EINVAL;
- ctx_arc4 = kmalloc(sizeof(*ctx_arc4), KSMBD_DEFAULT_GFP);
+ ctx_arc4 = kmalloc_obj(*ctx_arc4, KSMBD_DEFAULT_GFP);
if (!ctx_arc4)
return -ENOMEM;
@@ -774,7 +774,7 @@ static struct scatterlist *ksmbd_init_sg(struct kvec *iov, unsigned int nvec,
if (!nvec)
return NULL;
- nr_entries = kcalloc(nvec, sizeof(int), KSMBD_DEFAULT_GFP);
+ nr_entries = kzalloc_objs(int, nvec, KSMBD_DEFAULT_GFP);
if (!nr_entries)
return NULL;
@@ -794,8 +794,7 @@ static struct scatterlist *ksmbd_init_sg(struct kvec *iov, unsigned int nvec,
/* Add two entries for transform header and signature */
total_entries += 2;
- sg = kmalloc_array(total_entries, sizeof(struct scatterlist),
- KSMBD_DEFAULT_GFP);
+ sg = kmalloc_objs(struct scatterlist, total_entries, KSMBD_DEFAULT_GFP);
if (!sg) {
kfree(nr_entries);
return NULL;
diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c
index e7e3e77006b1..1bb2081c492c 100644
--- a/fs/smb/server/connection.c
+++ b/fs/smb/server/connection.c
@@ -111,7 +111,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void)
{
struct ksmbd_conn *conn;
- conn = kzalloc(sizeof(struct ksmbd_conn), KSMBD_DEFAULT_GFP);
+ conn = kzalloc_obj(struct ksmbd_conn, KSMBD_DEFAULT_GFP);
if (!conn)
return NULL;
diff --git a/fs/smb/server/crypto_ctx.c b/fs/smb/server/crypto_ctx.c
index fe29d186baf6..8fd9713b00b7 100644
--- a/fs/smb/server/crypto_ctx.c
+++ b/fs/smb/server/crypto_ctx.c
@@ -121,7 +121,7 @@ static struct ksmbd_crypto_ctx *ksmbd_find_crypto_ctx(void)
ctx_list.avail_ctx++;
spin_unlock(&ctx_list.ctx_lock);
- ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), KSMBD_DEFAULT_GFP);
+ ctx = kzalloc_obj(struct ksmbd_crypto_ctx, KSMBD_DEFAULT_GFP);
if (!ctx) {
spin_lock(&ctx_list.ctx_lock);
ctx_list.avail_ctx--;
@@ -226,7 +226,7 @@ int ksmbd_crypto_create(void)
init_waitqueue_head(&ctx_list.ctx_wait);
ctx_list.avail_ctx = 1;
- ctx = kzalloc(sizeof(struct ksmbd_crypto_ctx), KSMBD_DEFAULT_GFP);
+ ctx = kzalloc_obj(struct ksmbd_crypto_ctx, KSMBD_DEFAULT_GFP);
if (!ctx)
return -ENOMEM;
list_add(&ctx->list, &ctx_list.idle_ctx);
diff --git a/fs/smb/server/ksmbd_work.c b/fs/smb/server/ksmbd_work.c
index 4a71f46d7020..ab4958dc3eb0 100644
--- a/fs/smb/server/ksmbd_work.c
+++ b/fs/smb/server/ksmbd_work.c
@@ -28,8 +28,8 @@ struct ksmbd_work *ksmbd_alloc_work_struct(void)
INIT_LIST_HEAD(&work->fp_entry);
INIT_LIST_HEAD(&work->aux_read_list);
work->iov_alloc_cnt = 4;
- work->iov = kcalloc(work->iov_alloc_cnt, sizeof(struct kvec),
- KSMBD_DEFAULT_GFP);
+ work->iov = kzalloc_objs(struct kvec, work->iov_alloc_cnt,
+ KSMBD_DEFAULT_GFP);
if (!work->iov) {
kmem_cache_free(work_cache, work);
work = NULL;
@@ -111,7 +111,7 @@ static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len,
if (aux_size) {
need_iov_cnt++;
- ar = kmalloc(sizeof(struct aux_read), KSMBD_DEFAULT_GFP);
+ ar = kmalloc_obj(struct aux_read, KSMBD_DEFAULT_GFP);
if (!ar)
return -ENOMEM;
}
diff --git a/fs/smb/server/mgmt/share_config.c b/fs/smb/server/mgmt/share_config.c
index c9b1108d6e96..53f44ff4d376 100644
--- a/fs/smb/server/mgmt/share_config.c
+++ b/fs/smb/server/mgmt/share_config.c
@@ -102,7 +102,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,
if (!sz)
break;
- p = kzalloc(sizeof(struct ksmbd_veto_pattern), KSMBD_DEFAULT_GFP);
+ p = kzalloc_obj(struct ksmbd_veto_pattern, KSMBD_DEFAULT_GFP);
if (!p)
return -ENOMEM;
@@ -150,7 +150,7 @@ static struct ksmbd_share_config *share_config_request(struct ksmbd_work *work,
goto out;
}
- share = kzalloc(sizeof(struct ksmbd_share_config), KSMBD_DEFAULT_GFP);
+ share = kzalloc_obj(struct ksmbd_share_config, KSMBD_DEFAULT_GFP);
if (!share)
goto out;
diff --git a/fs/smb/server/mgmt/tree_connect.c b/fs/smb/server/mgmt/tree_connect.c
index 57dd47ef688c..a72d7e42a6c2 100644
--- a/fs/smb/server/mgmt/tree_connect.c
+++ b/fs/smb/server/mgmt/tree_connect.c
@@ -32,8 +32,7 @@ ksmbd_tree_conn_connect(struct ksmbd_work *work, const char *share_name)
if (!sc)
return status;
- tree_conn = kzalloc(sizeof(struct ksmbd_tree_connect),
- KSMBD_DEFAULT_GFP);
+ tree_conn = kzalloc_obj(struct ksmbd_tree_connect, KSMBD_DEFAULT_GFP);
if (!tree_conn) {
status.ret = -ENOMEM;
goto out_error;
diff --git a/fs/smb/server/mgmt/user_config.c b/fs/smb/server/mgmt/user_config.c
index 3267b86b8c16..a3183fe5c536 100644
--- a/fs/smb/server/mgmt/user_config.c
+++ b/fs/smb/server/mgmt/user_config.c
@@ -36,7 +36,7 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp,
{
struct ksmbd_user *user;
- user = kmalloc(sizeof(struct ksmbd_user), KSMBD_DEFAULT_GFP);
+ user = kmalloc_obj(struct ksmbd_user, KSMBD_DEFAULT_GFP);
if (!user)
return NULL;
diff --git a/fs/smb/server/mgmt/user_session.c b/fs/smb/server/mgmt/user_session.c
index 957a12de6a9d..39be2d2be86c 100644
--- a/fs/smb/server/mgmt/user_session.c
+++ b/fs/smb/server/mgmt/user_session.c
@@ -322,7 +322,7 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
if (!method)
return -EINVAL;
- entry = kzalloc(sizeof(struct ksmbd_session_rpc), KSMBD_DEFAULT_GFP);
+ entry = kzalloc_obj(struct ksmbd_session_rpc, KSMBD_DEFAULT_GFP);
if (!entry)
return -ENOMEM;
@@ -579,7 +579,7 @@ struct preauth_session *ksmbd_preauth_session_alloc(struct ksmbd_conn *conn,
{
struct preauth_session *sess;
- sess = kmalloc(sizeof(struct preauth_session), KSMBD_DEFAULT_GFP);
+ sess = kmalloc_obj(struct preauth_session, KSMBD_DEFAULT_GFP);
if (!sess)
return NULL;
@@ -663,7 +663,7 @@ static struct ksmbd_session *__session_create(int protocol)
if (protocol != CIFDS_SESSION_FLAG_SMB2)
return NULL;
- sess = kzalloc(sizeof(struct ksmbd_session), KSMBD_DEFAULT_GFP);
+ sess = kzalloc_obj(struct ksmbd_session, KSMBD_DEFAULT_GFP);
if (!sess)
return NULL;
diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
index a5967ac46604..09d9878db9cb 100644
--- a/fs/smb/server/oplock.c
+++ b/fs/smb/server/oplock.c
@@ -34,7 +34,7 @@ static struct oplock_info *alloc_opinfo(struct ksmbd_work *work,
struct ksmbd_session *sess = work->sess;
struct oplock_info *opinfo;
- opinfo = kzalloc(sizeof(struct oplock_info), KSMBD_DEFAULT_GFP);
+ opinfo = kzalloc_obj(struct oplock_info, KSMBD_DEFAULT_GFP);
if (!opinfo)
return NULL;
@@ -93,7 +93,7 @@ static int alloc_lease(struct oplock_info *opinfo, struct lease_ctx_info *lctx)
{
struct lease *lease;
- lease = kmalloc(sizeof(struct lease), KSMBD_DEFAULT_GFP);
+ lease = kmalloc_obj(struct lease, KSMBD_DEFAULT_GFP);
if (!lease)
return -ENOMEM;
@@ -698,7 +698,7 @@ static int smb2_oplock_break_noti(struct oplock_info *opinfo)
if (!work)
return -ENOMEM;
- br_info = kmalloc(sizeof(struct oplock_break_info), KSMBD_DEFAULT_GFP);
+ br_info = kmalloc_obj(struct oplock_break_info, KSMBD_DEFAULT_GFP);
if (!br_info) {
ksmbd_free_work_struct(work);
return -ENOMEM;
@@ -803,7 +803,7 @@ static int smb2_lease_break_noti(struct oplock_info *opinfo)
if (!work)
return -ENOMEM;
- br_info = kmalloc(sizeof(struct lease_break_info), KSMBD_DEFAULT_GFP);
+ br_info = kmalloc_obj(struct lease_break_info, KSMBD_DEFAULT_GFP);
if (!br_info) {
ksmbd_free_work_struct(work);
return -ENOMEM;
@@ -1046,7 +1046,7 @@ static int add_lease_global_list(struct oplock_info *opinfo)
}
read_unlock(&lease_list_lock);
- lb = kmalloc(sizeof(struct lease_table), KSMBD_DEFAULT_GFP);
+ lb = kmalloc_obj(struct lease_table, KSMBD_DEFAULT_GFP);
if (!lb)
return -ENOMEM;
@@ -1491,7 +1491,7 @@ struct lease_ctx_info *parse_lease_state(void *open_req)
if (IS_ERR_OR_NULL(cc))
return NULL;
- lreq = kzalloc(sizeof(struct lease_ctx_info), KSMBD_DEFAULT_GFP);
+ lreq = kzalloc_obj(struct lease_ctx_info, KSMBD_DEFAULT_GFP);
if (!lreq)
return NULL;
diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c
index c2c074346da1..c3f1b7219950 100644
--- a/fs/smb/server/server.c
+++ b/fs/smb/server/server.c
@@ -410,7 +410,7 @@ static int __queue_ctrl_work(int type)
{
struct server_ctrl_struct *ctrl;
- ctrl = kmalloc(sizeof(struct server_ctrl_struct), KSMBD_DEFAULT_GFP);
+ ctrl = kmalloc_obj(struct server_ctrl_struct, KSMBD_DEFAULT_GFP);
if (!ctrl)
return -ENOMEM;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index cbb31efdbaa2..8a3e17fd4af9 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -1164,8 +1164,8 @@ int smb2_handle_negotiate(struct ksmbd_work *work)
switch (conn->dialect) {
case SMB311_PROT_ID:
conn->preauth_info =
- kzalloc(sizeof(struct preauth_integrity_info),
- KSMBD_DEFAULT_GFP);
+ kzalloc_obj(struct preauth_integrity_info,
+ KSMBD_DEFAULT_GFP);
if (!conn->preauth_info) {
rc = -ENOMEM;
rsp->hdr.Status = STATUS_INVALID_PARAMETER;
@@ -1560,7 +1560,7 @@ binding_session:
if (conn->dialect >= SMB30_PROT_ID) {
chann = lookup_chann_list(sess, conn);
if (!chann) {
- chann = kmalloc(sizeof(struct channel), KSMBD_DEFAULT_GFP);
+ chann = kmalloc_obj(struct channel, KSMBD_DEFAULT_GFP);
if (!chann)
return -ENOMEM;
@@ -1655,7 +1655,7 @@ binding_session:
if (conn->dialect >= SMB30_PROT_ID) {
chann = lookup_chann_list(sess, conn);
if (!chann) {
- chann = kmalloc(sizeof(struct channel), KSMBD_DEFAULT_GFP);
+ chann = kmalloc_obj(struct channel, KSMBD_DEFAULT_GFP);
if (!chann)
return -ENOMEM;
@@ -7326,7 +7326,7 @@ static struct ksmbd_lock *smb2_lock_init(struct file_lock *flock,
{
struct ksmbd_lock *lock;
- lock = kzalloc(sizeof(struct ksmbd_lock), KSMBD_DEFAULT_GFP);
+ lock = kzalloc_obj(struct ksmbd_lock, KSMBD_DEFAULT_GFP);
if (!lock)
return NULL;
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 05598d994a68..49c2abb29bf5 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -417,7 +417,7 @@ static void parse_dacl(struct mnt_idmap *idmap,
return;
}
- ppace = kmalloc_array(num_aces, sizeof(struct smb_ace *), KSMBD_DEFAULT_GFP);
+ ppace = kmalloc_objs(struct smb_ace *, num_aces, KSMBD_DEFAULT_GFP);
if (!ppace) {
free_acl_state(&default_acl_state);
free_acl_state(&acl_state);
@@ -603,7 +603,7 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
for (i = 0; i < fattr->cf_acls->a_count; i++, pace++) {
int flags = 0;
- sid = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP);
+ sid = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP);
if (!sid)
break;
@@ -670,7 +670,7 @@ posix_default_acl:
pace = fattr->cf_dacls->a_entries;
for (i = 0; i < fattr->cf_dacls->a_count; i++, pace++) {
- sid = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP);
+ sid = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP);
if (!sid)
break;
@@ -930,7 +930,7 @@ int build_sec_desc(struct mnt_idmap *idmap,
gid_t gid;
unsigned int sid_type = SIDOWNER;
- nowner_sid_ptr = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP);
+ nowner_sid_ptr = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP);
if (!nowner_sid_ptr)
return -ENOMEM;
@@ -939,7 +939,7 @@ int build_sec_desc(struct mnt_idmap *idmap,
sid_type = SIDUNIX_USER;
id_to_sid(uid, sid_type, nowner_sid_ptr);
- ngroup_sid_ptr = kmalloc(sizeof(struct smb_sid), KSMBD_DEFAULT_GFP);
+ ngroup_sid_ptr = kmalloc_obj(struct smb_sid, KSMBD_DEFAULT_GFP);
if (!ngroup_sid_ptr) {
kfree(nowner_sid_ptr);
return -ENOMEM;
diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c
index fb36fb9d5214..7c53b78b818e 100644
--- a/fs/smb/server/transport_rdma.c
+++ b/fs/smb/server/transport_rdma.c
@@ -411,7 +411,7 @@ static struct smb_direct_transport *alloc_transport(struct rdma_cm_id *cm_id)
struct smbdirect_socket_parameters *sp;
struct ksmbd_conn *conn;
- t = kzalloc(sizeof(*t), KSMBD_DEFAULT_GFP);
+ t = kzalloc_obj(*t, KSMBD_DEFAULT_GFP);
if (!t)
return NULL;
sc = &t->socket;
@@ -1852,8 +1852,8 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
/* build rdma_rw_ctx for each descriptor */
desc_buf = buf;
for (i = 0; i < desc_num; i++) {
- msg = kzalloc(struct_size(msg, sg_list, SG_CHUNK_SIZE),
- KSMBD_DEFAULT_GFP);
+ msg = kzalloc_flex(*msg, sg_list, SG_CHUNK_SIZE,
+ KSMBD_DEFAULT_GFP);
if (!msg) {
ret = -ENOMEM;
goto out;
@@ -2860,7 +2860,7 @@ static int smb_direct_ib_client_add(struct ib_device *ib_dev)
if (!rdma_frwr_is_supported(&ib_dev->attrs))
return 0;
- smb_dev = kzalloc(sizeof(*smb_dev), KSMBD_DEFAULT_GFP);
+ smb_dev = kzalloc_obj(*smb_dev, KSMBD_DEFAULT_GFP);
if (!smb_dev)
return -ENOMEM;
smb_dev->ib_dev = ib_dev;
diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c
index 2436dabada95..7e29b06820e2 100644
--- a/fs/smb/server/transport_tcp.c
+++ b/fs/smb/server/transport_tcp.c
@@ -61,7 +61,7 @@ static struct tcp_transport *alloc_transport(struct socket *client_sk)
struct tcp_transport *t;
struct ksmbd_conn *conn;
- t = kzalloc(sizeof(*t), KSMBD_DEFAULT_GFP);
+ t = kzalloc_obj(*t, KSMBD_DEFAULT_GFP);
if (!t)
return NULL;
t->sock = client_sk;
@@ -156,7 +156,7 @@ static struct kvec *get_conn_iovec(struct tcp_transport *t, unsigned int nr_segs
return t->iov;
/* not big enough -- allocate a new one and release the old */
- new_iov = kmalloc_array(nr_segs, sizeof(*new_iov), KSMBD_DEFAULT_GFP);
+ new_iov = kmalloc_objs(*new_iov, nr_segs, KSMBD_DEFAULT_GFP);
if (new_iov) {
kfree(t->iov);
t->iov = new_iov;
@@ -636,7 +636,7 @@ static struct interface *alloc_iface(char *ifname)
if (!ifname)
return NULL;
- iface = kzalloc(sizeof(struct interface), KSMBD_DEFAULT_GFP);
+ iface = kzalloc_obj(struct interface, KSMBD_DEFAULT_GFP);
if (!iface) {
kfree(ifname);
return NULL;
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index e302e403e55a..ff4ea412d900 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -303,7 +303,7 @@ static struct ksmbd_inode *ksmbd_inode_get(struct ksmbd_file *fp)
if (ci)
return ci;
- ci = kmalloc(sizeof(struct ksmbd_inode), KSMBD_DEFAULT_GFP);
+ ci = kmalloc_obj(struct ksmbd_inode, KSMBD_DEFAULT_GFP);
if (!ci)
return NULL;
@@ -1126,7 +1126,7 @@ int ksmbd_reopen_durable_fd(struct ksmbd_work *work, struct ksmbd_file *fp)
int ksmbd_init_file_table(struct ksmbd_file_table *ft)
{
- ft->idr = kzalloc(sizeof(struct idr), KSMBD_DEFAULT_GFP);
+ ft->idr = kzalloc_obj(struct idr, KSMBD_DEFAULT_GFP);
if (!ft->idr)
return -ENOMEM;
diff --git a/fs/splice.c b/fs/splice.c
index 5fb07c01936f..cad3779fa35c 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -275,9 +275,8 @@ int splice_grow_spd(const struct pipe_inode_info *pipe, struct splice_pipe_desc
if (max_usage <= PIPE_DEF_BUFFERS)
return 0;
- spd->pages = kmalloc_array(max_usage, sizeof(struct page *), GFP_KERNEL);
- spd->partial = kmalloc_array(max_usage, sizeof(struct partial_page),
- GFP_KERNEL);
+ spd->pages = kmalloc_objs(struct page *, max_usage, GFP_KERNEL);
+ spd->partial = kmalloc_objs(struct partial_page, max_usage, GFP_KERNEL);
if (spd->pages && spd->partial)
return 0;
@@ -676,7 +675,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
if (!out->f_op->write_iter)
return -EINVAL;
- array = kcalloc(nbufs, sizeof(struct bio_vec), GFP_KERNEL);
+ array = kzalloc_objs(struct bio_vec, nbufs, GFP_KERNEL);
if (unlikely(!array))
return -ENOMEM;
@@ -697,8 +696,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
if (unlikely(nbufs < pipe->max_usage)) {
kfree(array);
nbufs = pipe->max_usage;
- array = kcalloc(nbufs, sizeof(struct bio_vec),
- GFP_KERNEL);
+ array = kzalloc_objs(struct bio_vec, nbufs, GFP_KERNEL);
if (!array) {
ret = -ENOMEM;
break;
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index a05e3793f93a..2d5850168026 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -88,8 +88,8 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
int idx = 0;
int err = 0;
#ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
- struct folio **cache_folios = kmalloc_array(page_count,
- sizeof(*cache_folios), GFP_KERNEL | __GFP_ZERO);
+ struct folio **cache_folios = kmalloc_objs(*cache_folios, page_count,
+ GFP_KERNEL | __GFP_ZERO);
#endif
bio_for_each_folio_all(fi, fullbio) {
diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
index 181260e72680..5d97b22ce297 100644
--- a/fs/squashfs/cache.c
+++ b/fs/squashfs/cache.c
@@ -229,13 +229,13 @@ struct squashfs_cache *squashfs_cache_init(char *name, int entries,
if (entries == 0)
return NULL;
- cache = kzalloc(sizeof(*cache), GFP_KERNEL);
+ cache = kzalloc_obj(*cache, GFP_KERNEL);
if (cache == NULL) {
ERROR("Failed to allocate %s cache\n", name);
return ERR_PTR(-ENOMEM);
}
- cache->entry = kcalloc(entries, sizeof(*(cache->entry)), GFP_KERNEL);
+ cache->entry = kzalloc_objs(*(cache->entry), entries, GFP_KERNEL);
if (cache->entry == NULL) {
ERROR("Failed to allocate %s cache\n", name);
goto cleanup;
diff --git a/fs/squashfs/decompressor_multi.c b/fs/squashfs/decompressor_multi.c
index 416c53eedbd1..4d7bc620bef5 100644
--- a/fs/squashfs/decompressor_multi.c
+++ b/fs/squashfs/decompressor_multi.c
@@ -65,7 +65,7 @@ static void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
struct decomp_stream *decomp_strm = NULL;
int err = -ENOMEM;
- stream = kzalloc(sizeof(*stream), GFP_KERNEL);
+ stream = kzalloc_obj(*stream, GFP_KERNEL);
if (!stream)
goto out;
@@ -80,7 +80,7 @@ static void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
* we could always fall back to default decompressor and
* file system works.
*/
- decomp_strm = kmalloc(sizeof(*decomp_strm), GFP_KERNEL);
+ decomp_strm = kmalloc_obj(*decomp_strm, GFP_KERNEL);
if (!decomp_strm)
goto out;
@@ -148,7 +148,7 @@ static struct decomp_stream *get_decomp_stream(struct squashfs_sb_info *msblk,
goto wait;
/* Let's allocate new decomp */
- decomp_strm = kmalloc(sizeof(*decomp_strm), GFP_KERNEL);
+ decomp_strm = kmalloc_obj(*decomp_strm, GFP_KERNEL);
if (!decomp_strm)
goto wait;
diff --git a/fs/squashfs/decompressor_single.c b/fs/squashfs/decompressor_single.c
index 6f161887710b..1f1597104ca8 100644
--- a/fs/squashfs/decompressor_single.c
+++ b/fs/squashfs/decompressor_single.c
@@ -30,7 +30,7 @@ static void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
struct squashfs_stream *stream;
int err = -ENOMEM;
- stream = kmalloc(sizeof(*stream), GFP_KERNEL);
+ stream = kmalloc_obj(*stream, GFP_KERNEL);
if (stream == NULL)
goto out;
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 4be92206e755..8b45020b4a13 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -103,8 +103,9 @@ static struct meta_index *empty_meta_index(struct inode *inode, int offset,
* mount time but doing it here means it is allocated only
* if a 'large' file is read.
*/
- msblk->meta_index = kcalloc(SQUASHFS_META_SLOTS,
- sizeof(*(msblk->meta_index)), GFP_KERNEL);
+ msblk->meta_index = kzalloc_objs(*(msblk->meta_index),
+ SQUASHFS_META_SLOTS,
+ GFP_KERNEL);
if (msblk->meta_index == NULL) {
ERROR("Failed to allocate meta_index\n");
goto failed;
diff --git a/fs/squashfs/lz4_wrapper.c b/fs/squashfs/lz4_wrapper.c
index 49797729f143..e482757d8f2c 100644
--- a/fs/squashfs/lz4_wrapper.c
+++ b/fs/squashfs/lz4_wrapper.c
@@ -54,7 +54,7 @@ static void *lz4_init(struct squashfs_sb_info *msblk, void *buff)
int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
struct squashfs_lz4 *stream;
- stream = kzalloc(sizeof(*stream), GFP_KERNEL);
+ stream = kzalloc_obj(*stream, GFP_KERNEL);
if (stream == NULL)
goto failed;
stream->input = vmalloc(block_size);
diff --git a/fs/squashfs/lzo_wrapper.c b/fs/squashfs/lzo_wrapper.c
index d216aeefa865..961fda720c14 100644
--- a/fs/squashfs/lzo_wrapper.c
+++ b/fs/squashfs/lzo_wrapper.c
@@ -29,7 +29,7 @@ static void *lzo_init(struct squashfs_sb_info *msblk, void *buff)
{
int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
- struct squashfs_lzo *stream = kzalloc(sizeof(*stream), GFP_KERNEL);
+ struct squashfs_lzo *stream = kzalloc_obj(*stream, GFP_KERNEL);
if (stream == NULL)
goto failed;
stream->input = vmalloc(block_size);
diff --git a/fs/squashfs/page_actor.c b/fs/squashfs/page_actor.c
index 2b3e807d4dea..3d8f0225e240 100644
--- a/fs/squashfs/page_actor.c
+++ b/fs/squashfs/page_actor.c
@@ -43,7 +43,7 @@ static void cache_finish_page(struct squashfs_page_actor *actor)
struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
int pages, int length)
{
- struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL);
+ struct squashfs_page_actor *actor = kmalloc_obj(*actor, GFP_KERNEL);
if (actor == NULL)
return NULL;
@@ -110,7 +110,7 @@ static void direct_finish_page(struct squashfs_page_actor *actor)
struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_info *msblk,
struct page **page, int pages, int length, loff_t start_index)
{
- struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL);
+ struct squashfs_page_actor *actor = kmalloc_obj(*actor, GFP_KERNEL);
if (actor == NULL)
return NULL;
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 4465cf05603a..69217e752bc5 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -196,7 +196,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
return -EINVAL;
}
- sb->s_fs_info = kzalloc(sizeof(*msblk), GFP_KERNEL);
+ sb->s_fs_info = kzalloc_obj(*msblk, GFP_KERNEL);
if (sb->s_fs_info == NULL) {
ERROR("Failed to allocate squashfs_sb_info\n");
return -ENOMEM;
@@ -549,7 +549,7 @@ static int squashfs_init_fs_context(struct fs_context *fc)
{
struct squashfs_mount_opts *opts;
- opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kzalloc_obj(*opts, GFP_KERNEL);
if (!opts)
return -ENOMEM;
diff --git a/fs/squashfs/xz_wrapper.c b/fs/squashfs/xz_wrapper.c
index 6c49481a2f8c..d258f4726d2e 100644
--- a/fs/squashfs/xz_wrapper.c
+++ b/fs/squashfs/xz_wrapper.c
@@ -42,7 +42,7 @@ static void *squashfs_xz_comp_opts(struct squashfs_sb_info *msblk,
struct comp_opts *opts;
int err = 0, n;
- opts = kmalloc(sizeof(*opts), GFP_KERNEL);
+ opts = kmalloc_obj(*opts, GFP_KERNEL);
if (opts == NULL) {
err = -ENOMEM;
goto out2;
@@ -84,7 +84,7 @@ static void *squashfs_xz_init(struct squashfs_sb_info *msblk, void *buff)
struct squashfs_xz *stream;
int err;
- stream = kmalloc(sizeof(*stream), GFP_KERNEL);
+ stream = kmalloc_obj(*stream, GFP_KERNEL);
if (stream == NULL) {
err = -ENOMEM;
goto failed;
diff --git a/fs/squashfs/zlib_wrapper.c b/fs/squashfs/zlib_wrapper.c
index cbb7afe7bc46..899629c54d97 100644
--- a/fs/squashfs/zlib_wrapper.c
+++ b/fs/squashfs/zlib_wrapper.c
@@ -23,7 +23,7 @@
static void *zlib_init(struct squashfs_sb_info *dummy, void *buff)
{
- z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL);
+ z_stream *stream = kmalloc_obj(z_stream, GFP_KERNEL);
if (stream == NULL)
goto failed;
stream->workspace = vmalloc(zlib_inflate_workspacesize());
diff --git a/fs/squashfs/zstd_wrapper.c b/fs/squashfs/zstd_wrapper.c
index 0e407c4d8b3b..632560e4d6b0 100644
--- a/fs/squashfs/zstd_wrapper.c
+++ b/fs/squashfs/zstd_wrapper.c
@@ -28,7 +28,7 @@ struct workspace {
static void *zstd_init(struct squashfs_sb_info *msblk, void *buff)
{
- struct workspace *wksp = kmalloc(sizeof(*wksp), GFP_KERNEL);
+ struct workspace *wksp = kmalloc_obj(*wksp, GFP_KERNEL);
if (wksp == NULL)
goto failed;
diff --git a/fs/super.c b/fs/super.c
index 784b5297a7d7..b8a6e156359d 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -317,7 +317,7 @@ static void destroy_unused_super(struct super_block *s)
static struct super_block *alloc_super(struct file_system_type *type, int flags,
struct user_namespace *user_ns)
{
- struct super_block *s = kzalloc(sizeof(struct super_block), GFP_KERNEL);
+ struct super_block *s = kzalloc_obj(struct super_block, GFP_KERNEL);
static const struct super_operations default_op;
int i;
@@ -1135,7 +1135,7 @@ void emergency_remount(void)
{
struct work_struct *work;
- work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ work = kmalloc_obj(*work, GFP_ATOMIC);
if (work) {
INIT_WORK(work, do_emergency_remount);
schedule_work(work);
@@ -1167,7 +1167,7 @@ void emergency_thaw_all(void)
{
struct work_struct *work;
- work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ work = kmalloc_obj(*work, GFP_ATOMIC);
if (work) {
INIT_WORK(work, do_thaw_all);
schedule_work(work);
diff --git a/fs/sync.c b/fs/sync.c
index f310a550316f..942a60cfedfb 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -135,7 +135,7 @@ void emergency_sync(void)
{
struct work_struct *work;
- work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ work = kmalloc_obj(*work, GFP_ATOMIC);
if (work) {
INIT_WORK(work, do_sync_work);
schedule_work(work);
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 98467bb76737..a6de7d945fba 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -62,7 +62,7 @@ static int sysfs_init_fs_context(struct fs_context *fc)
return -EPERM;
}
- kfc = kzalloc(sizeof(struct kernfs_fs_context), GFP_KERNEL);
+ kfc = kzalloc_obj(struct kernfs_fs_context, GFP_KERNEL);
if (!kfc)
return -ENOMEM;
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 9fcea7860ddf..f379edab7c02 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -413,7 +413,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
!capable(CAP_WAKE_ALARM))
return -EPERM;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 61cbdafa2411..81a3a7dcf6ce 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -191,8 +191,8 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,
/* Preallocate the children mode array if necessary */
if (!(dentry->d_inode->i_mode & S_IFDIR)) {
if (!ei->entry_attrs) {
- ei->entry_attrs = kcalloc(ei->nr_entries, sizeof(*ei->entry_attrs),
- GFP_NOFS);
+ ei->entry_attrs = kzalloc_objs(*ei->entry_attrs,
+ ei->nr_entries, GFP_NOFS);
if (!ei->entry_attrs) {
ret = -ENOMEM;
goto out;
@@ -439,7 +439,7 @@ static inline struct eventfs_inode *init_ei(struct eventfs_inode *ei, const char
static inline struct eventfs_inode *alloc_ei(const char *name)
{
- struct eventfs_inode *ei = kzalloc(sizeof(*ei), GFP_KERNEL);
+ struct eventfs_inode *ei = kzalloc_obj(*ei, GFP_KERNEL);
struct eventfs_inode *result;
if (!ei)
@@ -454,7 +454,7 @@ static inline struct eventfs_inode *alloc_ei(const char *name)
static inline struct eventfs_inode *alloc_root_ei(const char *name)
{
- struct eventfs_root_inode *rei = kzalloc(sizeof(*rei), GFP_KERNEL);
+ struct eventfs_root_inode *rei = kzalloc_obj(*rei, GFP_KERNEL);
struct eventfs_inode *ei;
if (!rei)
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index d9d8932a7b9c..780f38c1b52d 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -522,7 +522,7 @@ static int tracefs_init_fs_context(struct fs_context *fc)
{
struct tracefs_fs_info *fsi;
- fsi = kzalloc(sizeof(struct tracefs_fs_info), GFP_KERNEL);
+ fsi = kzalloc_obj(struct tracefs_fs_info, GFP_KERNEL);
if (!fsi)
return -ENOMEM;
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index b01f382ce8db..cb24592753b0 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -1846,7 +1846,7 @@ static struct fsck_inode *add_inode(struct ubifs_info *c,
return ERR_PTR(-EINVAL);
}
- fscki = kzalloc(sizeof(struct fsck_inode), GFP_NOFS);
+ fscki = kzalloc_obj(struct fsck_inode, GFP_NOFS);
if (!fscki)
return ERR_PTR(-ENOMEM);
@@ -3035,7 +3035,7 @@ void ubifs_assert_failed(struct ubifs_info *c, const char *expr,
*/
int ubifs_debugging_init(struct ubifs_info *c)
{
- c->dbg = kzalloc(sizeof(struct ubifs_debug_info), GFP_KERNEL);
+ c->dbg = kzalloc_obj(struct ubifs_debug_info, GFP_KERNEL);
if (!c->dbg)
return -ENOMEM;
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 3c3d3ad4fa6c..0e088aa661af 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1099,7 +1099,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino);
if (S_ISBLK(mode) || S_ISCHR(mode)) {
- dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
+ dev = kmalloc_obj(union ubifs_dev_desc, GFP_NOFS);
if (!dev)
return -ENOMEM;
devlen = ubifs_encode_dev(dev, rdev);
@@ -1399,7 +1399,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
if (flags & RENAME_WHITEOUT) {
union ubifs_dev_desc *dev = NULL;
- dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
+ dev = kmalloc_obj(union ubifs_dev_desc, GFP_NOFS);
if (!dev) {
err = -ENOMEM;
goto out_release;
@@ -1725,7 +1725,7 @@ static int ubifs_dir_open(struct inode *inode, struct file *file)
{
struct ubifs_dir_data *data;
- data = kzalloc(sizeof(struct ubifs_dir_data), GFP_KERNEL);
+ data = kzalloc_obj(struct ubifs_dir_data, GFP_KERNEL);
if (!data)
return -ENOMEM;
file->private_data = data;
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 3dc3ca1cd803..cd04755e792a 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -848,7 +848,7 @@ static int ubifs_bulk_read(struct folio *folio)
if (mutex_trylock(&c->bu_mutex))
bu = &c->bu;
else {
- bu = kmalloc(sizeof(struct bu_info), GFP_NOFS | __GFP_NOWARN);
+ bu = kmalloc_obj(struct bu_info, GFP_NOFS | __GFP_NOWARN);
if (!bu)
goto out_unlock;
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 3134d070fcc0..0bf08b7755b8 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -559,7 +559,7 @@ int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp)
goto out;
}
- idx_gc = kmalloc(sizeof(struct ubifs_gced_idx_leb), GFP_NOFS);
+ idx_gc = kmalloc_obj(struct ubifs_gced_idx_leb, GFP_NOFS);
if (!idx_gc) {
err = -ENOMEM;
goto out;
@@ -916,7 +916,7 @@ int ubifs_gc_start_commit(struct ubifs_info *c)
}
if (!lp)
break;
- idx_gc = kmalloc(sizeof(struct ubifs_gced_idx_leb), GFP_NOFS);
+ idx_gc = kmalloc_obj(struct ubifs_gced_idx_leb, GFP_NOFS);
if (!idx_gc) {
err = -ENOMEM;
goto out;
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c
index b6ac9c4281ef..c6edcbf35ebc 100644
--- a/fs/ubifs/log.c
+++ b/fs/ubifs/log.c
@@ -167,7 +167,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs)
struct ubifs_bud *bud;
struct ubifs_ref_node *ref;
- bud = kmalloc(sizeof(struct ubifs_bud), GFP_NOFS);
+ bud = kmalloc_obj(struct ubifs_bud, GFP_NOFS);
if (!bud)
return -ENOMEM;
ref = kzalloc(c->ref_node_alsz, GFP_NOFS);
@@ -574,7 +574,7 @@ static int done_already(struct rb_root *done_tree, int lnum)
return 1;
}
- dr = kzalloc(sizeof(struct done_ref), GFP_NOFS);
+ dr = kzalloc_obj(struct done_ref, GFP_NOFS);
if (!dr)
return -ENOMEM;
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index dde0aa3287f4..a9cb92e3ee9c 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -624,9 +624,9 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
if (IS_ERR(desc))
return PTR_ERR(desc);
- lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_KERNEL);
- pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
- nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
+ lsave = kmalloc_objs(int, c->lsave_cnt, GFP_KERNEL);
+ pnode = kzalloc_obj(struct ubifs_pnode, GFP_KERNEL);
+ nnode = kzalloc_obj(struct ubifs_nnode, GFP_KERNEL);
buf = vmalloc(c->leb_size);
ltab = vmalloc_array(c->lpt_lebs,
sizeof(struct ubifs_lpt_lprops));
@@ -1215,7 +1215,7 @@ int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip)
lnum = c->lpt_lnum;
offs = c->lpt_offs;
}
- nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_NOFS);
+ nnode = kzalloc_obj(struct ubifs_nnode, GFP_NOFS);
if (!nnode) {
err = -ENOMEM;
goto out;
@@ -1278,7 +1278,7 @@ static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip)
branch = &parent->nbranch[iip];
lnum = branch->lnum;
offs = branch->offs;
- pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_NOFS);
+ pnode = kzalloc_obj(struct ubifs_pnode, GFP_NOFS);
if (!pnode)
return -ENOMEM;
@@ -1856,7 +1856,7 @@ static int lpt_init_wr(struct ubifs_info *c)
return -ENOMEM;
if (c->big_lpt) {
- c->lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_NOFS);
+ c->lsave = kmalloc_objs(int, c->lsave_cnt, GFP_NOFS);
if (!c->lsave)
return -ENOMEM;
err = read_lsave(c);
@@ -2099,8 +2099,7 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum,
return err;
}
- path = kmalloc_array(c->lpt_hght + 1, sizeof(struct lpt_scan_node),
- GFP_NOFS);
+ path = kmalloc_objs(struct lpt_scan_node, c->lpt_hght + 1, GFP_NOFS);
if (!path)
return -ENOMEM;
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index 5555dd740889..85e467646e4a 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -55,7 +55,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
struct ubifs_orphan *orphan, *o;
struct rb_node **p, *parent = NULL;
- orphan = kzalloc(sizeof(struct ubifs_orphan), GFP_NOFS);
+ orphan = kzalloc_obj(struct ubifs_orphan, GFP_NOFS);
if (!orphan)
return -ENOMEM;
orphan->inum = inum;
@@ -758,7 +758,7 @@ static int dbg_ins_check_orphan(struct rb_root *root, ino_t inum)
struct check_orphan *orphan, *o;
struct rb_node **p, *parent = NULL;
- orphan = kzalloc(sizeof(struct check_orphan), GFP_NOFS);
+ orphan = kzalloc_obj(struct check_orphan, GFP_NOFS);
if (!orphan)
return -ENOMEM;
orphan->inum = inum;
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index b36dc9b032f4..d92aed9fbad7 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -508,7 +508,7 @@ static int fix_unclean_leb(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
dbg_rcvry("need to fix LEB %d start %d endpt %d",
lnum, start, sleb->endpt);
- ucleb = kzalloc(sizeof(struct ubifs_unclean_leb), GFP_NOFS);
+ ucleb = kzalloc_obj(struct ubifs_unclean_leb, GFP_NOFS);
if (!ucleb)
return -ENOMEM;
ucleb->lnum = lnum;
@@ -1258,7 +1258,7 @@ static int add_ino(struct ubifs_info *c, ino_t inum, loff_t i_size,
p = &(*p)->rb_right;
}
- e = kzalloc(sizeof(struct size_entry), GFP_KERNEL);
+ e = kzalloc_obj(struct size_entry, GFP_KERNEL);
if (!e)
return -ENOMEM;
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index a950c5f2560e..7e5435dab283 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -393,7 +393,7 @@ static int insert_node(struct ubifs_info *c, int lnum, int offs, int len,
if (key_inum(c, key) >= c->highest_inum)
c->highest_inum = key_inum(c, key);
- r = kzalloc(sizeof(struct replay_entry), GFP_KERNEL);
+ r = kzalloc_obj(struct replay_entry, GFP_KERNEL);
if (!r)
return -ENOMEM;
@@ -443,7 +443,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
if (key_inum(c, key) >= c->highest_inum)
c->highest_inum = key_inum(c, key);
- r = kzalloc(sizeof(struct replay_entry), GFP_KERNEL);
+ r = kzalloc_obj(struct replay_entry, GFP_KERNEL);
if (!r)
return -ENOMEM;
@@ -897,11 +897,11 @@ static int add_replay_bud(struct ubifs_info *c, int lnum, int offs, int jhead,
dbg_mnt("add replay bud LEB %d:%d, head %d", lnum, offs, jhead);
- bud = kmalloc(sizeof(struct ubifs_bud), GFP_KERNEL);
+ bud = kmalloc_obj(struct ubifs_bud, GFP_KERNEL);
if (!bud)
return -ENOMEM;
- b = kmalloc(sizeof(struct bud_entry), GFP_KERNEL);
+ b = kmalloc_obj(struct bud_entry, GFP_KERNEL);
if (!b) {
err = -ENOMEM;
goto out;
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c
index 84a9157dcc32..cbff2d800e27 100644
--- a/fs/ubifs/scan.c
+++ b/fs/ubifs/scan.c
@@ -130,7 +130,7 @@ struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum,
dbg_scan("scan LEB %d:%d", lnum, offs);
- sleb = kzalloc(sizeof(struct ubifs_scan_leb), GFP_NOFS);
+ sleb = kzalloc_obj(struct ubifs_scan_leb, GFP_NOFS);
if (!sleb)
return ERR_PTR(-ENOMEM);
@@ -185,7 +185,7 @@ int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
struct ubifs_ino_node *ino = buf;
struct ubifs_scan_node *snod;
- snod = kmalloc(sizeof(struct ubifs_scan_node), GFP_NOFS);
+ snod = kmalloc_obj(struct ubifs_scan_node, GFP_NOFS);
if (!snod)
return -ENOMEM;
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index f453c37cee37..b86b65fcd615 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -208,7 +208,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
dev_t rdev;
union ubifs_dev_desc *dev;
- ui->data = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
+ ui->data = kmalloc_obj(union ubifs_dev_desc, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_ino;
@@ -819,8 +819,7 @@ static int alloc_wbufs(struct ubifs_info *c)
{
int i, err;
- c->jheads = kcalloc(c->jhead_cnt, sizeof(struct ubifs_jhead),
- GFP_KERNEL);
+ c->jheads = kzalloc_objs(struct ubifs_jhead, c->jhead_cnt, GFP_KERNEL);
if (!c->jheads)
return -ENOMEM;
@@ -1246,8 +1245,7 @@ static int mount_ubifs(struct ubifs_info *c)
* never exceed 64.
*/
err = -ENOMEM;
- c->bottom_up_buf = kmalloc_array(BOTTOM_UP_HEIGHT, sizeof(int),
- GFP_KERNEL);
+ c->bottom_up_buf = kmalloc_objs(int, BOTTOM_UP_HEIGHT, GFP_KERNEL);
if (!c->bottom_up_buf)
goto out_free;
@@ -2083,7 +2081,7 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi)
{
struct ubifs_info *c;
- c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL);
+ c = kzalloc_obj(struct ubifs_info, GFP_KERNEL);
if (c) {
spin_lock_init(&c->cnt_lock);
spin_lock_init(&c->cs_lock);
@@ -2336,7 +2334,7 @@ static int ubifs_init_fs_context(struct fs_context *fc)
{
struct ubifs_fs_context *ctx;
- ctx = kzalloc(sizeof(struct ubifs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct ubifs_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/ubifs/sysfs.c b/fs/ubifs/sysfs.c
index aae32222f11b..1c926e865be3 100644
--- a/fs/ubifs/sysfs.c
+++ b/fs/ubifs/sysfs.c
@@ -93,7 +93,7 @@ int ubifs_sysfs_register(struct ubifs_info *c)
int ret, n;
char dfs_dir_name[UBIFS_DFS_DIR_LEN];
- c->stats = kzalloc(sizeof(struct ubifs_stats_info), GFP_KERNEL);
+ c->stats = kzalloc_obj(struct ubifs_stats_info, GFP_KERNEL);
if (!c->stats) {
ret = -ENOMEM;
goto out_last;
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 33946b518148..694b08d27d7d 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -99,7 +99,7 @@ static int insert_old_idx(struct ubifs_info *c, int lnum, int offs)
{
struct ubifs_old_idx *old_idx;
- old_idx = kmalloc(sizeof(struct ubifs_old_idx), GFP_NOFS);
+ old_idx = kmalloc_obj(struct ubifs_old_idx, GFP_NOFS);
if (unlikely(!old_idx))
return -ENOMEM;
old_idx->lnum = lnum;
@@ -294,7 +294,7 @@ static struct ubifs_znode *dirty_cow_znode(struct ubifs_info *c,
if (zbr->len) {
struct ubifs_old_idx *old_idx;
- old_idx = kmalloc(sizeof(struct ubifs_old_idx), GFP_NOFS);
+ old_idx = kmalloc_obj(struct ubifs_old_idx, GFP_NOFS);
if (unlikely(!old_idx)) {
err = -ENOMEM;
goto out;
@@ -1134,9 +1134,8 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c,
ubifs_assert(c, znode);
if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) {
kfree(c->bottom_up_buf);
- c->bottom_up_buf = kmalloc_array(c->zroot.znode->level,
- sizeof(int),
- GFP_NOFS);
+ c->bottom_up_buf = kmalloc_objs(int, c->zroot.znode->level,
+ GFP_NOFS);
if (!c->bottom_up_buf)
return ERR_PTR(-ENOMEM);
path = c->bottom_up_buf;
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index 7c43e0ccf6d4..7bf2672062a2 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -359,8 +359,7 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
dbg_gc("%d znodes to write", cnt);
- c->gap_lebs = kmalloc_array(c->lst.idx_lebs + 1, sizeof(int),
- GFP_NOFS);
+ c->gap_lebs = kmalloc_objs(int, c->lst.idx_lebs + 1, GFP_NOFS);
if (!c->gap_lebs)
return -ENOMEM;
@@ -692,7 +691,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt)
dbg_cmt("need about %d empty LEBS for TNC commit", leb_cnt);
if (!leb_cnt)
return 0;
- c->ilebs = kmalloc_array(leb_cnt, sizeof(int), GFP_NOFS);
+ c->ilebs = kmalloc_objs(int, leb_cnt, GFP_NOFS);
if (!c->ilebs)
return -ENOMEM;
for (i = 0; i < leb_cnt; i++) {
diff --git a/fs/udf/super.c b/fs/udf/super.c
index b2f168b0a0d1..365cb78097d3 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -270,7 +270,7 @@ static int udf_init_fs_context(struct fs_context *fc)
{
struct udf_options *uopt;
- uopt = kzalloc(sizeof(*uopt), GFP_KERNEL);
+ uopt = kzalloc_obj(*uopt, GFP_KERNEL);
if (!uopt)
return -ENOMEM;
@@ -320,7 +320,7 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
{
struct udf_sb_info *sbi = UDF_SB(sb);
- sbi->s_partmaps = kcalloc(count, sizeof(*sbi->s_partmaps), GFP_KERNEL);
+ sbi->s_partmaps = kzalloc_objs(*sbi->s_partmaps, count, GFP_KERNEL);
if (!sbi->s_partmaps) {
sbi->s_partitions = 0;
return -ENOMEM;
@@ -1047,8 +1047,7 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
struct udf_bitmap *bitmap;
int nr_groups = udf_compute_nr_groups(sb, index);
- bitmap = kvzalloc(struct_size(bitmap, s_block_bitmap, nr_groups),
- GFP_KERNEL);
+ bitmap = kvzalloc_flex(*bitmap, s_block_bitmap, nr_groups, GFP_KERNEL);
if (!bitmap)
return NULL;
@@ -1697,7 +1696,7 @@ static struct udf_vds_record *handle_partition_descriptor(
struct part_desc_seq_scan_data *new_loc;
unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP);
- new_loc = kcalloc(new_size, sizeof(*new_loc), GFP_KERNEL);
+ new_loc = kzalloc_objs(*new_loc, new_size, GFP_KERNEL);
if (!new_loc)
return ERR_PTR(-ENOMEM);
memcpy(new_loc, data->part_descs_loc,
@@ -1757,9 +1756,8 @@ static noinline int udf_process_sequence(
memset(data.vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
data.size_part_descs = PART_DESC_ALLOC_STEP;
data.num_part_descs = 0;
- data.part_descs_loc = kcalloc(data.size_part_descs,
- sizeof(*data.part_descs_loc),
- GFP_KERNEL);
+ data.part_descs_loc = kzalloc_objs(*data.part_descs_loc,
+ data.size_part_descs, GFP_KERNEL);
if (!data.part_descs_loc)
return -ENOMEM;
@@ -2158,7 +2156,7 @@ static int udf_fill_super(struct super_block *sb, struct fs_context *fc)
bool lvid_open = false;
int silent = fc->sb_flags & SB_SILENT;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 6e4585169f94..2937221f7942 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -483,8 +483,7 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
* Read cylinder group (we read only first fragment from block
* at this time) and prepare internal data structures for cg caching.
*/
- sbi->s_ucg = kmalloc_array(uspi->s_ncg, sizeof(struct buffer_head *),
- GFP_NOFS);
+ sbi->s_ucg = kmalloc_objs(struct buffer_head *, uspi->s_ncg, GFP_NOFS);
if (!sbi->s_ucg)
goto failed;
for (i = 0; i < uspi->s_ncg; i++)
@@ -503,7 +502,7 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data);
}
for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) {
- if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_NOFS)))
+ if (!(sbi->s_ucpi[i] = kmalloc_obj(struct ufs_cg_private_info, GFP_NOFS)))
goto failed;
sbi->s_cgno[i] = UFS_CGNO_EMPTY;
}
@@ -744,7 +743,7 @@ static int ufs_fill_super(struct super_block *sb, struct fs_context *fc)
}
#endif
- sbi = kzalloc(sizeof(struct ufs_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct ufs_sb_info, GFP_KERNEL);
if (!sbi)
goto failed_nomem;
sb->s_fs_info = sbi;
@@ -769,7 +768,7 @@ static int ufs_fill_super(struct super_block *sb, struct fs_context *fc)
sbi->s_flavour = UFS_MOUNT_UFSTYPE_OLD;
}
- uspi = kzalloc(sizeof(struct ufs_sb_private_info), GFP_KERNEL);
+ uspi = kzalloc_obj(struct ufs_sb_private_info, GFP_KERNEL);
sbi->s_uspi = uspi;
if (!uspi)
goto failed;
@@ -1438,7 +1437,7 @@ static int ufs_init_fs_context(struct fs_context *fc)
{
struct ufs_fs_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/ufs/util.c b/fs/ufs/util.c
index f0e906ab4ddd..034b1d82c355 100644
--- a/fs/ufs/util.c
+++ b/fs/ufs/util.c
@@ -27,7 +27,7 @@ struct ufs_buffer_head * _ubh_bread_ (struct ufs_sb_private_info * uspi,
count = size >> uspi->s_fshift;
if (count > UFS_MAXFRAG)
return NULL;
- ubh = kmalloc (sizeof (struct ufs_buffer_head), GFP_NOFS);
+ ubh = kmalloc_obj(struct ufs_buffer_head, GFP_NOFS);
if (!ubh)
return NULL;
ubh->fragment = fragment;
diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c
index 6fc9ab8667e6..3755b8067ad3 100644
--- a/fs/unicode/utf8-core.c
+++ b/fs/unicode/utf8-core.c
@@ -176,7 +176,7 @@ struct unicode_map *utf8_load(unsigned int version)
{
struct unicode_map *um;
- um = kzalloc(sizeof(struct unicode_map), GFP_KERNEL);
+ um = kzalloc_obj(struct unicode_map, GFP_KERNEL);
if (!um)
return ERR_PTR(-ENOMEM);
um->version = version;
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index c5ba1f4487bd..e90c4a762917 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -653,7 +653,7 @@ int dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
}
if (!ctx) {
- fctx = kmalloc(sizeof(*fctx), GFP_KERNEL);
+ fctx = kmalloc_obj(*fctx, GFP_KERNEL);
if (!fctx)
return -ENOMEM;
@@ -840,7 +840,7 @@ int userfaultfd_unmap_prep(struct vm_area_struct *vma, unsigned long start,
has_unmap_ctx(ctx, unmaps, start, end))
return 0;
- unmap_ctx = kzalloc(sizeof(*unmap_ctx), GFP_KERNEL);
+ unmap_ctx = kzalloc_obj(*unmap_ctx, GFP_KERNEL);
if (!unmap_ctx)
return -ENOMEM;
diff --git a/fs/vboxsf/file.c b/fs/vboxsf/file.c
index 111752010edb..174ede512d30 100644
--- a/fs/vboxsf/file.c
+++ b/fs/vboxsf/file.c
@@ -26,7 +26,7 @@ struct vboxsf_handle *vboxsf_create_sf_handle(struct inode *inode,
struct vboxsf_inode *sf_i = VBOXSF_I(inode);
struct vboxsf_handle *sf_handle;
- sf_handle = kmalloc(sizeof(*sf_handle), GFP_KERNEL);
+ sf_handle = kmalloc_obj(*sf_handle, GFP_KERNEL);
if (!sf_handle)
return ERR_PTR(-ENOMEM);
diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c
index 241647b060ee..fe048ab05c48 100644
--- a/fs/vboxsf/super.c
+++ b/fs/vboxsf/super.c
@@ -122,7 +122,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc)
if (!fc->source)
return -EINVAL;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
@@ -427,7 +427,7 @@ static int vboxsf_init_fs_context(struct fs_context *fc)
{
struct vboxsf_fs_context *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
index 9515bbf0b54c..b95c1e42d073 100644
--- a/fs/vboxsf/utils.c
+++ b/fs/vboxsf/utils.c
@@ -478,7 +478,7 @@ static struct vboxsf_dir_buf *vboxsf_dir_buf_alloc(struct list_head *list)
{
struct vboxsf_dir_buf *b;
- b = kmalloc(sizeof(*b), GFP_KERNEL);
+ b = kmalloc_obj(*b, GFP_KERNEL);
if (!b)
return NULL;
@@ -507,7 +507,7 @@ struct vboxsf_dir_info *vboxsf_dir_info_alloc(void)
{
struct vboxsf_dir_info *p;
- p = kmalloc(sizeof(*p), GFP_KERNEL);
+ p = kmalloc_obj(*p, GFP_KERNEL);
if (!p)
return NULL;
diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
index 586918ed1cbf..759da639d386 100644
--- a/fs/xfs/libxfs/xfs_ag.c
+++ b/fs/xfs/libxfs/xfs_ag.c
@@ -224,7 +224,7 @@ xfs_perag_alloc(
struct xfs_perag *pag;
int error;
- pag = kzalloc(sizeof(*pag), GFP_KERNEL);
+ pag = kzalloc_obj(*pag, GFP_KERNEL);
if (!pag)
return -ENOMEM;
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index c39e40dcb0b0..472c261163ed 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -982,7 +982,7 @@ xfs_defer_ops_capture(
return ERR_PTR(error);
/* Create an object to capture the defer ops. */
- dfc = kzalloc(sizeof(*dfc), GFP_KERNEL | __GFP_NOFAIL);
+ dfc = kzalloc_obj(*dfc, GFP_KERNEL | __GFP_NOFAIL);
INIT_LIST_HEAD(&dfc->dfc_list);
INIT_LIST_HEAD(&dfc->dfc_dfops);
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 107c1a5b8a96..495620cc001f 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -116,10 +116,10 @@ xfs_da_mount(
ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
ASSERT(xfs_dir2_dirblock_bytes(&mp->m_sb) <= XFS_MAX_BLOCKSIZE);
- mp->m_dir_geo = kzalloc(sizeof(struct xfs_da_geometry),
- GFP_KERNEL | __GFP_RETRY_MAYFAIL);
- mp->m_attr_geo = kzalloc(sizeof(struct xfs_da_geometry),
- GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ mp->m_dir_geo = kzalloc_obj(struct xfs_da_geometry,
+ GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ mp->m_attr_geo = kzalloc_obj(struct xfs_da_geometry,
+ GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!mp->m_dir_geo || !mp->m_attr_geo) {
kfree(mp->m_dir_geo);
kfree(mp->m_attr_geo);
@@ -248,7 +248,7 @@ xfs_dir_init(
if (error)
return error;
- args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
+ args = kzalloc_obj(*args, GFP_KERNEL | __GFP_NOFAIL);
if (!args)
return -ENOMEM;
@@ -341,7 +341,7 @@ xfs_dir_createname(
XFS_STATS_INC(dp->i_mount, xs_dir_create);
}
- args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
+ args = kzalloc_obj(*args, GFP_KERNEL | __GFP_NOFAIL);
if (!args)
return -ENOMEM;
@@ -437,8 +437,7 @@ xfs_dir_lookup(
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_lookup);
- args = kzalloc(sizeof(*args),
- GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
+ args = kzalloc_obj(*args, GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
args->geo = dp->i_mount->m_dir_geo;
args->name = name->name;
args->namelen = name->len;
@@ -503,7 +502,7 @@ xfs_dir_removename(
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_remove);
- args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
+ args = kzalloc_obj(*args, GFP_KERNEL | __GFP_NOFAIL);
if (!args)
return -ENOMEM;
@@ -563,7 +562,7 @@ xfs_dir_replace(
if (rval)
return rval;
- args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
+ args = kzalloc_obj(*args, GFP_KERNEL | __GFP_NOFAIL);
if (!args)
return -ENOMEM;
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 915ec85530e7..40c7f0ff6cf3 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -2033,8 +2033,8 @@ xfs_refcount_recover_extent(
return -EFSCORRUPTED;
}
- rr = kmalloc(sizeof(struct xfs_refcount_recovery),
- GFP_KERNEL | __GFP_NOFAIL);
+ rr = kmalloc_obj(struct xfs_refcount_recovery,
+ GFP_KERNEL | __GFP_NOFAIL);
INIT_LIST_HEAD(&rr->rr_list);
xfs_refcount_btrec_to_irec(rec, &rr->rr_rrec);
diff --git a/fs/xfs/libxfs/xfs_rtgroup.c b/fs/xfs/libxfs/xfs_rtgroup.c
index 09328f2d1575..3b7f4819b85b 100644
--- a/fs/xfs/libxfs/xfs_rtgroup.c
+++ b/fs/xfs/libxfs/xfs_rtgroup.c
@@ -98,7 +98,7 @@ xfs_rtgroup_alloc(
struct xfs_rtgroup *rtg;
int error;
- rtg = kzalloc(sizeof(struct xfs_rtgroup), GFP_KERNEL);
+ rtg = kzalloc_obj(struct xfs_rtgroup, GFP_KERNEL);
if (!rtg)
return -ENOMEM;
diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
index 7ffe4b0ef0f1..9ed053b5f061 100644
--- a/fs/xfs/scrub/agheader.c
+++ b/fs/xfs/scrub/agheader.c
@@ -816,8 +816,8 @@ xchk_agfl(
xchk_block_set_corrupt(sc, sc->sa.agf_bp);
goto out;
}
- sai.entries = kvcalloc(sai.agflcount, sizeof(xfs_agblock_t),
- XCHK_GFP_FLAGS);
+ sai.entries = kvzalloc_objs(xfs_agblock_t, sai.agflcount,
+ XCHK_GFP_FLAGS);
if (!sai.entries) {
error = -ENOMEM;
goto out;
diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
index 15d58eedb387..ae9ed5f280d0 100644
--- a/fs/xfs/scrub/agheader_repair.c
+++ b/fs/xfs/scrub/agheader_repair.c
@@ -1719,7 +1719,7 @@ xrep_agi(
if (!xfs_has_rmapbt(mp))
return -EOPNOTSUPP;
- sc->buf = kzalloc(sizeof(struct xrep_agi), XCHK_GFP_FLAGS);
+ sc->buf = kzalloc_obj(struct xrep_agi, XCHK_GFP_FLAGS);
if (!sc->buf)
return -ENOMEM;
ragi = sc->buf;
diff --git a/fs/xfs/scrub/alloc_repair.c b/fs/xfs/scrub/alloc_repair.c
index 5b4c2a39a155..dce6ab0429dc 100644
--- a/fs/xfs/scrub/alloc_repair.c
+++ b/fs/xfs/scrub/alloc_repair.c
@@ -856,7 +856,7 @@ xrep_allocbt(
if (!xfs_has_rmapbt(mp))
return -EOPNOTSUPP;
- ra = kzalloc(sizeof(struct xrep_abt), XCHK_GFP_FLAGS);
+ ra = kzalloc_obj(struct xrep_abt, XCHK_GFP_FLAGS);
if (!ra)
return -ENOMEM;
ra->sc = sc;
diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
index c3c122ea2d32..390ac2e11ee0 100644
--- a/fs/xfs/scrub/attr.c
+++ b/fs/xfs/scrub/attr.c
@@ -85,7 +85,7 @@ xchk_setup_xattr_buf(
if (ab)
goto resize_value;
- ab = kvzalloc(sizeof(struct xchk_xattr_buf), XCHK_GFP_FLAGS);
+ ab = kvzalloc_obj(struct xchk_xattr_buf, XCHK_GFP_FLAGS);
if (!ab)
return -ENOMEM;
sc->buf = ab;
diff --git a/fs/xfs/scrub/attr_repair.c b/fs/xfs/scrub/attr_repair.c
index a924b467a844..7d00a1ce0bac 100644
--- a/fs/xfs/scrub/attr_repair.c
+++ b/fs/xfs/scrub/attr_repair.c
@@ -1534,7 +1534,7 @@ xrep_xattr_setup_scan(
int max_len;
int error;
- rx = kzalloc(sizeof(struct xrep_xattr), XCHK_GFP_FLAGS);
+ rx = kzalloc_obj(struct xrep_xattr, XCHK_GFP_FLAGS);
if (!rx)
return -ENOMEM;
rx->sc = sc;
diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
index 51f3171bc6c8..c7fa908d92b2 100644
--- a/fs/xfs/scrub/bitmap.c
+++ b/fs/xfs/scrub/bitmap.c
@@ -87,8 +87,8 @@ xbitmap64_clear(
xbitmap64_tree_insert(bn, &bitmap->xb_root);
/* add an extent */
- new_bn = kmalloc(sizeof(struct xbitmap64_node),
- XCHK_GFP_FLAGS);
+ new_bn = kmalloc_obj(struct xbitmap64_node,
+ XCHK_GFP_FLAGS);
if (!new_bn)
return -ENOMEM;
new_bn->bn_start = last + 1;
@@ -164,7 +164,7 @@ xbitmap64_set(
xbitmap64_tree_insert(right, &bitmap->xb_root);
} else {
/* add an extent */
- left = kmalloc(sizeof(struct xbitmap64_node), XCHK_GFP_FLAGS);
+ left = kmalloc_obj(struct xbitmap64_node, XCHK_GFP_FLAGS);
if (!left)
return -ENOMEM;
left->bn_start = start;
@@ -362,8 +362,8 @@ xbitmap32_clear(
xbitmap32_tree_insert(bn, &bitmap->xb_root);
/* add an extent */
- new_bn = kmalloc(sizeof(struct xbitmap32_node),
- XCHK_GFP_FLAGS);
+ new_bn = kmalloc_obj(struct xbitmap32_node,
+ XCHK_GFP_FLAGS);
if (!new_bn)
return -ENOMEM;
new_bn->bn_start = last + 1;
@@ -439,7 +439,7 @@ xbitmap32_set(
xbitmap32_tree_insert(right, &bitmap->xb_root);
} else {
/* add an extent */
- left = kmalloc(sizeof(struct xbitmap32_node), XCHK_GFP_FLAGS);
+ left = kmalloc_obj(struct xbitmap32_node, XCHK_GFP_FLAGS);
if (!left)
return -ENOMEM;
left->bn_start = start;
diff --git a/fs/xfs/scrub/bmap_repair.c b/fs/xfs/scrub/bmap_repair.c
index 0a83d5845379..822a4af43833 100644
--- a/fs/xfs/scrub/bmap_repair.c
+++ b/fs/xfs/scrub/bmap_repair.c
@@ -933,7 +933,7 @@ xrep_bmap(
if (error)
return error;
- rb = kzalloc(sizeof(struct xrep_bmap), XCHK_GFP_FLAGS);
+ rb = kzalloc_obj(struct xrep_bmap, XCHK_GFP_FLAGS);
if (!rb)
return -ENOMEM;
rb->sc = sc;
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index 1089b1f4c5df..786b1e7c4dc3 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -449,7 +449,7 @@ xchk_btree_check_owner(
if (xfs_btree_is_bno(cur->bc_ops) || xfs_btree_is_rmap(cur->bc_ops)) {
struct check_owner *co;
- co = kmalloc(sizeof(struct check_owner), XCHK_GFP_FLAGS);
+ co = kmalloc_obj(struct check_owner, XCHK_GFP_FLAGS);
if (!co)
return -ENOMEM;
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index 33749cf43520..bffc4666ce60 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -685,7 +685,7 @@ xrep_bmap_cow(
return 0;
}
- xc = kzalloc(sizeof(struct xrep_cow), XCHK_GFP_FLAGS);
+ xc = kzalloc_obj(struct xrep_cow, XCHK_GFP_FLAGS);
if (!xc)
return -ENOMEM;
diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index 5858d4d5e279..1a71d36898b1 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -512,7 +512,7 @@ xchk_da_btree(
return 0;
/* Set up initial da state. */
- ds = kzalloc(sizeof(struct xchk_da_btree), XCHK_GFP_FLAGS);
+ ds = kzalloc_obj(struct xchk_da_btree, XCHK_GFP_FLAGS);
if (!ds)
return -ENOMEM;
ds->dargs.dp = sc->ip;
diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
index 91228623d016..e09724cd3725 100644
--- a/fs/xfs/scrub/dir.c
+++ b/fs/xfs/scrub/dir.c
@@ -1095,7 +1095,7 @@ xchk_directory(
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return 0;
- sd = kvzalloc(sizeof(struct xchk_dir), XCHK_GFP_FLAGS);
+ sd = kvzalloc_obj(struct xchk_dir, XCHK_GFP_FLAGS);
if (!sd)
return -ENOMEM;
sd->sc = sc;
diff --git a/fs/xfs/scrub/dir_repair.c b/fs/xfs/scrub/dir_repair.c
index f105e49f654b..9dc55c918c78 100644
--- a/fs/xfs/scrub/dir_repair.c
+++ b/fs/xfs/scrub/dir_repair.c
@@ -198,7 +198,7 @@ xrep_setup_directory(
if (error)
return error;
- rd = kvzalloc(sizeof(struct xrep_dir), XCHK_GFP_FLAGS);
+ rd = kvzalloc_obj(struct xrep_dir, XCHK_GFP_FLAGS);
if (!rd)
return -ENOMEM;
rd->sc = sc;
diff --git a/fs/xfs/scrub/dirtree.c b/fs/xfs/scrub/dirtree.c
index e95dc74f1145..143114718d75 100644
--- a/fs/xfs/scrub/dirtree.c
+++ b/fs/xfs/scrub/dirtree.c
@@ -106,7 +106,7 @@ xchk_setup_dirtree(
return error;
}
- dl = kvzalloc(sizeof(struct xchk_dirtree), XCHK_GFP_FLAGS);
+ dl = kvzalloc_obj(struct xchk_dirtree, XCHK_GFP_FLAGS);
if (!dl)
return -ENOMEM;
dl->sc = sc;
@@ -238,7 +238,7 @@ xchk_dirtree_create_path(
* Create a new xchk_path structure to remember this parent pointer
* and record the first name step.
*/
- path = kmalloc(sizeof(struct xchk_dirpath), XCHK_GFP_FLAGS);
+ path = kmalloc_obj(struct xchk_dirpath, XCHK_GFP_FLAGS);
if (!path)
return -ENOMEM;
diff --git a/fs/xfs/scrub/dirtree_repair.c b/fs/xfs/scrub/dirtree_repair.c
index 019feaf0d606..bcfbbf5efc6c 100644
--- a/fs/xfs/scrub/dirtree_repair.c
+++ b/fs/xfs/scrub/dirtree_repair.c
@@ -567,7 +567,7 @@ xrep_dirtree_create_adoption_path(
* Create a new xchk_path structure to remember this parent pointer
* and record the first name step.
*/
- path = kmalloc(sizeof(struct xchk_dirpath), XCHK_GFP_FLAGS);
+ path = kmalloc_obj(struct xchk_dirpath, XCHK_GFP_FLAGS);
if (!path)
return -ENOMEM;
diff --git a/fs/xfs/scrub/fscounters.c b/fs/xfs/scrub/fscounters.c
index b35f65b537ba..916699f3da7b 100644
--- a/fs/xfs/scrub/fscounters.c
+++ b/fs/xfs/scrub/fscounters.c
@@ -207,7 +207,7 @@ xchk_setup_fscounters(
if (!xfs_has_lazysbcount(sc->mp))
xchk_fsgates_enable(sc, XCHK_FSGATES_DRAIN);
- sc->buf = kzalloc(sizeof(struct xchk_fscounters), XCHK_GFP_FLAGS);
+ sc->buf = kzalloc_obj(struct xchk_fscounters, XCHK_GFP_FLAGS);
if (!sc->buf)
return -ENOMEM;
sc->buf_cleanup = xchk_fscounters_cleanup;
diff --git a/fs/xfs/scrub/ialloc_repair.c b/fs/xfs/scrub/ialloc_repair.c
index 9b63b9d19e1b..608c7022ac15 100644
--- a/fs/xfs/scrub/ialloc_repair.c
+++ b/fs/xfs/scrub/ialloc_repair.c
@@ -804,7 +804,7 @@ xrep_iallocbt(
if (!xfs_has_rmapbt(mp))
return -EOPNOTSUPP;
- ri = kzalloc(sizeof(struct xrep_ibt), XCHK_GFP_FLAGS);
+ ri = kzalloc_obj(struct xrep_ibt, XCHK_GFP_FLAGS);
if (!ri)
return -ENOMEM;
ri->sc = sc;
diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c
index bf182a18f115..9738b9ce3f2d 100644
--- a/fs/xfs/scrub/inode_repair.c
+++ b/fs/xfs/scrub/inode_repair.c
@@ -151,7 +151,7 @@ xrep_setup_inode(
{
struct xrep_inode *ri;
- sc->buf = kzalloc(sizeof(struct xrep_inode), XCHK_GFP_FLAGS);
+ sc->buf = kzalloc_obj(struct xrep_inode, XCHK_GFP_FLAGS);
if (!sc->buf)
return -ENOMEM;
diff --git a/fs/xfs/scrub/metapath.c b/fs/xfs/scrub/metapath.c
index 3d9de59c1758..050b86eb12d3 100644
--- a/fs/xfs/scrub/metapath.c
+++ b/fs/xfs/scrub/metapath.c
@@ -102,7 +102,7 @@ xchk_setup_metapath_scan(
return error;
}
- mpath = kzalloc(sizeof(struct xchk_metapath), XCHK_GFP_FLAGS);
+ mpath = kzalloc_obj(struct xchk_metapath, XCHK_GFP_FLAGS);
if (!mpath) {
kfree_const(path);
return -ENOMEM;
diff --git a/fs/xfs/scrub/newbt.c b/fs/xfs/scrub/newbt.c
index 43e868f829aa..2e4981c1baf2 100644
--- a/fs/xfs/scrub/newbt.c
+++ b/fs/xfs/scrub/newbt.c
@@ -195,7 +195,7 @@ xrep_newbt_add_blocks(
struct xrep_newbt_resv *resv;
int error;
- resv = kmalloc(sizeof(struct xrep_newbt_resv), XCHK_GFP_FLAGS);
+ resv = kmalloc_obj(struct xrep_newbt_resv, XCHK_GFP_FLAGS);
if (!resv)
return -ENOMEM;
diff --git a/fs/xfs/scrub/nlinks.c b/fs/xfs/scrub/nlinks.c
index e80fe7395d78..1e0effdb65a6 100644
--- a/fs/xfs/scrub/nlinks.c
+++ b/fs/xfs/scrub/nlinks.c
@@ -58,7 +58,7 @@ xchk_setup_nlinks(
return error;
}
- xnc = kvzalloc(sizeof(struct xchk_nlink_ctrs), XCHK_GFP_FLAGS);
+ xnc = kvzalloc_obj(struct xchk_nlink_ctrs, XCHK_GFP_FLAGS);
if (!xnc)
return -ENOMEM;
xnc->xname.name = xnc->namebuf;
diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c
index 5a259570b154..931604fa1294 100644
--- a/fs/xfs/scrub/parent.c
+++ b/fs/xfs/scrub/parent.c
@@ -757,7 +757,7 @@ xchk_parent_pptr(
struct xchk_pptrs *pp;
int error;
- pp = kvzalloc(sizeof(struct xchk_pptrs), XCHK_GFP_FLAGS);
+ pp = kvzalloc_obj(struct xchk_pptrs, XCHK_GFP_FLAGS);
if (!pp)
return -ENOMEM;
pp->sc = sc;
diff --git a/fs/xfs/scrub/parent_repair.c b/fs/xfs/scrub/parent_repair.c
index 83a8205ae2f1..2ce0cefad362 100644
--- a/fs/xfs/scrub/parent_repair.c
+++ b/fs/xfs/scrub/parent_repair.c
@@ -217,7 +217,7 @@ xrep_setup_parent(
xchk_fsgates_enable(sc, XCHK_FSGATES_DIRENTS);
- rp = kvzalloc(sizeof(struct xrep_parent), XCHK_GFP_FLAGS);
+ rp = kvzalloc_obj(struct xrep_parent, XCHK_GFP_FLAGS);
if (!rp)
return -ENOMEM;
rp->sc = sc;
diff --git a/fs/xfs/scrub/quotacheck.c b/fs/xfs/scrub/quotacheck.c
index e8cba19334a0..9ea014e2ecfd 100644
--- a/fs/xfs/scrub/quotacheck.c
+++ b/fs/xfs/scrub/quotacheck.c
@@ -86,7 +86,7 @@ xchk_setup_quotacheck(
xchk_fsgates_enable(sc, XCHK_FSGATES_QUOTA);
- sc->buf = kzalloc(sizeof(struct xqcheck), XCHK_GFP_FLAGS);
+ sc->buf = kzalloc_obj(struct xqcheck, XCHK_GFP_FLAGS);
if (!sc->buf)
return -ENOMEM;
@@ -256,7 +256,7 @@ xqcheck_mod_live_ino_dqtrx(
dqa = rhashtable_lookup_fast(&xqc->shadow_dquot_acct, &p->tx_id,
xqcheck_dqacct_hash_params);
if (!dqa) {
- dqa = kzalloc(sizeof(struct xqcheck_dqacct), XCHK_GFP_FLAGS);
+ dqa = kzalloc_obj(struct xqcheck_dqacct, XCHK_GFP_FLAGS);
if (!dqa)
goto out_abort;
diff --git a/fs/xfs/scrub/rcbag.c b/fs/xfs/scrub/rcbag.c
index c1a97a073d92..8f3a10f7c908 100644
--- a/fs/xfs/scrub/rcbag.c
+++ b/fs/xfs/scrub/rcbag.c
@@ -36,7 +36,7 @@ rcbag_init(
struct rcbag *bag;
int error;
- bag = kzalloc(sizeof(struct rcbag), XCHK_GFP_FLAGS);
+ bag = kzalloc_obj(struct rcbag, XCHK_GFP_FLAGS);
if (!bag)
return -ENOMEM;
diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c
index bf87025f24fc..4e1bf23e5b89 100644
--- a/fs/xfs/scrub/refcount.c
+++ b/fs/xfs/scrub/refcount.c
@@ -142,8 +142,7 @@ xchk_refcountbt_rmap_check(
* is healthy each rmap_irec we see will be in agbno order
* so we don't need insertion sort here.
*/
- frag = kmalloc(sizeof(struct xchk_refcnt_frag),
- XCHK_GFP_FLAGS);
+ frag = kmalloc_obj(struct xchk_refcnt_frag, XCHK_GFP_FLAGS);
if (!frag)
return -ENOMEM;
memcpy(&frag->rm, rec, sizeof(frag->rm));
diff --git a/fs/xfs/scrub/refcount_repair.c b/fs/xfs/scrub/refcount_repair.c
index 507993e0fb0f..ca9c382005ff 100644
--- a/fs/xfs/scrub/refcount_repair.c
+++ b/fs/xfs/scrub/refcount_repair.c
@@ -704,7 +704,7 @@ xrep_refcountbt(
if (!xfs_has_rmapbt(mp))
return -EOPNOTSUPP;
- rr = kzalloc(sizeof(struct xrep_refc), XCHK_GFP_FLAGS);
+ rr = kzalloc_obj(struct xrep_refc, XCHK_GFP_FLAGS);
if (!rr)
return -ENOMEM;
rr->sc = sc;
diff --git a/fs/xfs/scrub/rmap.c b/fs/xfs/scrub/rmap.c
index 2c25910e2903..0cd3eecd2ca5 100644
--- a/fs/xfs/scrub/rmap.c
+++ b/fs/xfs/scrub/rmap.c
@@ -548,7 +548,7 @@ xchk_rmapbt(
struct xchk_rmap *cr;
int error;
- cr = kzalloc(sizeof(struct xchk_rmap), XCHK_GFP_FLAGS);
+ cr = kzalloc_obj(struct xchk_rmap, XCHK_GFP_FLAGS);
if (!cr)
return -ENOMEM;
diff --git a/fs/xfs/scrub/rmap_repair.c b/fs/xfs/scrub/rmap_repair.c
index ab7053e25e1c..6766df9922e8 100644
--- a/fs/xfs/scrub/rmap_repair.c
+++ b/fs/xfs/scrub/rmap_repair.c
@@ -172,7 +172,7 @@ xrep_setup_ag_rmapbt(
if (error)
return error;
- rr = kzalloc(sizeof(struct xrep_rmap), XCHK_GFP_FLAGS);
+ rr = kzalloc_obj(struct xrep_rmap, XCHK_GFP_FLAGS);
if (!rr)
return -ENOMEM;
diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c
index 4bcfd99cec17..b3a4972d423e 100644
--- a/fs/xfs/scrub/rtbitmap.c
+++ b/fs/xfs/scrub/rtbitmap.c
@@ -41,8 +41,8 @@ xchk_setup_rtbitmap(
if (xchk_need_intent_drain(sc))
xchk_fsgates_enable(sc, XCHK_FSGATES_DRAIN);
- rtb = kzalloc(struct_size(rtb, words, xchk_rtbitmap_wordcnt(sc)),
- XCHK_GFP_FLAGS);
+ rtb = kzalloc_flex(*rtb, words, xchk_rtbitmap_wordcnt(sc),
+ XCHK_GFP_FLAGS);
if (!rtb)
return -ENOMEM;
sc->buf = rtb;
diff --git a/fs/xfs/scrub/rtrefcount.c b/fs/xfs/scrub/rtrefcount.c
index 8cfe2f120b6b..4951cc271788 100644
--- a/fs/xfs/scrub/rtrefcount.c
+++ b/fs/xfs/scrub/rtrefcount.c
@@ -156,8 +156,7 @@ xchk_rtrefcountbt_rmap_check(
* is healthy each rmap_irec we see will be in agbno order
* so we don't need insertion sort here.
*/
- frag = kmalloc(sizeof(struct xchk_rtrefcnt_frag),
- XCHK_GFP_FLAGS);
+ frag = kmalloc_obj(struct xchk_rtrefcnt_frag, XCHK_GFP_FLAGS);
if (!frag)
return -ENOMEM;
memcpy(&frag->rm, rec, sizeof(frag->rm));
diff --git a/fs/xfs/scrub/rtrefcount_repair.c b/fs/xfs/scrub/rtrefcount_repair.c
index f713daf095fb..f165fb397647 100644
--- a/fs/xfs/scrub/rtrefcount_repair.c
+++ b/fs/xfs/scrub/rtrefcount_repair.c
@@ -709,7 +709,7 @@ xrep_rtrefcountbt(
if (error)
return error;
- rr = kzalloc(sizeof(struct xrep_rtrefc), XCHK_GFP_FLAGS);
+ rr = kzalloc_obj(struct xrep_rtrefc, XCHK_GFP_FLAGS);
if (!rr)
return -ENOMEM;
rr->sc = sc;
diff --git a/fs/xfs/scrub/rtrmap_repair.c b/fs/xfs/scrub/rtrmap_repair.c
index 4610d6d80648..f2d16ca8d251 100644
--- a/fs/xfs/scrub/rtrmap_repair.c
+++ b/fs/xfs/scrub/rtrmap_repair.c
@@ -111,7 +111,7 @@ xrep_setup_rtrmapbt(
if (error)
return error;
- rr = kzalloc(sizeof(struct xrep_rtrmap), XCHK_GFP_FLAGS);
+ rr = kzalloc_obj(struct xrep_rtrmap, XCHK_GFP_FLAGS);
if (!rr)
return -ENOMEM;
diff --git a/fs/xfs/scrub/rtsummary.c b/fs/xfs/scrub/rtsummary.c
index b510e6bbbd3e..efce39d7a1ef 100644
--- a/fs/xfs/scrub/rtsummary.c
+++ b/fs/xfs/scrub/rtsummary.c
@@ -49,8 +49,7 @@ xchk_setup_rtsummary(
if (xchk_need_intent_drain(sc))
xchk_fsgates_enable(sc, XCHK_FSGATES_DRAIN);
- rts = kvzalloc(struct_size(rts, words, mp->m_blockwsize),
- XCHK_GFP_FLAGS);
+ rts = kvzalloc_flex(*rts, words, mp->m_blockwsize, XCHK_GFP_FLAGS);
if (!rts)
return -ENOMEM;
sc->buf = rts;
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index c1c6415f5055..27511a125b39 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -632,7 +632,7 @@ xchk_scrub_create_subord(
{
struct xfs_scrub_subord *sub;
- sub = kzalloc(sizeof(*sub), XCHK_GFP_FLAGS);
+ sub = kzalloc_obj(*sub, XCHK_GFP_FLAGS);
if (!sub)
return NULL;
@@ -680,7 +680,7 @@ xfs_scrub_metadata(
if (error)
goto out;
- sc = kzalloc(sizeof(struct xfs_scrub), XCHK_GFP_FLAGS);
+ sc = kzalloc_obj(struct xfs_scrub, XCHK_GFP_FLAGS);
if (!sc) {
error = -ENOMEM;
goto out;
diff --git a/fs/xfs/scrub/stats.c b/fs/xfs/scrub/stats.c
index 4efafc5ae966..8cd018bac5d6 100644
--- a/fs/xfs/scrub/stats.c
+++ b/fs/xfs/scrub/stats.c
@@ -389,7 +389,7 @@ xchk_mount_stats_alloc(
struct xchk_stats *cs;
int error;
- cs = kvzalloc(sizeof(struct xchk_stats), GFP_KERNEL);
+ cs = kvzalloc_obj(struct xchk_stats, GFP_KERNEL);
if (!cs)
return -ENOMEM;
diff --git a/fs/xfs/scrub/xfblob.c b/fs/xfs/scrub/xfblob.c
index 96fc360312de..84237fb41ccb 100644
--- a/fs/xfs/scrub/xfblob.c
+++ b/fs/xfs/scrub/xfblob.c
@@ -41,7 +41,7 @@ xfblob_create(
if (error)
return error;
- blob = kmalloc(sizeof(struct xfblob), XCHK_GFP_FLAGS);
+ blob = kmalloc_obj(struct xfblob, XCHK_GFP_FLAGS);
if (!blob) {
error = -ENOMEM;
goto out_xfile;
diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c
index bee0662fbdb6..05581571854d 100644
--- a/fs/xfs/scrub/xfile.c
+++ b/fs/xfs/scrub/xfile.c
@@ -57,7 +57,7 @@ xfile_create(
struct xfile *xf;
int error;
- xf = kmalloc(sizeof(struct xfile), XCHK_GFP_FLAGS);
+ xf = kmalloc_obj(struct xfile, XCHK_GFP_FLAGS);
if (!xf)
return -ENOMEM;
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index db46883991de..d2f3c50d80e7 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -295,8 +295,8 @@ xfs_buf_alloc(
if (nmaps == 1)
bp->b_maps = &bp->__b_map;
else
- bp->b_maps = kcalloc(nmaps, sizeof(struct xfs_buf_map),
- GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
+ bp->b_maps = kzalloc_objs(struct xfs_buf_map, nmaps,
+ GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
for (i = 0; i < nmaps; i++) {
bp->b_maps[i].bm_bn = map[i].bm_bn;
bp->b_maps[i].bm_len = map[i].bm_len;
@@ -1799,7 +1799,7 @@ xfs_alloc_buftarg(
#if defined(CONFIG_FS_DAX) && defined(CONFIG_MEMORY_FAILURE)
ops = &xfs_dax_holder_operations;
#endif
- btp = kzalloc(sizeof(*btp), GFP_KERNEL | __GFP_NOFAIL);
+ btp = kzalloc_obj(*btp, GFP_KERNEL | __GFP_NOFAIL);
btp->bt_mount = mp;
btp->bt_file = bdev_file;
diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c
index 77ad071ebe78..5f391372f188 100644
--- a/fs/xfs/xfs_buf_item_recover.c
+++ b/fs/xfs/xfs_buf_item_recover.c
@@ -90,7 +90,7 @@ xlog_add_buffer_cancelled(
return false;
}
- bcp = kmalloc(sizeof(struct xfs_buf_cancel), GFP_KERNEL | __GFP_NOFAIL);
+ bcp = kmalloc_obj(struct xfs_buf_cancel, GFP_KERNEL | __GFP_NOFAIL);
bcp->bc_blkno = blkno;
bcp->bc_len = len;
bcp->bc_refcount = 1;
@@ -1180,8 +1180,7 @@ xlog_alloc_buf_cancel_table(
ASSERT(log->l_buf_cancel_table == NULL);
- p = kmalloc_array(XLOG_BC_TABLE_SIZE, sizeof(struct list_head),
- GFP_KERNEL);
+ p = kmalloc_objs(struct list_head, XLOG_BC_TABLE_SIZE, GFP_KERNEL);
if (!p)
return -ENOMEM;
diff --git a/fs/xfs/xfs_buf_mem.c b/fs/xfs/xfs_buf_mem.c
index f1f23623e4a4..e0529f380a77 100644
--- a/fs/xfs/xfs_buf_mem.c
+++ b/fs/xfs/xfs_buf_mem.c
@@ -58,7 +58,7 @@ xmbuf_alloc(
struct xfs_buftarg *btp;
int error;
- btp = kzalloc(struct_size(btp, bt_cache, 1), GFP_KERNEL);
+ btp = kzalloc_flex(*btp, bt_cache, 1, GFP_KERNEL);
if (!btp)
return -ENOMEM;
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 31477a74b523..3ecbb4e0f2c8 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -349,7 +349,7 @@ xfs_trim_perag_extents(
do {
struct xfs_busy_extents *extents;
- extents = kzalloc(sizeof(*extents), GFP_KERNEL);
+ extents = kzalloc_obj(*extents, GFP_KERNEL);
if (!extents) {
error = -ENOMEM;
break;
@@ -537,7 +537,7 @@ xfs_trim_gather_rtextent(
return 0;
}
- busyp = kzalloc(sizeof(struct xfs_rtx_busy), GFP_KERNEL);
+ busyp = kzalloc_obj(struct xfs_rtx_busy, GFP_KERNEL);
if (!busyp)
return -ENOMEM;
@@ -689,7 +689,7 @@ xfs_trim_rtgroup_extents(
* trims the extents returned.
*/
do {
- tr.extents = kzalloc(sizeof(*tr.extents), GFP_KERNEL);
+ tr.extents = kzalloc_obj(*tr.extents, GFP_KERNEL);
if (!tr.extents) {
error = -ENOMEM;
break;
diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c
index cfecb2959472..a5f02cac9d31 100644
--- a/fs/xfs/xfs_extent_busy.c
+++ b/fs/xfs/xfs_extent_busy.c
@@ -41,8 +41,7 @@ xfs_extent_busy_insert_list(
struct rb_node **rbp;
struct rb_node *parent = NULL;
- new = kzalloc(sizeof(struct xfs_extent_busy),
- GFP_KERNEL | __GFP_NOFAIL);
+ new = kzalloc_obj(struct xfs_extent_busy, GFP_KERNEL | __GFP_NOFAIL);
new->group = xfs_group_hold(xg);
new->bno = bno;
new->length = len;
@@ -718,7 +717,7 @@ xfs_extent_busy_alloc(void)
{
struct xfs_extent_busy_tree *eb;
- eb = kzalloc(sizeof(*eb), GFP_KERNEL);
+ eb = kzalloc_obj(*eb, GFP_KERNEL);
if (!eb)
return NULL;
spin_lock_init(&eb->eb_lock);
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index 44e1b14069a3..32e641d76e92 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -308,7 +308,7 @@ xfs_filestream_create_association(
* error for this failure - as long as we return a referenced AG, the
* allocation can still go ahead just fine.
*/
- item = kmalloc(sizeof(*item), GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ item = kmalloc_obj(*item, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!item)
goto out_put_fstrms;
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 098c2b50bc6f..3724e64898f3 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -1326,11 +1326,11 @@ xfs_ioc_getfsmap(
*/
count = min_t(unsigned int, head.fmh_count,
131072 / sizeof(struct fsmap));
- recs = kvcalloc(count, sizeof(struct fsmap), GFP_KERNEL);
+ recs = kvzalloc_objs(struct fsmap, count, GFP_KERNEL);
if (!recs) {
count = min_t(unsigned int, head.fmh_count,
PAGE_SIZE / sizeof(struct fsmap));
- recs = kvcalloc(count, sizeof(struct fsmap), GFP_KERNEL);
+ recs = kvzalloc_objs(struct fsmap, count, GFP_KERNEL);
if (!recs)
return -ENOMEM;
}
diff --git a/fs/xfs/xfs_healthmon.c b/fs/xfs/xfs_healthmon.c
index ca7352dcd182..757a4213b2d0 100644
--- a/fs/xfs/xfs_healthmon.c
+++ b/fs/xfs/xfs_healthmon.c
@@ -1187,7 +1187,7 @@ xfs_ioc_health_monitor(
if (!xfs_healthmon_validate(&hmo))
return -EINVAL;
- hm = kzalloc(sizeof(*hm), GFP_KERNEL);
+ hm = kzalloc_obj(*hm, GFP_KERNEL);
if (!hm)
return -ENOMEM;
hm->dev = mp->m_super->s_dev;
@@ -1200,7 +1200,7 @@ xfs_ioc_health_monitor(
hm->verbose = true;
/* Queue up the first event that lets the client know we're running. */
- running_event = kzalloc(sizeof(struct xfs_healthmon_event), GFP_NOFS);
+ running_event = kzalloc_obj(struct xfs_healthmon_event, GFP_NOFS);
if (!running_event) {
ret = -ENOMEM;
goto out_hm;
@@ -1214,8 +1214,7 @@ xfs_ioc_health_monitor(
* filesystem later. This is key for triggering fast exit of the
* xfs_healer daemon.
*/
- hm->unmount_event = kzalloc(sizeof(struct xfs_healthmon_event),
- GFP_NOFS);
+ hm->unmount_event = kzalloc_obj(struct xfs_healthmon_event, GFP_NOFS);
if (!hm->unmount_event) {
ret = -ENOMEM;
goto out_hm;
diff --git a/fs/xfs/xfs_inode_item_recover.c b/fs/xfs/xfs_inode_item_recover.c
index 5d93228783eb..b42106c4a9ef 100644
--- a/fs/xfs/xfs_inode_item_recover.c
+++ b/fs/xfs/xfs_inode_item_recover.c
@@ -329,8 +329,8 @@ xlog_recover_inode_commit_pass2(
if (item->ri_buf[0].iov_len == sizeof(struct xfs_inode_log_format)) {
in_f = item->ri_buf[0].iov_base;
} else {
- in_f = kmalloc(sizeof(struct xfs_inode_log_format),
- GFP_KERNEL | __GFP_NOFAIL);
+ in_f = kmalloc_obj(struct xfs_inode_log_format,
+ GFP_KERNEL | __GFP_NOFAIL);
need_free = 1;
error = xfs_inode_item_format_convert(&item->ri_buf[0], in_f);
if (error)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 4eeda4d4e3ab..1074e36fa240 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -896,7 +896,7 @@ xfs_ioc_getbmap(
if (bmx.bmv_count >= INT_MAX / recsize)
return -ENOMEM;
- buf = kvcalloc(bmx.bmv_count, sizeof(*buf), GFP_KERNEL);
+ buf = kvzalloc_objs(*buf, bmx.bmv_count, GFP_KERNEL);
if (!buf)
return -ENOMEM;
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 9faff287f747..97f106d2b4cd 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -230,8 +230,8 @@ xfs_bulkstat_one(
ASSERT(breq->icount == 1);
- bc.buf = kzalloc(sizeof(struct xfs_bulkstat),
- GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ bc.buf = kzalloc_obj(struct xfs_bulkstat,
+ GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!bc.buf)
return -ENOMEM;
@@ -317,8 +317,8 @@ xfs_bulkstat(
if (xfs_bulkstat_already_done(breq->mp, breq->startino))
return 0;
- bc.buf = kzalloc(sizeof(struct xfs_bulkstat),
- GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ bc.buf = kzalloc_obj(struct xfs_bulkstat,
+ GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!bc.buf)
return -ENOMEM;
diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c
index ed4033006868..96a4cb3360bc 100644
--- a/fs/xfs/xfs_iwalk.c
+++ b/fs/xfs/xfs_iwalk.c
@@ -659,8 +659,8 @@ xfs_iwalk_threaded(
if (xfs_pwork_ctl_want_abort(&pctl))
break;
- iwag = kzalloc(sizeof(struct xfs_iwalk_ag),
- GFP_KERNEL | __GFP_NOFAIL);
+ iwag = kzalloc_obj(struct xfs_iwalk_ag,
+ GFP_KERNEL | __GFP_NOFAIL);
iwag->mp = mp;
/*
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index a26378ca247d..b96f262ba139 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1334,7 +1334,7 @@ xlog_alloc_log(
int error = -ENOMEM;
uint log2_size = 0;
- log = kzalloc(sizeof(struct xlog), GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ log = kzalloc_obj(struct xlog, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!log) {
xfs_warn(mp, "Log allocation failed: No memory!");
goto out;
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 566976b8fef3..edc368938f30 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -100,7 +100,7 @@ xlog_cil_ctx_alloc(void)
{
struct xfs_cil_ctx *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL | __GFP_NOFAIL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL | __GFP_NOFAIL);
INIT_LIST_HEAD(&ctx->committing);
INIT_LIST_HEAD(&ctx->busy_extents.extent_list);
INIT_LIST_HEAD(&ctx->log_items);
@@ -2006,7 +2006,7 @@ xlog_cil_init(
struct xlog_cil_pcp *cilpcp;
int cpu;
- cil = kzalloc(sizeof(*cil), GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ cil = kzalloc_obj(*cil, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!cil)
return -ENOMEM;
/*
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 935905743f94..09e6678ca487 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2092,8 +2092,7 @@ xlog_recover_add_item(
{
struct xlog_recover_item *item;
- item = kzalloc(sizeof(struct xlog_recover_item),
- GFP_KERNEL | __GFP_NOFAIL);
+ item = kzalloc_obj(struct xlog_recover_item, GFP_KERNEL | __GFP_NOFAIL);
INIT_LIST_HEAD(&item->ri_list);
list_add_tail(&item->ri_list, head);
}
@@ -2223,8 +2222,8 @@ xlog_recover_add_to_trans(
}
item->ri_total = in_f->ilf_size;
- item->ri_buf = kcalloc(item->ri_total, sizeof(*item->ri_buf),
- GFP_KERNEL | __GFP_NOFAIL);
+ item->ri_buf = kzalloc_objs(*item->ri_buf, item->ri_total,
+ GFP_KERNEL | __GFP_NOFAIL);
}
if (item->ri_total <= item->ri_cnt) {
@@ -2367,7 +2366,7 @@ xlog_recover_ophdr_to_trans(
* This is a new transaction so allocate a new recovery container to
* hold the recovery ops that will follow.
*/
- trans = kzalloc(sizeof(struct xlog_recover), GFP_KERNEL | __GFP_NOFAIL);
+ trans = kzalloc_obj(struct xlog_recover, GFP_KERNEL | __GFP_NOFAIL);
trans->r_log_tid = tid;
trans->r_lsn = be64_to_cpu(rhead->h_lsn);
INIT_LIST_HEAD(&trans->r_itemq);
diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
index 4e417747688f..d61ec8cb126d 100644
--- a/fs/xfs/xfs_mru_cache.c
+++ b/fs/xfs/xfs_mru_cache.c
@@ -333,7 +333,7 @@ xfs_mru_cache_create(
if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count))
return -EINVAL;
- mru = kzalloc(sizeof(*mru), GFP_KERNEL | __GFP_NOFAIL);
+ mru = kzalloc_obj(*mru, GFP_KERNEL | __GFP_NOFAIL);
if (!mru)
return -ENOMEM;
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index a3e7d4a107d4..7bd15d9e7fba 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -771,8 +771,8 @@ xfs_qm_init_quotainfo(
ASSERT(XFS_IS_QUOTA_ON(mp));
- qinf = mp->m_quotainfo = kzalloc(sizeof(struct xfs_quotainfo),
- GFP_KERNEL | __GFP_NOFAIL);
+ qinf = mp->m_quotainfo = kzalloc_obj(struct xfs_quotainfo,
+ GFP_KERNEL | __GFP_NOFAIL);
error = list_lru_init(&qinf->qi_lru);
if (error)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 8586f044a14b..0ce953b45852 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -2235,12 +2235,12 @@ xfs_init_fs_context(
struct xfs_mount *mp;
int i;
- mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
+ mp = kzalloc_obj(struct xfs_mount, GFP_KERNEL);
if (!mp)
return -ENOMEM;
#ifdef DEBUG
- mp->m_errortag = kcalloc(XFS_ERRTAG_MAX, sizeof(*mp->m_errortag),
- GFP_KERNEL);
+ mp->m_errortag = kzalloc_objs(*mp->m_errortag, XFS_ERRTAG_MAX,
+ GFP_KERNEL);
if (!mp->m_errortag) {
kfree(mp);
return -ENOMEM;
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 363d7f88c2c6..923729af4206 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -922,8 +922,7 @@ xfs_trans_ail_init(
{
struct xfs_ail *ailp;
- ailp = kzalloc(sizeof(struct xfs_ail),
- GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+ ailp = kzalloc_obj(struct xfs_ail, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!ailp)
return -ENOMEM;
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index b60952565737..5d45d88f1f03 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -417,7 +417,7 @@ xfs_init_open_zone(
{
struct xfs_open_zone *oz;
- oz = kzalloc(sizeof(*oz), GFP_NOFS | __GFP_NOFAIL);
+ oz = kzalloc_obj(*oz, GFP_NOFS | __GFP_NOFAIL);
spin_lock_init(&oz->oz_alloc_lock);
atomic_set(&oz->oz_ref, 1);
oz->oz_rtg = rtg;
@@ -1196,7 +1196,7 @@ xfs_alloc_zone_info(
struct xfs_zone_info *zi;
int i;
- zi = kzalloc(sizeof(*zi), GFP_KERNEL);
+ zi = kzalloc_obj(*zi, GFP_KERNEL);
if (!zi)
return NULL;
INIT_LIST_HEAD(&zi->zi_open_zones);
diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
index 1f1f9fc973af..b8b9c72e955a 100644
--- a/fs/xfs/xfs_zone_gc.c
+++ b/fs/xfs/xfs_zone_gc.c
@@ -199,11 +199,11 @@ xfs_zone_gc_data_alloc(
struct xfs_zone_gc_data *data;
int i;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return NULL;
- data->iter.recs = kcalloc(XFS_ZONE_GC_RECS, sizeof(*data->iter.recs),
- GFP_KERNEL);
+ data->iter.recs = kzalloc_objs(*data->iter.recs, XFS_ZONE_GC_RECS,
+ GFP_KERNEL);
if (!data->iter.recs)
goto out_free_data;
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 086a31269198..28be57db6e4b 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -903,8 +903,8 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
struct block_device *bdev = zd->sb->s_bdev;
int ret;
- zd->zones = kvcalloc(bdev_nr_zones(bdev), sizeof(struct blk_zone),
- GFP_KERNEL);
+ zd->zones = kvzalloc_objs(struct blk_zone, bdev_nr_zones(bdev),
+ GFP_KERNEL);
if (!zd->zones)
return -ENOMEM;
@@ -948,8 +948,8 @@ static int zonefs_init_zgroup(struct super_block *sb,
if (!zgroup->g_nr_zones)
return 0;
- zgroup->g_zones = kvcalloc(zgroup->g_nr_zones,
- sizeof(struct zonefs_zone), GFP_KERNEL);
+ zgroup->g_zones = kvzalloc_objs(struct zonefs_zone, zgroup->g_nr_zones,
+ GFP_KERNEL);
if (!zgroup->g_zones)
return -ENOMEM;
@@ -1243,7 +1243,7 @@ static int zonefs_fill_super(struct super_block *sb, struct fs_context *fc)
* ZONEFS_F_AGGRCNV which increases the maximum file size of a file
* beyond the zone size is taken into account.
*/
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi)
return -ENOMEM;
@@ -1388,7 +1388,7 @@ static int zonefs_init_fs_context(struct fs_context *fc)
{
struct zonefs_context *ctx;
- ctx = kzalloc(sizeof(struct zonefs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct zonefs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
ctx->s_mount_opts = ZONEFS_MNTOPT_ERRORS_RO;