drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Let the kememdup_array() take care about multiplication and possible
overflows.
Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
---
drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index 09a287c1aedd..d90348c56765 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -111,8 +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(wal->list,
- wal->count * sizeof(*list),
+ struct i915_wa *list = kmemdup_array(wal->list,
+ wal->count, sizeof(*list),
GFP_KERNEL);
if (list) {
--
2.34.1
Hi Yi,
Please, next time check with "git drivers/gpu/drm/i915/gt" to
better understand the patch formatting.
The title should be something like:
drm/i915/gt: Switch to use kmemdup_array()
But sounds more grammatically correct
drm/i915/gt: Use kmemdup_array instead of kmemdup for multiple allocation
On Tue, Aug 20, 2024 at 03:45:03PM +0800, Yu Jiaoliang wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
Leave one blank line between the commit log and the tag section
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> ---
> drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> index 09a287c1aedd..d90348c56765 100644
> --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
> +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> @@ -111,8 +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(wal->list,
> - wal->count * sizeof(*list),
> + struct i915_wa *list = kmemdup_array(wal->list,
> + wal->count, sizeof(*list),
> GFP_KERNEL);
Here you are not aligning correctly. Everything should be aligned
to one character after the open parenthesis; for example:
struct i915_wa *list = kmemdup_array(wal->list, wal->count,
sizeof(*list), GFP_KERNEL);
Patch is good, though looking forward to receiving v2.
Thanks,
Andi
>
> if (list) {
> --
> 2.34.1
On Tue, 20 Aug 2024, Yu Jiaoliang <yujiaoliang@vivo.com> wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
For future reference, please look at git log for the file instead of
inventing subject prefixes.
There should be a blank line between commit message and trailers.
Other than that,
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> index 09a287c1aedd..d90348c56765 100644
> --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
> +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> @@ -111,8 +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(wal->list,
> - wal->count * sizeof(*list),
> + struct i915_wa *list = kmemdup_array(wal->list,
> + wal->count, sizeof(*list),
> GFP_KERNEL);
>
> if (list) {
--
Jani Nikula, Intel
© 2016 - 2026 Red Hat, Inc.