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/s390/scsi | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-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/s390/scsi')
| -rw-r--r-- | drivers/s390/scsi/zfcp_aux.c | 4 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_dbf.c | 2 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_diag.c | 2 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_fc.c | 4 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_fsf.c | 2 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_qdio.c | 2 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_reqlist.h | 2 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_scsi.c | 6 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_sysfs.c | 5 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_unit.c | 2 |
10 files changed, 15 insertions, 16 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index 01f927ae61b5..f8435ea9a967 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c @@ -344,7 +344,7 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device) if (!get_device(&ccw_device->dev)) return ERR_PTR(-ENODEV); - adapter = kzalloc(sizeof(struct zfcp_adapter), GFP_KERNEL); + adapter = kzalloc_obj(struct zfcp_adapter, GFP_KERNEL); if (!adapter) { put_device(&ccw_device->dev); return ERR_PTR(-ENOMEM); @@ -518,7 +518,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, goto err_put; } - port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL); + port = kzalloc_obj(struct zfcp_port, GFP_KERNEL); if (!port) goto err_put; diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index 6b5561c54e2f..37938e6903ef 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c @@ -816,7 +816,7 @@ int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter) char name[DEBUG_MAX_NAME_LEN]; struct zfcp_dbf *dbf; - dbf = kzalloc(sizeof(struct zfcp_dbf), GFP_KERNEL); + dbf = kzalloc_obj(struct zfcp_dbf, GFP_KERNEL); if (!dbf) return -ENOMEM; diff --git a/drivers/s390/scsi/zfcp_diag.c b/drivers/s390/scsi/zfcp_diag.c index 4d2d89d9c15a..e8c9077b4e96 100644 --- a/drivers/s390/scsi/zfcp_diag.c +++ b/drivers/s390/scsi/zfcp_diag.c @@ -36,7 +36,7 @@ int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter) struct zfcp_diag_adapter *diag; struct zfcp_diag_header *hdr; - diag = kzalloc(sizeof(*diag), GFP_KERNEL); + diag = kzalloc_obj(*diag, GFP_KERNEL); if (diag == NULL) return -ENOMEM; diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index 78ca394e1195..c212ca0924f8 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c @@ -128,7 +128,7 @@ void zfcp_fc_enqueue_event(struct zfcp_adapter *adapter, { struct zfcp_fc_event *event; - event = kmalloc(sizeof(struct zfcp_fc_event), GFP_ATOMIC); + event = kmalloc_obj(struct zfcp_fc_event, GFP_ATOMIC); if (!event) return; @@ -1116,7 +1116,7 @@ int zfcp_fc_gs_setup(struct zfcp_adapter *adapter) { struct zfcp_fc_wka_ports *wka_ports; - wka_ports = kzalloc(sizeof(struct zfcp_fc_wka_ports), GFP_KERNEL); + wka_ports = kzalloc_obj(struct zfcp_fc_wka_ports, GFP_KERNEL); if (!wka_ports) return -ENOMEM; diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 9418086368c3..d407f16e77ef 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -806,7 +806,7 @@ static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool) if (likely(pool)) req = mempool_alloc(pool, GFP_ATOMIC); else - req = kmalloc(sizeof(*req), GFP_ATOMIC); + req = kmalloc_obj(*req, GFP_ATOMIC); if (unlikely(!req)) return NULL; diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index e15a1eabe42d..3febefc80ccf 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c @@ -549,7 +549,7 @@ int zfcp_qdio_setup(struct zfcp_adapter *adapter) { struct zfcp_qdio *qdio; - qdio = kzalloc(sizeof(struct zfcp_qdio), GFP_KERNEL); + qdio = kzalloc_obj(struct zfcp_qdio, GFP_KERNEL); if (!qdio) return -ENOMEM; diff --git a/drivers/s390/scsi/zfcp_reqlist.h b/drivers/s390/scsi/zfcp_reqlist.h index 59fbb1b128cb..2037424f9981 100644 --- a/drivers/s390/scsi/zfcp_reqlist.h +++ b/drivers/s390/scsi/zfcp_reqlist.h @@ -42,7 +42,7 @@ static inline struct zfcp_reqlist *zfcp_reqlist_alloc(void) size_t i; struct zfcp_reqlist *rl; - rl = kzalloc(sizeof(struct zfcp_reqlist), GFP_KERNEL); + rl = kzalloc_obj(struct zfcp_reqlist, GFP_KERNEL); if (!rl) return NULL; diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 634bd8dceedd..f78df15b384a 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -542,7 +542,7 @@ zfcp_scsi_init_fc_host_stats(struct zfcp_adapter *adapter) struct fc_host_statistics *fc_stats; if (!adapter->fc_stats) { - fc_stats = kmalloc(sizeof(*fc_stats), GFP_KERNEL); + fc_stats = kmalloc_obj(*fc_stats, GFP_KERNEL); if (!fc_stats) return NULL; adapter->fc_stats = fc_stats; /* freed in adapter_release */ @@ -622,7 +622,7 @@ zfcp_scsi_get_fc_host_stats(struct Scsi_Host *host) if (!fc_stats) return NULL; - data = kzalloc(sizeof(*data), GFP_KERNEL); + data = kzalloc_obj(*data, GFP_KERNEL); if (!data) return NULL; @@ -651,7 +651,7 @@ static void zfcp_scsi_reset_fc_host_stats(struct Scsi_Host *shost) int ret; adapter = (struct zfcp_adapter *)shost->hostdata[0]; - data = kzalloc(sizeof(*data), GFP_KERNEL); + data = kzalloc_obj(*data, GFP_KERNEL); if (!data) return; diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 10a3840b2b6b..33ea87286c35 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -708,7 +708,7 @@ static ssize_t zfcp_sysfs_adapter_util_show(struct device *dev, if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA)) return -EOPNOTSUPP; - qtcb_port = kzalloc(sizeof(struct fsf_qtcb_bottom_port), GFP_KERNEL); + qtcb_port = kzalloc_obj(struct fsf_qtcb_bottom_port, GFP_KERNEL); if (!qtcb_port) return -ENOMEM; @@ -733,8 +733,7 @@ static int zfcp_sysfs_adapter_ex_config(struct device *dev, if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA)) return -EOPNOTSUPP; - qtcb_config = kzalloc(sizeof(struct fsf_qtcb_bottom_config), - GFP_KERNEL); + qtcb_config = kzalloc_obj(struct fsf_qtcb_bottom_config, GFP_KERNEL); if (!qtcb_config) return -ENOMEM; diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c index 4ef2a635d34f..0f47643cd5d9 100644 --- a/drivers/s390/scsi/zfcp_unit.c +++ b/drivers/s390/scsi/zfcp_unit.c @@ -137,7 +137,7 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun) goto out; } - unit = kzalloc(sizeof(struct zfcp_unit), GFP_KERNEL); + unit = kzalloc_obj(struct zfcp_unit, GFP_KERNEL); if (!unit) { retval = -ENOMEM; goto out; |
