Skip to contentSkip to conversation

bus: ti-sysc: Use 2-factor allocator arguments

PATCH In review Kees Cook 2 participants 5 messages Jun 18, 2018 – Jul 3, 2018 OMAP2+ support

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 bus: ti-sysc: Use 2-factor allocator arguments

This adjusts the allocator calls to use 2-factor argument call style, as done treewide already for improved defense against allocation overflows.

---
 drivers/bus/ti-sysc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/bus/ti-sysc.c +4 -4
index 1cc29629d238..80d60f43db56 100644
@@ -169,9 +169,9 @@ static int sysc_get_clocks(struct sysc *ddata)
 	const char *name;
 	int nr_fck = 0, nr_ick = 0, i, error = 0;
 
-	ddata->clock_roles = devm_kzalloc(ddata->dev,
-					  sizeof(*ddata->clock_roles) *
+	ddata->clock_roles = devm_kcalloc(ddata->dev,
 					  SYSC_MAX_CLOCKS,
+					  sizeof(*ddata->clock_roles),
 					  GFP_KERNEL);
 	if (!ddata->clock_roles)
 		return -ENOMEM;
@@ -200,8 +200,8 @@ static int sysc_get_clocks(struct sysc *ddata)
 		return -EINVAL;
 	}
 
-	ddata->clocks = devm_kzalloc(ddata->dev,
-				     sizeof(*ddata->clocks) * ddata->nr_clocks,
+	ddata->clocks = devm_kcalloc(ddata->dev,
+				     ddata->nr_clocks, sizeof(*ddata->clocks),
 				     GFP_KERNEL);
 	if (!ddata->clocks)
 		return -ENOMEM;
Signature · 6 lines
2.17.0


-- 
Kees Cook
Pixel Security
author
#1 lore raw
Quoted 4 lines · Kees Cook

This adjusts the allocator calls to use 2-factor argument call style, as done treewide already for improved defense against allocation overflows.

Friendly ping! :) This is the last 2-factor devm* allocation left in 4.18 to be fixed.

Thanks!

-Kees

Quoted 38 lines
---
 drivers/bus/ti-sysc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/bus/ti-sysc.c +4 -5
index 1cc29629d238..80d60f43db56 100644
@@ -169,9 +169,9 @@ static int sysc_get_clocks(struct sysc *ddata)
        const char *name;
        int nr_fck = 0, nr_ick = 0, i, error = 0;
 
-       ddata->clock_roles = devm_kzalloc(ddata->dev,
-                                         sizeof(*ddata->clock_roles) *
+       ddata->clock_roles = devm_kcalloc(ddata->dev,
                                          SYSC_MAX_CLOCKS,
+                                         sizeof(*ddata->clock_roles),
                                          GFP_KERNEL);
        if (!ddata->clock_roles)
                return -ENOMEM;
@@ -200,8 +200,8 @@ static int sysc_get_clocks(struct sysc *ddata)
                return -EINVAL;
        }
 
-       ddata->clocks = devm_kzalloc(ddata->dev,
-                                    sizeof(*ddata->clocks) * ddata->nr_clocks,
+       ddata->clocks = devm_kcalloc(ddata->dev,
+                                    ddata->nr_clocks, sizeof(*ddata->clocks),
                                     GFP_KERNEL);
        if (!ddata->clocks)
                return -ENOMEM;
--

2.17.0

--
Kees Cook
Pixel Security

Signature · 2 lines
Kees Cook
Pixel Security
maintainer
#2 lore raw
Quoted 8 lines · Kees Cook
Quoted 4 lines · Kees Cook

This adjusts the allocator calls to use 2-factor argument call style, as done treewide already for improved defense against allocation overflows.

Friendly ping! :) This is the last 2-factor devm* allocation left in 4.18 to be fixed.

Sorry for the delay on this one. As we're already at -rc3, I'll apply this into omap-for-v4.19/ti-sysc. Seems there should not be need to rush this into v4.18-rc cycle, but please do let me know if that is not the case.

Regards,

Tony

author
#3 lore raw
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Kees Cook
Quoted 4 lines · Kees Cook

This adjusts the allocator calls to use 2-factor argument call style, as done treewide already for improved defense against allocation overflows.

Quoted 7 lines
Quoted 2 lines

Friendly ping! :) This is the last 2-factor devm* allocation left in 4.18 to be fixed.

Sorry for the delay on this one. As we're already at -rc3, I'll apply this into omap-for-v4.19/ti-sysc. Seems there should not be need to rush this into v4.18-rc cycle, but please do let me know if that is not the case.

I'd like to be able to reason about multiplication vs allocator uses in 4.18 and later. Since all other allocators got fixed in 4.18, I'd really like to have this one fixed too, then the scripts that check for multiplications in single-argument allocators will run clean for 4.18.

So, it's not strictly a "rush", but it would be appreciated. :)

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
maintainer
#4 lore raw
Quoted 16 lines · Kees Cook
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Kees Cook
Quoted 4 lines · Kees Cook

This adjusts the allocator calls to use 2-factor argument call style, as done treewide already for improved defense against allocation overflows.

Quoted 7 lines
Quoted 2 lines

Friendly ping! :) This is the last 2-factor devm* allocation left in 4.18 to be fixed.

Sorry for the delay on this one. As we're already at -rc3, I'll apply this into omap-for-v4.19/ti-sysc. Seems there should not be need to rush this into v4.18-rc cycle, but please do let me know if that is not the case.

Quoted 7 lines

I'd like to be able to reason about multiplication vs allocator uses in 4.18 and later. Since all other allocators got fixed in 4.18, I'd really like to have this one fixed too, then the scripts that check for multiplications in single-argument allocators will run clean for 4.18.

So, it's not strictly a "rush", but it would be appreciated. :)

OK I'll merge that commit also into omap-for-v4.18/fixes branch too.

Regards,

Tony