Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3817861pxa; Sun, 9 Aug 2020 12:46:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1vzQVORqSQqYEIElSyfZtrlClQxgr99D26HgaeksfORdh6JNDu33XkOMtuNUjFlzqpoZN X-Received: by 2002:aa7:c30b:: with SMTP id l11mr17981631edq.253.1597002386535; Sun, 09 Aug 2020 12:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597002386; cv=none; d=google.com; s=arc-20160816; b=etaEnN/YefbVJjtBM2U8Jmk6ZBLq5Hw20KHqQNf5LYtEEKOflrCt76TMZMbv9NFjGt gKlZMToDdSVV+qPGYYD0QpQehAHQpoG7B2mEsayOcuahyN5NIcq9e/CyaUYgaG6L7Eom +VSKe4+RNhOx+kKwzzKJpwr4UlH6XU7dIUklp55rvmmGdFqvqZULrET8ZNT+S9Qkpi3Q 3M+QbWtkVDQtH6mt7pQnsiIoCdmQD5+ch4RA32BeVCSB3t3neysyo5srLWs1A26up2EG ivm3yam68DgLZ69pqCxLPxfOfVjUpfY7I/0MZpTrT5/HJfAgA87B1Qpu1OpGWTU/1pVs jblA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=4szbnufHQF2HK5pviSPitVDKxjvvCLZrgBO3PzVaDDg=; b=rZRK4NHBc3+N+nTSeH04kvVprTG2kAdOo+4fRt3j2y9fhb3Ts/DblzWAs6KzqtS8mI gJkFoDUMNUnMH5pJHN98cLvPxgq0U8NvRSzkc5BafVlyFTr36eUsrs0FM0VwILc5c0iS pMBVisXE8sAelDaz9c3HyYRsjcFh/CISXIp7GWJlY+Izam1jFs1FA/XLhaTl/tYz9+jc T/s3KhwRyBc+eaSxa8whpOfqPFMoTKjXg8CDDK21lnx68cdef1UH7sUjlorKYikLUymc 1JxDLZo7Fs1LsbSIeOhQxARkBQLLDCxn8jDGnbGfdA+5Campdg1BdYkmRB4Al0wTGTmc MG7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SbLG+4ED; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox17si9723776ejb.241.2020.08.09.12.46.02; Sun, 09 Aug 2020 12:46:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SbLG+4ED; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgHITo3 (ORCPT + 99 others); Sun, 9 Aug 2020 15:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726242AbgHITo3 (ORCPT ); Sun, 9 Aug 2020 15:44:29 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B432DC061756 for ; Sun, 9 Aug 2020 12:44:28 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id t23so7378942ljc.3 for ; Sun, 09 Aug 2020 12:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4szbnufHQF2HK5pviSPitVDKxjvvCLZrgBO3PzVaDDg=; b=SbLG+4EDjGYXnzmZ7ginX4OdN5TAAOvQz1lG3gmnuLEugh5tiQpVasccdKer+S98HD NYd9f/ugN33J3Af9QOweklnnOJK63L6FEL2ygafhM/UE9ADudllLRwx0LiIYhNPhWI2Z Pr3twaBP8dOI0BNYuuPQ6X3vvlvPFwhpZu5jxeHJdOT9RxOms9TtBjFImfw/wrdEUalD QNdQfrJJpm9E6g6OHx/ddXW6WsJ98nbCTvCvMa2gQ9Joy91/DQbtD6Mmt/ljN49IJKpi G0nsk0PTvIlJvliuwfTBbgI8gKvpQC6qroJ49alIbdche1xbrIbJSNWVcXJVm/5ntIL6 v7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4szbnufHQF2HK5pviSPitVDKxjvvCLZrgBO3PzVaDDg=; b=p4BsX/wS/Em2uBUOEPueNr4dy6ZrC7bU5JcM3fAmv2sYeLtO7kpYsPsLf8dVwrYCnh Hd286pc9natyhLUvSRNiFCYD45d4Qprz7pglg+ZvBFHljRT6fwrZFJvR6T0YAhTcPLjG SWPuxesVIQlWOD01qclPYbO8rFjZPbjCxozt09GG+lWt98eJ69nAl1qN4t4GEkBisAFY tySIH0xCj/ut5wXzwlNbGAyCMgxtiNhX7FcREmCFtYu9aHIbfsYx7wH9wuLzQEVdOqZe m8h+gwrWIjXVIKL8ltRMfSVAJdXLXf6N11852niUJK42PuR2jMqz0BGG3Z04JsPB8gYW x+Lg== X-Gm-Message-State: AOAM530Yi59oXaNEb7UiQEItYvc23EXlBY4AfUUwAVevvHOM7J2WQyeP yUbr+3l0QiDjvzKUWapYM71EpAI9 X-Received: by 2002:a2e:9c59:: with SMTP id t25mr10418764ljj.402.1597002266869; Sun, 09 Aug 2020 12:44:26 -0700 (PDT) Received: from [192.168.2.145] (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.googlemail.com with ESMTPSA id z20sm8238087ljk.97.2020.08.09.12.44.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Aug 2020 12:44:26 -0700 (PDT) Subject: Re: [PATCH] regulator: fix pointer table overallocation To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org References: <407fbd06a02caf038a9ba3baa51c7d6d47cd6517.1597000795.git.mirq-linux@rere.qmqm.pl> From: Dmitry Osipenko Message-ID: <5ef51b56-c533-46c8-621d-7907129594e9@gmail.com> Date: Sun, 9 Aug 2020 22:44:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <407fbd06a02caf038a9ba3baa51c7d6d47cd6517.1597000795.git.mirq-linux@rere.qmqm.pl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 09.08.2020 22:21, Michał Mirosław пишет: > The code allocates sizeof(regulator_dev) for a pointer. Make it less > generous. Let kcalloc() calculate the size, while at it. > > Cc: stable@vger.kernel.org > Fixes: d8ca7d184b33 ("regulator: core: Introduce API for regulators coupling customization") > Signed-off-by: Michał Mirosław > --- > drivers/regulator/core.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c > index 75ff7c563c5d..9e18997777d3 100644 > --- a/drivers/regulator/core.c > +++ b/drivers/regulator/core.c > @@ -5011,20 +5011,20 @@ static void regulator_remove_coupling(struct regulator_dev *rdev) > > static int regulator_init_coupling(struct regulator_dev *rdev) > { > + struct regulator_dev **coupled; > int err, n_phandles; > - size_t alloc_size; > > if (!IS_ENABLED(CONFIG_OF)) > n_phandles = 0; > else > n_phandles = of_get_n_coupled(rdev); > > - alloc_size = sizeof(*rdev) * (n_phandles + 1); > - > - rdev->coupling_desc.coupled_rdevs = kzalloc(alloc_size, GFP_KERNEL); > - if (!rdev->coupling_desc.coupled_rdevs) > + coupled = kcalloc(n_phandles + 1, sizeof(*coupled), GFP_KERNEL); > + if (!coupled) > return -ENOMEM; > > + rdev->coupling_desc.coupled_rdevs = coupled; > + > /* > * Every regulator should always have coupling descriptor filled with > * at least pointer to itself. > Hello, Michał! Thank you for the patch! Not sure whether it's worthwhile to backport this change since it's an improvement, I'll leave it to Mark to decide, otherwise looks good to me. Reviewed-by: Dmitry Osipenko