From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1E7A221540 for ; Mon, 26 Jan 2026 16:18:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769444324; cv=none; b=qZeP8hmkI9oZGCcSBhlmmUppkY230fwsUuQXJELjMFKmmogE5ufHg9JuSy6VTZfGsxdltTtPqaKDlSrmOEJE+kmXSPht8UOhyZbKDDqs8hncUqIInATLJvXYkRm8wmqE+rGmZnwjtnTp9P5c1eQS6D1n64LKkf0I0AdlWAXZJz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769444324; c=relaxed/simple; bh=C98OXKpJG/GaHUOc9JXkyOsZbJsLuK7ObbR8sDzNkcw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K/78r/0dDEgky+OiawRJqO3AYQBZcLSJXMvFLyoDqlYcFqTpE6B9UTEKIurbKkvDPwjynBX8fFq2bzPAYnPKDXlRY1x9uz2HBLTTSvWBcxaMyu6JRuQhWC/5n5T+t+TladFmc/Jkkzh1L429fjvUQ3eeeWB165aB8IQlwPr3vOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C773D339; Mon, 26 Jan 2026 08:18:35 -0800 (PST) Received: from localhost (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D38983F5CA; Mon, 26 Jan 2026 08:18:41 -0800 (PST) Date: Mon, 26 Jan 2026 16:18:39 +0000 From: Leo Yan To: Suzuki K Poulose Cc: Mike Leach , James Clark , Alexander Shishkin , Greg Kroah-Hartman , Mathieu Poirier , Mao Jinlong , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/8] coresight: Fix memory leak in coresight_alloc_device_name() Message-ID: <20260126161839.GC1339236@e132581.arm.com> References: <20260126-arm_coresight_refactor_dev_register-v2-0-b5a3c0441c15@arm.com> <20260126-arm_coresight_refactor_dev_register-v2-1-b5a3c0441c15@arm.com> <062c51c2-082d-4771-83df-3e5bfa90927d@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <062c51c2-082d-4771-83df-3e5bfa90927d@arm.com> Hi Suzuki, On Mon, Jan 26, 2026 at 03:48:28PM +0000, Suzuki K Poulose wrote: [...] > > @@ -1546,7 +1546,7 @@ 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_array(dict->fwnode_list, > > + list = devm_krealloc_array(dev, dict->fwnode_list, > > idx + 1, sizeof(*dict->fwnode_list), > > This is wrong. This would mean, the array gets released when the "dev" goes > away and thats not good. This is a per-driver list, not a per-device list. > Also, please remember that, we need to keep that node alive > when the device goes away, to make sure to allocate the same device name > when if/it comes back. May be, you could release the list and array, when > the "driver" goes away. Indeed. In next spin, I will to fix the leak in module exit. Thanks for pointing this out. Leo