From: Heinrich Schuchardt Date: Thu, 18 Mar 2021 12:52:19 +0100 Subject: [PATCH] dfu: memory leak in dfu_free_entities() In-Reply-To: <20210318111858.2853-1-xypron.glpk@gmx.de> References: <20210318111858.2853-1-xypron.glpk@gmx.de> Message-ID: <941b7ab9-7d27-dd70-bfea-460be544ec4e@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 18.03.21 12:18, Heinrich Schuchardt wrote: > We must free all entries that we remove from the list not just one to avoid > a memory leak. > > With list_for_each_entry_safe_reverse() it is safe to delete the current > entry as it provides a second pointer for the next entry. I got that wrong: dfu_alt_init() reserves memory for dfu_alt_num entries at once. So must call free() only once. Sorry for the noise. Best regards Heinrich