From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx> Subject: drm: atomic: use krealloc_array() Use the helper that checks for overflows internally instead of manually calculating the size of the new array. Link: https://lkml.kernel.org/r/20201109110654.12547-8-brgl@xxxxxxxx Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx> Acked-by: Daniel Vetter <daniel.vetter@xxxxxxxx> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: Borislav Petkov <bp@xxxxxxxxx> Cc: Borislav Petkov <bp@xxxxxxx> Cc: Christian Knig <christian.koenig@xxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: Daniel Vetter <daniel@xxxxxxxx> Cc: David Airlie <airlied@xxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Gustavo Padovan <gustavo@xxxxxxxxxxx> Cc: James Morse <james.morse@xxxxxxx> Cc: Jaroslav Kysela <perex@xxxxxxxx> Cc: Jason Wang <jasowang@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx> Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx> Cc: Maxime Ripard <mripard@xxxxxxxxxx> Cc: "Michael S . Tsirkin" <mst@xxxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: Robert Richter <rric@xxxxxxxxxx> Cc: Sumit Semwal <sumit.semwal@xxxxxxxxxx> Cc: Takashi Iwai <tiwai@xxxxxxxx> Cc: Takashi Iwai <tiwai@xxxxxxx> Cc: Thomas Zimmermann <tzimmermann@xxxxxxx> Cc: Tony Luck <tony.luck@xxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/drm_atomic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/drm_atomic.c~drm-atomic-use-krealloc_array +++ a/drivers/gpu/drm/drm_atomic.c @@ -960,7 +960,8 @@ drm_atomic_get_connector_state(struct dr struct __drm_connnectors_state *c; int alloc = max(index + 1, config->num_connector); - c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL); + c = krealloc_array(state->connectors, alloc, + sizeof(*state->connectors), GFP_KERNEL); if (!c) return ERR_PTR(-ENOMEM); _