The drm_atomic_get_private_obj_state() function allocates a new entry in the private_objs array using krealloc_array(), then zeroes the new entry with a separate memset() call.
However, since krealloc_array() already supports the __GFP_ZERO flag to zero newly allocated memory, the explicit memset() is redundant. Pass __GFP_ZERO to krealloc_array() and drop the manual memset(). Suggested-by: Thomas Zimmermann <[email protected]> Reviewed-by: Daniel Stone <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> --- drivers/gpu/drm/drm_atomic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index aa47c647df31..43b58e9b25e4 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1093,17 +1093,16 @@ drm_atomic_get_private_obj_state(struct drm_atomic_commit *state, if (ret) return ERR_PTR(ret); num_objs = state->num_private_objs + 1; arr = krealloc_array(state->private_objs, num_objs, - sizeof(*state->private_objs), GFP_KERNEL); + sizeof(*state->private_objs), GFP_KERNEL | __GFP_ZERO); if (!arr) return ERR_PTR(-ENOMEM); state->private_objs = arr; index = state->num_private_objs; - memset(&state->private_objs[index], 0, sizeof(*state->private_objs)); obj_state = obj->funcs->atomic_duplicate_state(obj); if (!obj_state) return ERR_PTR(-ENOMEM); -- 2.55.0
