The drm_atomic_get_connector_state() function grows the connectors array with krealloc_array() when the requested connector index exceeds the current allocation, then zeroes the new entries with a separate memset() call.
Since krealloc_array() supports the __GFP_ZERO flag to zero newly allocated memory, the explicit memset() is unnecessary. 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 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 43b58e9b25e4..80436adcfb7f 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1388,18 +1388,15 @@ drm_atomic_get_connector_state(struct drm_atomic_commit *state, if (index >= state->num_connector) { struct __drm_connnectors_state *c; int alloc = max(index + 1, config->num_connector); c = krealloc_array(state->connectors, alloc, - sizeof(*state->connectors), GFP_KERNEL); + sizeof(*state->connectors), GFP_KERNEL | __GFP_ZERO); if (!c) return ERR_PTR(-ENOMEM); state->connectors = c; - memset(&state->connectors[state->num_connector], 0, - sizeof(*state->connectors) * (alloc - state->num_connector)); - state->num_connector = alloc; } connector_state = drm_atomic_get_new_connector_state(state, connector); if (connector_state) -- 2.55.0
