From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C8757CA1007 for ; Tue, 2 Sep 2025 19:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9pDO3CiZDcgl6FpTMD0qpu93FtQQ0Hu54ZUk55r1Ur4=; b=nwXgt3yCfHSXGAuDtp66py/TYV gzBFvwyQnfTb0Q8+mmuTu0Ht76odGICgkXTnYFwFD1pf/bYr0RsR5rXnYHyEQ24yaep6LOofVp61i P2+canjs4lDyZnUgA+tIjuCxxPe/DjBFpQehi8J2mSLWyzYyblVCeUzIX9LuWyoVtAxHpf03u+Ajk uUsQBsn9mUy2XDuTCvSEUwc0qqeC4sFTF9jq3fc1BZxFSWTyBNnyvYdDN1C/aT3VgDSZMYOS8AH+i WJHwcPv9KNKPqSc0+CpuTXaClUvieQM448SEQHQZUe5qKt9hLDKsO2ooJckdotLXNJmNhuMF8bt45 UY9nvzIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1utWNg-00000001ZFo-1rlg; Tue, 02 Sep 2025 19:09:24 +0000 Received: from mgamail.intel.com ([192.198.163.18]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1utQmF-0000000HXZ4-0yLZ; Tue, 02 Sep 2025 13:10:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1756818623; x=1788354623; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=1LweHExYhd8TIGAtsNsPF1dVuZ9HmUdwiz8regfEmyY=; b=SLCOT4T5qLpZpZl7fHQyAljcIndFmagyl8OX5Jd/6deJ9FphAMxNHgFv J68jHmg6azBtxFzZWvE8Omf45+esXU+nDASf4a3i5mpDmtwmgnMnxqmyk ao+286l9BjMIBqG/w21l4WVZvLOQVYMHnDEV8pz7bKy1i/DqRNapFdz/Q zivN0cZm79POIPgf4bX9ArvKNZO/vZ4jvEBYpTcEEIyfQ8jPhrrSP1QLE fFdP5U1G5+ks5tnek4yttZmuPvRD3cUen04iYd3MnLqg1ZYoYyyMlXJZG 59eTBHRFwCKjq3pS2yV1xHv42Mjdp6WLfT5Omjiy8AOSg5gLWD3WsyPz9 A==; X-CSE-ConnectionGUID: 4BEGNVarR/uZCecgnZbUKQ== X-CSE-MsgGUID: NAQSTTQQSD++MxJIy4b8Fw== X-IronPort-AV: E=McAfee;i="6800,10657,11541"; a="58296874" X-IronPort-AV: E=Sophos;i="6.18,230,1751266800"; d="scan'208";a="58296874" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2025 06:10:21 -0700 X-CSE-ConnectionGUID: ABQ3ZIn+Qu67Yn1YR+Rhyg== X-CSE-MsgGUID: rodiyp3KRASXPRSRymwAzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,230,1751266800"; d="scan'208";a="175651755" Received: from smile.fi.intel.com ([10.237.72.52]) by fmviesa005.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2025 06:10:12 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98.2) (envelope-from ) id 1utQlz-0000000AhRr-2lqG; Tue, 02 Sep 2025 16:10:07 +0300 Date: Tue, 2 Sep 2025 16:10:07 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , Bjorn Andersson , Konrad Dybcio , Alexey Klimov , Lorenzo Bianconi , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Paul Cercueil , Kees Cook , Andy Shevchenko , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , NXP S32 Linux Team , Sascha Hauer , Tony Lindgren , Haojian Zhuang , Geert Uytterhoeven , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Neil Armstrong , Mark Brown , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v7 08/16] pinctrl: keembay: release allocated memory in detach path Message-ID: References: <20250902-pinctrl-gpio-pinfuncs-v7-0-bb091daedc52@linaro.org> <20250902-pinctrl-gpio-pinfuncs-v7-8-bb091daedc52@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250902-pinctrl-gpio-pinfuncs-v7-8-bb091daedc52@linaro.org> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250902_061023_293031_C00F48F2 X-CRM114-Status: GOOD ( 17.23 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Tue, Sep 02, 2025 at 01:59:17PM +0200, Bartosz Golaszewski wrote: > > Unlike all the other allocations in this driver, the memory for storing > the pin function descriptions allocated with kcalloc() and later resized > with krealloc() is never freed. Use devres like elsewhere to handle > that. While at it - replace krealloc() with more suitable > devm_krealloc_array(). With that in mind... > Note: the logic in this module is pretty convoluted and could probably > use some revisiting, we should probably be able to calculate the exact > amount of memory needed in advance or even skip the allocation > altogether and just add each function to the radix tree separately. ... > Tested-by: Neil Armstrong This tag is not applicable to all patches, I do not believe this has been tested. ... > - keembay_funcs = kcalloc(kpc->npins * 8, sizeof(*keembay_funcs), GFP_KERNEL); > + keembay_funcs = devm_kcalloc(kpc->dev, kpc->npins * 8, ...switching to size_mul() also adds more robustness against too big npins values. > + sizeof(*keembay_funcs), GFP_KERNEL); -- With Best Regards, Andy Shevchenko