Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2198242iof; Tue, 7 Jun 2022 22:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXcro5A8FatfdFmZr4SWS3cCssxP97r3ugK4+VhgsADpM9RlcjYisSBLR9Id5mDvkFe6YC X-Received: by 2002:a17:90a:1911:b0:1df:b08a:e252 with SMTP id 17-20020a17090a191100b001dfb08ae252mr70683938pjg.215.1654667902400; Tue, 07 Jun 2022 22:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667902; cv=none; d=google.com; s=arc-20160816; b=fDbF30qotiAEu8Eqc58K0vI0gKrQRF7igp7JS8Op4ftVkhF7H5JA9rJ0s3ZOkhHcTe IcZt46WOwZldrUmqOcO2DQ6fOqQLQ5kSVUNVic/IIjY6N3KiJ/W7yp/jVupriDwPzdYo /VYRmH08/ZTMh2dwQIsGkBqNJuZZryY5xS+7CvSn+0hGMafVpgW2HmhzXrLrz/q452TR Q46Z2fHPBA7nHoXOMpogdY4T69ESLb+dS5z36H42SDVkxWQr9PwT5J6KMn4sd9KSAMkz ILy7JpKILdFUQhdApPzKs7KKeOrQJyYaaxySvIb9Jp/DZ4UZetKr1PkpRy9MSseueeEX /aYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3T7XTh1scC68xUXSx0xQHLF8ZUlOTDeg+1VTxctq9v4=; b=Bq/pcjELTpcsYm87rhrC5wjT15K0jBFLSzQxe0/fS51kEXmpQQtiHx+dhDOEqYDz2f 7MDjmlVtBtILMITJzfu6J2e97GdvojtIzrVUzTBwkKp9Z7/eM75aq+L30tdAP0I9DmZk dpySNsLAOzKiero+oUdQR02EQXp9mJ6Rda2aEiuH6TRySAoHpfT4sMaAIXts6A1jBQwe PfJlHipj/I4pQ/2rKq9OQKtvpcWtBMYdtyuTaeeY7PTtTcqL3EiENza018HL3sdQBu57 lRS0KN3mPJPqIFFnPQuX1jkYz7udsqM3uSAq6DnKo6uH31TO/rvKpH/gmuj1fkJYaKOA z87w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XTFHIP7F; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w17-20020a170902e89100b001620ad77764si19121682plg.522.2022.06.07.22.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:58:22 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XTFHIP7F; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3392147976E; Tue, 7 Jun 2022 22:27:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347917AbiFHBMl (ORCPT + 99 others); Tue, 7 Jun 2022 21:12:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382998AbiFGVwK (ORCPT ); Tue, 7 Jun 2022 17:52:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A7B7192270; Tue, 7 Jun 2022 12:10:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E06D6B8220B; Tue, 7 Jun 2022 19:10:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AB2AC385A5; Tue, 7 Jun 2022 19:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629011; bh=DHhMOTAVSHSY0j7O0/1UO25k14ku7/TFOBskDOIVeLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTFHIP7F9YqQxMJ436dE5mVc2bSN9hYO8rrVE6EwlSGj4iT75ZdlT2ge0jQbxjWiO uOaacoAc11OFFYtjJGxkSFoPSF1crYiFoIdG0I32jE0iCdReSLrCx0XVPiq2C9qHxD f8eReM6izaP63zn2Tc0CQLDJdCc4eHjanqCmC+XI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 5.18 536/879] memory: samsung: exynos5422-dmc: Avoid some over memory allocation Date: Tue, 7 Jun 2022 19:00:54 +0200 Message-Id: <20220607165018.430760211@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit 56653827f0d7bc7c2d8bac0e119fd1521fa9990a ] 'dmc->counter' is a 'struct devfreq_event_dev **', so there is some over memory allocation. 'counters_size' should be computed with 'sizeof(struct devfreq_event_dev *)'. Use 'sizeof(*dmc->counter)' instead to fix it. While at it, use devm_kcalloc() instead of devm_kzalloc()+open coded multiplication. Fixes: 6e7674c3c6df ("memory: Add DMC driver for Exynos5422") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/69d7e69346986e2fdb994d4382954c932f9f0993.1647760213.git.christophe.jaillet@wanadoo.fr Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin --- drivers/memory/samsung/exynos5422-dmc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/memory/samsung/exynos5422-dmc.c b/drivers/memory/samsung/exynos5422-dmc.c index 9c8318923ed0..4733e7898ffe 100644 --- a/drivers/memory/samsung/exynos5422-dmc.c +++ b/drivers/memory/samsung/exynos5422-dmc.c @@ -1322,7 +1322,6 @@ static int exynos5_dmc_init_clks(struct exynos5_dmc *dmc) */ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc) { - int counters_size; int ret, i; dmc->num_counters = devfreq_event_get_edev_count(dmc->dev, @@ -1332,8 +1331,8 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc) return dmc->num_counters; } - counters_size = sizeof(struct devfreq_event_dev) * dmc->num_counters; - dmc->counter = devm_kzalloc(dmc->dev, counters_size, GFP_KERNEL); + dmc->counter = devm_kcalloc(dmc->dev, dmc->num_counters, + sizeof(*dmc->counter), GFP_KERNEL); if (!dmc->counter) return -ENOMEM; -- 2.35.1