mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
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>
This commit is contained in:
@@ -446,25 +446,25 @@ static int amdgpu_pmu_alloc_pmu_attrs(
|
||||
struct amdgpu_pmu_event_attribute **evt_attr,
|
||||
struct amdgpu_pmu_config *config)
|
||||
{
|
||||
*fmt_attr = kcalloc(config->num_formats, sizeof(**fmt_attr),
|
||||
GFP_KERNEL);
|
||||
*fmt_attr = kzalloc_objs(**fmt_attr, config->num_formats, GFP_KERNEL);
|
||||
|
||||
if (!(*fmt_attr))
|
||||
return -ENOMEM;
|
||||
|
||||
fmt_attr_group->attrs = kcalloc(config->num_formats + 1,
|
||||
sizeof(*fmt_attr_group->attrs), GFP_KERNEL);
|
||||
fmt_attr_group->attrs = kzalloc_objs(*fmt_attr_group->attrs,
|
||||
config->num_formats + 1,
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!fmt_attr_group->attrs)
|
||||
goto err_fmt_attr_grp;
|
||||
|
||||
*evt_attr = kcalloc(config->num_events, sizeof(**evt_attr), GFP_KERNEL);
|
||||
*evt_attr = kzalloc_objs(**evt_attr, config->num_events, GFP_KERNEL);
|
||||
|
||||
if (!(*evt_attr))
|
||||
goto err_evt_attr;
|
||||
|
||||
evt_attr_group->attrs = kcalloc(config->num_events + 1,
|
||||
sizeof(*evt_attr_group->attrs), GFP_KERNEL);
|
||||
evt_attr_group->attrs = kzalloc_objs(*evt_attr_group->attrs,
|
||||
config->num_events + 1, GFP_KERNEL);
|
||||
|
||||
if (!evt_attr_group->attrs)
|
||||
goto err_evt_attr_grp;
|
||||
@@ -599,7 +599,7 @@ static struct amdgpu_pmu_entry *create_pmu_entry(struct amdgpu_device *adev,
|
||||
{
|
||||
struct amdgpu_pmu_entry *pmu_entry;
|
||||
|
||||
pmu_entry = kzalloc(sizeof(struct amdgpu_pmu_entry), GFP_KERNEL);
|
||||
pmu_entry = kzalloc_obj(struct amdgpu_pmu_entry, GFP_KERNEL);
|
||||
|
||||
if (!pmu_entry)
|
||||
return pmu_entry;
|
||||
|
||||
Reference in New Issue
Block a user