From patchwork Tue Oct 27 12:17:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11860221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77769C5DF9D for ; Tue, 27 Oct 2020 12:18:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 335A122202 for ; Tue, 27 Oct 2020 12:18:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="uINaxail" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750967AbgJ0MSE (ORCPT ); Tue, 27 Oct 2020 08:18:04 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35639 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbgJ0MRz (ORCPT ); Tue, 27 Oct 2020 08:17:55 -0400 Received: by mail-wm1-f66.google.com with SMTP id h22so1205669wmb.0 for ; Tue, 27 Oct 2020 05:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nNS5tvBpA/i0H7p7l8m9y8bW5QzwJCcb9cwqd3juySc=; b=uINaxail9sUfALoEWstn2csJR9jE7v9clDsZtLcLiOMSXg2LAVFIQqN6lHKyyZUd4l jRiwMGMG4DxMFJH69rSCLOtob+027D28VPhBQtpIrjKA/W5lb5Kv+7Q+cjTTcQNW8hxv wUoV9A8I84g3amtYBnRWsQ9zCBUoSUYIxS8yqik5kvDE0D17HbZwhUPBEWV0xwo4eSQB xtGlMRrIXAwBsMOZYueqppFbh9JQaNXeAayhSnZZJNrW9nmKvVAevDfxEiP//pXPGQn7 22ZoAAwvkiz2v+dHQuQfEfVqcnXh5D2KeVL1FBqvTUVKMuvl7wX7b6wRp1orV+Uuzzwn SgBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nNS5tvBpA/i0H7p7l8m9y8bW5QzwJCcb9cwqd3juySc=; b=NT9619E8bEaQdrVMUQV3KOCC2hHo55mGifUnztu7mrO4N0vSbXaY5fQ3aU4R1vr4fw xdMTi/0BIguQwgCJd+NKHFdjXnuv3TRg7ACaN3fHYuBawemXlSOlzHA3/hhp/z0/+L9+ duV/XGzFPD7sto8QMb+oro6tMGoAEM8IymsuM5cIL+EHOBQ+IliSbMxonE5QABJOFlph Yy4XPZWD6HOKERpuN7cfwLMP5n076xMYZCu/8HK7U3kXmd7mdGogaWlLaVMxi58UHRAK Y7xpxCupEAbAGr5t+u6Nd3x8jAf5ab0OIKjReTCvShtDXtz/p4X/B5HL2R1ueucOFqZ4 2YNQ== X-Gm-Message-State: AOAM530TWIOW+Jcrprview7+0HINHJIWXwukn9QObHIc36idEPbHOyBd JGAs/GjXJe/JegPqgej0KW0PGQ== X-Google-Smtp-Source: ABdhPJwlnp8d7/fOEkypkqwExUCmIl2RKP9vSFIY6Z3TXZuynGv+gQ6ZzaCTjRN4xR7i9/EdKZccow== X-Received: by 2002:a1c:28d4:: with SMTP id o203mr2460319wmo.143.1603801072719; Tue, 27 Oct 2020 05:17:52 -0700 (PDT) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id a2sm1731908wrs.55.2020.10.27.05.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 05:17:51 -0700 (PDT) From: Bartosz Golaszewski To: Andy Shevchenko , Sumit Semwal , Gustavo Padovan , =?utf-8?q?Christian_K=C3=B6nig?= , Mauro Carvalho Chehab , Borislav Petkov , Tony Luck , James Morse , Robert Richter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Alexander Shishkin , Linus Walleij , "Michael S . Tsirkin" , Jason Wang , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Jaroslav Kysela , Takashi Iwai Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-gpio@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-mm@kvack.org, alsa-devel@alsa-project.org, Bartosz Golaszewski Subject: [PATCH 8/8] dma-buf: use krealloc_array() Date: Tue, 27 Oct 2020 13:17:25 +0100 Message-Id: <20201027121725.24660-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027121725.24660-1-brgl@bgdev.pl> References: <20201027121725.24660-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Bartosz Golaszewski Use the helper that checks for overflows internally instead of manually calculating the size of the new array. Signed-off-by: Bartosz Golaszewski Acked-by: Christian König --- drivers/dma-buf/sync_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c index 5a5a1da01a00..2925ea03eef0 100644 --- a/drivers/dma-buf/sync_file.c +++ b/drivers/dma-buf/sync_file.c @@ -270,8 +270,8 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, fences[i++] = dma_fence_get(a_fences[0]); if (num_fences > i) { - nfences = krealloc(fences, i * sizeof(*fences), - GFP_KERNEL); + nfences = krealloc_array(fences, i, + sizeof(*fences), GFP_KERNEL); if (!nfences) goto err;