summaryrefslogtreecommitdiff
path: root/drivers/vdpa
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-02-21 11:02:58 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-02-21 11:02:58 -0800
commit8934827db5403eae57d4537114a9ff88b0a8460f (patch)
tree5167aa7e16b786b9135e19d508b234054fa6e8ce /drivers/vdpa
parentc7decec2f2d2ab0366567f9e30c0e1418cece43f (diff)
parent7a70c15bd1449f1eb30991772edce37b41e496fb (diff)
Merge tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull kmalloc_obj conversion from Kees Cook: "This does the tree-wide conversion to kmalloc_obj() and friends using coccinelle, with a subsequent small manual cleanup of whitespace alignment that coccinelle does not handle. This uncovered a clang bug in __builtin_counted_by_ref(), so the conversion is preceded by disabling that for current versions of clang. The imminent clang 22.1 release has the fix. I've done allmodconfig build tests for x86_64, arm64, i386, and arm. I did defconfig builds for alpha, m68k, mips, parisc, powerpc, riscv, s390, sparc, sh, arc, csky, xtensa, hexagon, and openrisc" * tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: kmalloc_obj: Clean up after treewide replacements treewide: Replace kmalloc with kmalloc_obj for non-scalar types compiler_types: Disable __builtin_counted_by_ref for Clang
Diffstat (limited to 'drivers/vdpa')
-rw-r--r--drivers/vdpa/ifcvf/ifcvf_main.c2
-rw-r--r--drivers/vdpa/mlx5/core/mr.c10
-rw-r--r--drivers/vdpa/mlx5/net/mlx5_vnet.c26
-rw-r--r--drivers/vdpa/pds/aux_drv.c2
-rw-r--r--drivers/vdpa/solidrun/snet_main.c6
-rw-r--r--drivers/vdpa/vdpa_sim/vdpa_sim.c12
-rw-r--r--drivers/vdpa/vdpa_user/iova_domain.c4
-rw-r--r--drivers/vdpa/vdpa_user/vduse_dev.c17
-rw-r--r--drivers/vdpa/virtio_pci/vp_vdpa.c6
9 files changed, 43 insertions, 42 deletions
diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 6658dc74d915..b1b4c6adeef7 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -793,7 +793,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
pci_set_master(pdev);
- ifcvf_mgmt_dev = kzalloc(sizeof(struct ifcvf_vdpa_mgmt_dev), GFP_KERNEL);
+ ifcvf_mgmt_dev = kzalloc_obj(struct ifcvf_vdpa_mgmt_dev, GFP_KERNEL);
if (!ifcvf_mgmt_dev) {
IFCVF_ERR(pdev, "Failed to alloc memory for the vDPA management device\n");
return -ENOMEM;
diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c
index 8870a7169267..f27316f3fec3 100644
--- a/drivers/vdpa/mlx5/core/mr.c
+++ b/drivers/vdpa/mlx5/core/mr.c
@@ -215,7 +215,7 @@ static int create_direct_keys(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *
int err = 0;
int i = 0;
- cmds = kvcalloc(mr->num_directs, sizeof(*cmds), GFP_KERNEL);
+ cmds = kvzalloc_objs(*cmds, mr->num_directs, GFP_KERNEL);
if (!cmds)
return -ENOMEM;
@@ -287,8 +287,8 @@ static int destroy_direct_keys(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr
int err = 0;
int i = 0;
- cmds = kvcalloc(mr->num_directs, sizeof(*cmds), GFP_KERNEL);
- cmd_mem = kvcalloc(mr->num_directs, sizeof(*cmd_mem), GFP_KERNEL);
+ cmds = kvzalloc_objs(*cmds, mr->num_directs, GFP_KERNEL);
+ cmd_mem = kvzalloc_objs(*cmd_mem, mr->num_directs, GFP_KERNEL);
if (!cmds || !cmd_mem)
return -ENOMEM;
@@ -456,7 +456,7 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev,
st = start;
while (size) {
sz = (u32)min_t(u64, MAX_KLM_SIZE, size);
- dmr = kzalloc(sizeof(*dmr), GFP_KERNEL);
+ dmr = kzalloc_obj(*dmr, GFP_KERNEL);
if (!dmr) {
err = -ENOMEM;
goto err_alloc;
@@ -817,7 +817,7 @@ struct mlx5_vdpa_mr *mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev,
struct mlx5_vdpa_mr *mr;
int err;
- mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+ mr = kzalloc_obj(*mr, GFP_KERNEL);
if (!mr)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index b7e46338815f..15a6c91ec335 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1229,8 +1229,8 @@ static int query_virtqueues(struct mlx5_vdpa_net *ndev,
WARN(start_vq + num_vqs > mvdev->max_vqs, "query vq range invalid [%d, %d), max_vqs: %u\n",
start_vq, start_vq + num_vqs, mvdev->max_vqs);
- cmds = kvcalloc(num_vqs, sizeof(*cmds), GFP_KERNEL);
- cmd_mem = kvcalloc(num_vqs, sizeof(*cmd_mem), GFP_KERNEL);
+ cmds = kvzalloc_objs(*cmds, num_vqs, GFP_KERNEL);
+ cmd_mem = kvzalloc_objs(*cmd_mem, num_vqs, GFP_KERNEL);
if (!cmds || !cmd_mem) {
err = -ENOMEM;
goto done;
@@ -1562,8 +1562,8 @@ static int modify_virtqueues(struct mlx5_vdpa_net *ndev, int start_vq, int num_v
WARN(start_vq + num_vqs > mvdev->max_vqs, "modify vq range invalid [%d, %d), max_vqs: %u\n",
start_vq, start_vq + num_vqs, mvdev->max_vqs);
- cmds = kvcalloc(num_vqs, sizeof(*cmds), GFP_KERNEL);
- cmd_mem = kvcalloc(num_vqs, sizeof(*cmd_mem), GFP_KERNEL);
+ cmds = kvzalloc_objs(*cmds, num_vqs, GFP_KERNEL);
+ cmd_mem = kvzalloc_objs(*cmd_mem, num_vqs, GFP_KERNEL);
if (!cmds || !cmd_mem) {
err = -ENOMEM;
goto done;
@@ -1649,7 +1649,7 @@ static int suspend_vqs(struct mlx5_vdpa_net *ndev, int start_vq, int num_vqs)
if (err)
return err;
- attrs = kcalloc(num_vqs, sizeof(struct mlx5_virtq_attr), GFP_KERNEL);
+ attrs = kzalloc_objs(struct mlx5_virtq_attr, num_vqs, GFP_KERNEL);
if (!attrs)
return -ENOMEM;
@@ -1922,7 +1922,7 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac,
int err;
u16 vid;
- spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
+ spec = kvzalloc_obj(*spec, GFP_KERNEL);
if (!spec)
return -ENOMEM;
@@ -2034,7 +2034,7 @@ static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vid, bool tagge
if (mac_vlan_lookup(ndev, val))
return -EEXIST;
- ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
+ ptr = kzalloc_obj(*ptr, GFP_KERNEL);
if (!ptr)
return -ENOMEM;
@@ -2846,7 +2846,7 @@ static int queue_link_work(struct mlx5_vdpa_net *ndev)
{
struct mlx5_vdpa_wq_ent *wqent;
- wqent = kzalloc(sizeof(*wqent), GFP_ATOMIC);
+ wqent = kzalloc_obj(*wqent, GFP_ATOMIC);
if (!wqent)
return -ENOMEM;
@@ -3809,7 +3809,8 @@ static void allocate_irqs(struct mlx5_vdpa_net *ndev)
if (!ndev->mvdev.mdev->pdev)
return;
- ndev->irqp.entries = kcalloc(ndev->mvdev.max_vqs, sizeof(*ndev->irqp.entries), GFP_KERNEL);
+ ndev->irqp.entries = kzalloc_objs(*ndev->irqp.entries,
+ ndev->mvdev.max_vqs, GFP_KERNEL);
if (!ndev->irqp.entries)
return;
@@ -3901,8 +3902,9 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
mlx5_cmd_init_async_ctx(mdev, &mvdev->async_ctx);
- ndev->vqs = kcalloc(max_vqs, sizeof(*ndev->vqs), GFP_KERNEL);
- ndev->event_cbs = kcalloc(max_vqs + 1, sizeof(*ndev->event_cbs), GFP_KERNEL);
+ ndev->vqs = kzalloc_objs(*ndev->vqs, max_vqs, GFP_KERNEL);
+ ndev->event_cbs = kzalloc_objs(*ndev->event_cbs, max_vqs + 1,
+ GFP_KERNEL);
if (!ndev->vqs || !ndev->event_cbs) {
err = -ENOMEM;
goto err_alloc;
@@ -4102,7 +4104,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
struct mlx5_vdpa_mgmtdev *mgtdev;
int err;
- mgtdev = kzalloc(sizeof(*mgtdev), GFP_KERNEL);
+ mgtdev = kzalloc_obj(*mgtdev, GFP_KERNEL);
if (!mgtdev)
return -ENOMEM;
diff --git a/drivers/vdpa/pds/aux_drv.c b/drivers/vdpa/pds/aux_drv.c
index f57330cf9024..970eec66b117 100644
--- a/drivers/vdpa/pds/aux_drv.c
+++ b/drivers/vdpa/pds/aux_drv.c
@@ -39,7 +39,7 @@ static int pds_vdpa_probe(struct auxiliary_device *aux_dev,
struct pds_vdpa_aux *vdpa_aux;
int err;
- vdpa_aux = kzalloc(sizeof(*vdpa_aux), GFP_KERNEL);
+ vdpa_aux = kzalloc_obj(*vdpa_aux, GFP_KERNEL);
if (!vdpa_aux)
return -ENOMEM;
diff --git a/drivers/vdpa/solidrun/snet_main.c b/drivers/vdpa/solidrun/snet_main.c
index 4588211d57eb..527efeed912c 100644
--- a/drivers/vdpa/solidrun/snet_main.c
+++ b/drivers/vdpa/solidrun/snet_main.c
@@ -732,7 +732,7 @@ static int psnet_read_cfg(struct pci_dev *pdev, struct psnet *psnet)
/* Load device configuration from BAR */
for (i = 0; i < cfg->devices_num; i++) {
- cfg->devs[i] = kzalloc(sizeof(*cfg->devs[i]), GFP_KERNEL);
+ cfg->devs[i] = kzalloc_obj(*cfg->devs[i], GFP_KERNEL);
if (!cfg->devs[i]) {
snet_free_cfg(cfg);
return -ENOMEM;
@@ -827,7 +827,7 @@ static int snet_build_vqs(struct snet *snet)
/* Allocate the VQs */
for (i = 0; i < snet->cfg->vq_num; i++) {
- snet->vqs[i] = kzalloc(sizeof(*snet->vqs[i]), GFP_KERNEL);
+ snet->vqs[i] = kzalloc_obj(*snet->vqs[i], GFP_KERNEL);
if (!snet->vqs[i]) {
snet_free_vqs(snet);
return -ENOMEM;
@@ -902,7 +902,7 @@ static int snet_vdpa_probe_pf(struct pci_dev *pdev)
}
/* Allocate a PCI physical function device */
- psnet = kzalloc(sizeof(*psnet), GFP_KERNEL);
+ psnet = kzalloc_obj(*psnet, GFP_KERNEL);
if (!psnet)
return -ENOMEM;
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index df9c7ddc5d78..24b4fca22893 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -246,18 +246,18 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr,
if (!vdpasim->config)
goto err_iommu;
- vdpasim->vqs = kcalloc(dev_attr->nvqs, sizeof(struct vdpasim_virtqueue),
- GFP_KERNEL);
+ vdpasim->vqs = kzalloc_objs(struct vdpasim_virtqueue, dev_attr->nvqs,
+ GFP_KERNEL);
if (!vdpasim->vqs)
goto err_iommu;
- vdpasim->iommu = kmalloc_array(vdpasim->dev_attr.nas,
- sizeof(*vdpasim->iommu), GFP_KERNEL);
+ vdpasim->iommu = kmalloc_objs(*vdpasim->iommu, vdpasim->dev_attr.nas,
+ GFP_KERNEL);
if (!vdpasim->iommu)
goto err_iommu;
- vdpasim->iommu_pt = kmalloc_array(vdpasim->dev_attr.nas,
- sizeof(*vdpasim->iommu_pt), GFP_KERNEL);
+ vdpasim->iommu_pt = kmalloc_objs(*vdpasim->iommu_pt,
+ vdpasim->dev_attr.nas, GFP_KERNEL);
if (!vdpasim->iommu_pt)
goto err_iommu;
diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
index 0a9f668467a8..44e9babc0b54 100644
--- a/drivers/vdpa/vdpa_user/iova_domain.c
+++ b/drivers/vdpa/vdpa_user/iova_domain.c
@@ -25,7 +25,7 @@ static int vduse_iotlb_add_range(struct vduse_iova_domain *domain,
struct vdpa_map_file *map_file;
int ret;
- map_file = kmalloc(sizeof(*map_file), GFP_ATOMIC);
+ map_file = kmalloc_obj(*map_file, GFP_ATOMIC);
if (!map_file)
return -ENOMEM;
@@ -622,7 +622,7 @@ vduse_domain_create(unsigned long iova_limit, size_t bounce_size)
if (iova_limit <= bounce_size)
return NULL;
- domain = kzalloc(sizeof(*domain), GFP_KERNEL);
+ domain = kzalloc_obj(*domain, GFP_KERNEL);
if (!domain)
return NULL;
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 405d59610f76..7478aa8d5489 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -1232,7 +1232,7 @@ static int vduse_dev_reg_umem(struct vduse_dev *dev,
npages = size >> PAGE_SHIFT;
page_list = __vmalloc(array_size(npages, sizeof(struct page *)),
GFP_KERNEL_ACCOUNT);
- umem = kzalloc(sizeof(*umem), GFP_KERNEL);
+ umem = kzalloc_obj(*umem, GFP_KERNEL);
if (!page_list || !umem)
goto unlock;
@@ -1800,12 +1800,12 @@ static int vduse_dev_init_vqs(struct vduse_dev *dev, u32 vq_align, u32 vq_num)
dev->vq_align = vq_align;
dev->vq_num = vq_num;
- dev->vqs = kcalloc(dev->vq_num, sizeof(*dev->vqs), GFP_KERNEL);
+ dev->vqs = kzalloc_objs(*dev->vqs, dev->vq_num, GFP_KERNEL);
if (!dev->vqs)
return -ENOMEM;
for (i = 0; i < vq_num; i++) {
- dev->vqs[i] = kzalloc(sizeof(*dev->vqs[i]), GFP_KERNEL);
+ dev->vqs[i] = kzalloc_obj(*dev->vqs[i], GFP_KERNEL);
if (!dev->vqs[i]) {
ret = -ENOMEM;
goto err;
@@ -1839,7 +1839,7 @@ err:
static struct vduse_dev *vduse_dev_create(void)
{
- struct vduse_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ struct vduse_dev *dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev)
return NULL;
@@ -2076,7 +2076,7 @@ static int vduse_create_dev(struct vduse_dev_config *config,
dev->vendor_id = config->vendor_id;
dev->nas = (dev->api_version < VDUSE_API_VERSION_1) ? 1 : config->nas;
- dev->as = kcalloc(dev->nas, sizeof(dev->as[0]), GFP_KERNEL);
+ dev->as = kzalloc_objs(dev->as[0], dev->nas, GFP_KERNEL);
if (!dev->as)
goto err_as;
for (int i = 0; i < dev->nas; i++)
@@ -2085,8 +2085,7 @@ static int vduse_create_dev(struct vduse_dev_config *config,
dev->ngroups = (dev->api_version < VDUSE_API_VERSION_1)
? 1
: config->ngroups;
- dev->groups = kcalloc(dev->ngroups, sizeof(dev->groups[0]),
- GFP_KERNEL);
+ dev->groups = kzalloc_objs(dev->groups[0], dev->ngroups, GFP_KERNEL);
if (!dev->groups)
goto err_vq_groups;
for (u32 i = 0; i < dev->ngroups; ++i) {
@@ -2227,7 +2226,7 @@ static int vduse_open(struct inode *inode, struct file *file)
{
struct vduse_control *control;
- control = kmalloc(sizeof(struct vduse_control), GFP_KERNEL);
+ control = kmalloc_obj(struct vduse_control, GFP_KERNEL);
if (!control)
return -ENOMEM;
@@ -2357,7 +2356,7 @@ static int vduse_mgmtdev_init(void)
{
int ret;
- vduse_mgmt = kzalloc(sizeof(*vduse_mgmt), GFP_KERNEL);
+ vduse_mgmt = kzalloc_obj(*vduse_mgmt, GFP_KERNEL);
if (!vduse_mgmt)
return -ENOMEM;
diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c
index 17a19a728c9c..102f25ccfddf 100644
--- a/drivers/vdpa/virtio_pci/vp_vdpa.c
+++ b/drivers/vdpa/virtio_pci/vp_vdpa.c
@@ -608,7 +608,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
struct virtio_device_id *mdev_id = NULL;
int err;
- vp_vdpa_mgtdev = kzalloc(sizeof(*vp_vdpa_mgtdev), GFP_KERNEL);
+ vp_vdpa_mgtdev = kzalloc_obj(*vp_vdpa_mgtdev, GFP_KERNEL);
if (!vp_vdpa_mgtdev)
return -ENOMEM;
@@ -616,7 +616,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
mgtdev->ops = &vp_vdpa_mdev_ops;
mgtdev->device = dev;
- mdev = kzalloc(sizeof(struct virtio_pci_modern_device), GFP_KERNEL);
+ mdev = kzalloc_obj(struct virtio_pci_modern_device, GFP_KERNEL);
if (!mdev) {
err = -ENOMEM;
goto mdev_err;
@@ -626,7 +626,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
* id_table should be a null terminated array, so allocate one additional
* entry here, see vdpa_mgmtdev_get_classes().
*/
- mdev_id = kcalloc(2, sizeof(struct virtio_device_id), GFP_KERNEL);
+ mdev_id = kzalloc_objs(struct virtio_device_id, 2, GFP_KERNEL);
if (!mdev_id) {
err = -ENOMEM;
goto mdev_id_err;