From patchwork Mon Jun 14 17:58:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12319585 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 C9853C2B9F4 for ; Mon, 14 Jun 2021 18:01:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 879F461055 for ; Mon, 14 Jun 2021 18:01:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 879F461055 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GjbUNV0re6+5QdWdzIEarQn++zAgRBYRrtBEx/7Yeqc=; b=sXRRQzW6dQRE3J zhbQLCoWUcBxQODROsjJogmCtQyTE8xFNmMbrFngSx0XHFd13c8J7Fd35GawRm/KdIIuLRqzhB19J 21rH/eYnqKklI3K/qzk0URjiI8MDRkXD9x9Z7hzlvztiri3QeCOZqYoJE3v6nDdp97s662QPLjpyV iXNgFBJCxTBcwfGYPXC5kMyBiFI2d/4SiHyVKq23YDKI9ipMmM8yC/ROWSj5obT8TtjVyxbbfZT/x eIQ8sAi60Y39PsfavBgoOQjaZa3eDCL70D3Lg58B6e6DQzfxrht5TzM0tf3Mv2sKp3dl/mlkogTp7 OmZeT1qm+Kekl40kfilA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsqru-00FZFC-J0; Mon, 14 Jun 2021 17:59:26 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsqra-00FZ9z-Du for linux-arm-kernel@lists.infradead.org; Mon, 14 Jun 2021 17:59:08 +0000 Received: by mail-pf1-x42d.google.com with SMTP id z26so11118703pfj.5 for ; Mon, 14 Jun 2021 10:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tiW1MiNSxVy/hCeNInIQyfBMYNNxInq9UWdM3u/5QaI=; b=BTx5vB111fZfaNJviKToWKnd3s085SfxYJXTUooAQV0xHMl9TbfFaXG4VR8AfuSzgj BWPxer2RaEEJ+iwNC9XrU7RJw/5KSoPmi99RIhsA3GPt1dmnhUYtKi9BS4RTqFQghI9x 8usC2nzVZF2a0LT9Q8OAg6wlladjM9iuBfLMpQlF8S+BKQ3TENgrpra6LFPAt10CAppz k7iP4hviN/s3Mh8Q/OGLsuSixDbulo5J58BbAzkD9GhqsMtkwq72HlkD1rFLdGzlt+zS SsjJuF8RNlZCLsG/8lEieAQeF2dI02L5tu84YT//cPi+JKtFjPAvJDtAVgz3ecrHGYF+ Xudw== 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=tiW1MiNSxVy/hCeNInIQyfBMYNNxInq9UWdM3u/5QaI=; b=owxIifsIn3bLRAuNdLwBnUy5GLzu6E9A0iuK2NWalS0Y97hD4BNwnIfSKiJV4klj5E f+WXCuG2twbQXQLw9IgbktbhCO8p6TrY+3GFPn4gdIE0EYSElPopR0uiPA2H84x82UXE Xr9yMlaX2UZkhQpf5pQe33viZnQbBMmZRbw0aH6pHNukeigQQwJLK0C+1VQvdXpX/JNT ZoHt2geSq/1on1Wp8Ze/kIt2PwZa4Q0b/0GSA0oNWO8bMd4sOR9HSyYH6RH4X0xwxV/K c92ciYCAPnZhKNSajNOF3m2Sdwcp6bfewZegUVFl+TMoSa5i9UmnGUYdgCD6djXnTD5G ExHg== X-Gm-Message-State: AOAM5321tFTeDCNq3yXLKIi0bGUTSaJ/t9fGrZM78Zjw9f6aPUL+y9U+ swa9kqP1tW/dwaYefcT/3BdpxPsbxuymLg== X-Google-Smtp-Source: ABdhPJxuMaCVSzChO1l5VDImulKblryLr0k3o+St1URwrnMhrEzuovCgBTMWXV99yMds5RoaHvKttg== X-Received: by 2002:a63:ed4d:: with SMTP id m13mr18329392pgk.433.1623693545242; Mon, 14 Jun 2021 10:59:05 -0700 (PDT) Received: from p14s.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id z17sm13553246pfq.218.2021.06.14.10.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:59:04 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] coresight: core: Switch to krealloc_array() Date: Mon, 14 Jun 2021 11:58:56 -0600 Message-Id: <20210614175901.532683-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614175901.532683-1-mathieu.poirier@linaro.org> References: <20210614175901.532683-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210614_105906_545830_986F5438 X-CRM114-Status: GOOD ( 12.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Andy Shevchenko Let the krealloc_array() check for multiplication overflow. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210520135041.56163-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 6c68d34d956e..a7971c68b0be 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1730,9 +1730,9 @@ char *coresight_alloc_device_name(struct coresight_dev_list *dict, if (idx < 0) { /* Make space for the new entry */ idx = dict->nr_idx; - list = krealloc(dict->fwnode_list, - (idx + 1) * sizeof(*dict->fwnode_list), - GFP_KERNEL); + list = krealloc_array(dict->fwnode_list, + idx + 1, sizeof(*dict->fwnode_list), + GFP_KERNEL); if (ZERO_OR_NULL_PTR(list)) { idx = -ENOMEM; goto done;