[PATCH v2] drm/i915/gt: Use kmemdup_array instead of kmemdup for multiple allocation

Lucas De Marchi lucas.demarchi at intel.com
Tue Aug 20 12:53:10 UTC 2024


On Tue, Aug 20, 2024 at 05:53:02PM GMT, Yu Jiaoliang wrote:
>Let the kememdup_array() take care about multiplication and possible
>overflows.
>
>v2:
>- Change subject
>- Leave one blank line between the commit log and the tag section
>- Fix code alignment issue
>
>Signed-off-by: Yu Jiaoliang <yujiaoliang at vivo.com>
>Reviewed-by: Jani Nikula <jani.nikula at intel.com>
>Reviewed-by: Andi Shyti <andi.shyti at linux.intel.com>
>---
> drivers/gpu/drm/i915/gt/intel_workarounds.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
>index d90348c56765..0fcfd55c62b4 100644
>--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
>+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
>@@ -111,9 +111,8 @@ static void wa_init_finish(struct i915_wa_list *wal)
> {
> 	/* Trim unused entries. */
> 	if (!IS_ALIGNED(wal->count, WA_LIST_CHUNK)) {
>-		struct i915_wa *list = kmemdup_array(wal->list,

					^

it was already kmemdup_array, not kmemdup. Am I missing anything?

Lucas De Marchi

>-					       wal->count, sizeof(*list),
>-					       GFP_KERNEL);
>+		struct i915_wa *list = kmemdup_array(wal->list, wal->count,
>+											 sizeof(*list), GFP_KERNEL);
>
> 		if (list) {
> 			kfree(wal->list);
>-- 
>2.34.1
>


More information about the Intel-gfx mailing list