diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/scsi/fcoe | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
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 'drivers/scsi/fcoe')
| -rw-r--r-- | drivers/scsi/fcoe/fcoe.c | 2 | ||||
| -rw-r--r-- | drivers/scsi/fcoe/fcoe_ctlr.c | 7 | ||||
| -rw-r--r-- | drivers/scsi/fcoe/fcoe_sysfs.c | 2 | ||||
| -rw-r--r-- | drivers/scsi/fcoe/fcoe_transport.c | 2 |
4 files changed, 6 insertions, 7 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index c8c5dfb3ba9a..bc0064da561c 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -820,7 +820,7 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev) if (realdev->netdev_ops->ndo_fcoe_get_hbainfo) { struct netdev_fcoe_hbainfo *fdmi; - fdmi = kzalloc(sizeof(*fdmi), GFP_KERNEL); + fdmi = kzalloc_obj(*fdmi, GFP_KERNEL); if (!fdmi) return; diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c index 8e4241c295e3..a356cf072bf1 100644 --- a/drivers/scsi/fcoe/fcoe_ctlr.c +++ b/drivers/scsi/fcoe/fcoe_ctlr.c @@ -168,7 +168,7 @@ static int fcoe_sysfs_fcf_add(struct fcoe_fcf *new) LIBFCOE_FIP_DBG(fip, "New FCF fab %16.16llx mac %pM\n", new->fabric_name, new->fcf_mac); - temp = kzalloc(sizeof(*temp), GFP_KERNEL); + temp = kzalloc_obj(*temp, GFP_KERNEL); if (!temp) goto out; @@ -1043,7 +1043,7 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb) if (fip->fcf_count >= FCOE_CTLR_FCF_LIMIT) goto out; - fcf = kmalloc(sizeof(*fcf), GFP_ATOMIC); + fcf = kmalloc_obj(*fcf, GFP_ATOMIC); if (!fcf) goto out; @@ -1378,8 +1378,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, */ num_vlink_desc = rlen / sizeof(*vp); if (num_vlink_desc) - vlink_desc_arr = kmalloc_array(num_vlink_desc, sizeof(vp), - GFP_ATOMIC); + vlink_desc_arr = kmalloc_objs(vp, num_vlink_desc, GFP_ATOMIC); if (!vlink_desc_arr) return; num_vlink_desc = 0; diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c index 0609ca6b9353..afea5763a3c0 100644 --- a/drivers/scsi/fcoe/fcoe_sysfs.c +++ b/drivers/scsi/fcoe/fcoe_sysfs.c @@ -986,7 +986,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr, } } - fcf = kzalloc(sizeof(struct fcoe_fcf_device), GFP_ATOMIC); + fcf = kzalloc_obj(struct fcoe_fcf_device, GFP_ATOMIC); if (unlikely(!fcf)) goto out; diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c index 2f478426f16e..e1615cc5c092 100644 --- a/drivers/scsi/fcoe/fcoe_transport.c +++ b/drivers/scsi/fcoe/fcoe_transport.c @@ -638,7 +638,7 @@ static int fcoe_add_netdev_mapping(struct net_device *netdev, { struct fcoe_netdev_mapping *nm; - nm = kmalloc(sizeof(*nm), GFP_KERNEL); + nm = kmalloc_obj(*nm, GFP_KERNEL); if (!nm) { printk(KERN_ERR "Unable to allocate netdev_mapping"); return -ENOMEM; |
