summaryrefslogtreecommitdiff
path: root/drivers/scsi/device_handler
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 /drivers/scsi/device_handler
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 'drivers/scsi/device_handler')
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c6
-rw-r--r--drivers/scsi/device_handler/scsi_dh_emc.c2
-rw-r--r--drivers/scsi/device_handler/scsi_dh_hp_sw.c2
-rw-r--r--drivers/scsi/device_handler/scsi_dh_rdac.c6
4 files changed, 8 insertions, 8 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 6fd89ae33059..842476f131fd 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -219,7 +219,7 @@ static struct alua_port_group *alua_alloc_pg(struct scsi_device *sdev,
{
struct alua_port_group *pg, *tmp_pg;
- pg = kzalloc(sizeof(struct alua_port_group), GFP_KERNEL);
+ pg = kzalloc_obj(struct alua_port_group, GFP_KERNEL);
if (!pg)
return ERR_PTR(-ENOMEM);
@@ -1137,7 +1137,7 @@ static int alua_activate(struct scsi_device *sdev,
struct alua_queue_data *qdata;
struct alua_port_group *pg;
- qdata = kzalloc(sizeof(*qdata), GFP_KERNEL);
+ qdata = kzalloc_obj(*qdata, GFP_KERNEL);
if (!qdata) {
err = SCSI_DH_RES_TEMP_UNAVAIL;
goto out;
@@ -1239,7 +1239,7 @@ static int alua_bus_attach(struct scsi_device *sdev)
struct alua_dh_data *h;
int err;
- h = kzalloc(sizeof(*h) , GFP_KERNEL);
+ h = kzalloc_obj(*h, GFP_KERNEL);
if (!h)
return SCSI_DH_NOMEM;
spin_lock_init(&h->pg_lock);
diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c
index 3cf88db2d5b2..5a2f6f09de07 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -478,7 +478,7 @@ static int clariion_bus_attach(struct scsi_device *sdev)
struct clariion_dh_data *h;
int err;
- h = kzalloc(sizeof(*h) , GFP_KERNEL);
+ h = kzalloc_obj(*h, GFP_KERNEL);
if (!h)
return SCSI_DH_NOMEM;
h->lun_state = CLARIION_LUN_UNINITIALIZED;
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index b6eaf49dfb00..36d877afff4b 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -226,7 +226,7 @@ static int hp_sw_bus_attach(struct scsi_device *sdev)
struct hp_sw_dh_data *h;
int ret;
- h = kzalloc(sizeof(*h), GFP_KERNEL);
+ h = kzalloc_obj(*h, GFP_KERNEL);
if (!h)
return SCSI_DH_NOMEM;
h->path_state = HP_SW_PATH_UNINITIALIZED;
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 6e1b252cea0e..088dc509d505 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -336,7 +336,7 @@ static struct rdac_controller *get_controller(int index, char *array_name,
return tmp;
}
}
- ctlr = kmalloc(sizeof(*ctlr), GFP_ATOMIC);
+ ctlr = kmalloc_obj(*ctlr, GFP_ATOMIC);
if (!ctlr)
return NULL;
@@ -601,7 +601,7 @@ static int queue_mode_select(struct scsi_device *sdev,
struct rdac_queue_data *qdata;
struct rdac_controller *ctlr;
- qdata = kzalloc(sizeof(*qdata), GFP_KERNEL);
+ qdata = kzalloc_obj(*qdata, GFP_KERNEL);
if (!qdata)
return SCSI_DH_RETRY;
@@ -741,7 +741,7 @@ static int rdac_bus_attach(struct scsi_device *sdev)
char array_name[ARRAY_LABEL_LEN];
char array_id[UNIQUE_ID_LEN];
- h = kzalloc(sizeof(*h) , GFP_KERNEL);
+ h = kzalloc_obj(*h, GFP_KERNEL);
if (!h)
return SCSI_DH_NOMEM;
h->lun = UNINITIALIZED_LUN;