From: Borislav Petkov <bp@alien8.de>
To: Eric-Terminal <ericterminal@gmail.com>
Cc: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
Tony Luck <tony.luck@intel.com>,
linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] EDAC/versalnet: Fix resource leaks and NULL derefs in init_versalnet()
Date: Thu, 26 Feb 2026 13:59:32 +0100 [thread overview]
Message-ID: <20260226125932.GAaaBDtCAp5ueJVTib@fat_crate.local> (raw)
In-Reply-To: <20260226112907.76971-1-ericterminal@gmail.com>
On Thu, Feb 26, 2026 at 07:29:07PM +0800, Eric-Terminal wrote:
> From: Yufan Chen <ericterminal@gmail.com>
>
> init_versalnet() has several bugs in its error handling. kzalloc() and
> kmalloc() return values are used without NULL checks, causing a NULL
> pointer dereference when allocation fails. The cleanup loop uses
> while (i--) which skips the current failing index, leaking the
> resources already allocated for that slot. edac_mc_del_mc() is called
> unconditionally during unwind, even for controllers that were never
> registered with edac_mc_add_mc(). Also, sprintf() is used instead of
> snprintf() on a fixed-size buffer.
>
> Fix by adding NULL checks for dev and name allocations, replacing
> while (i--) with for (j = i; j >= 0; j--) to include the failing
> index, tracking successful edac_mc_add_mc() calls with a bool array,
> and switching to snprintf().
>
> Signed-off-by: Yufan Chen <ericterminal@gmail.com>
> Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
> ---
> v2: Correct Signed-off-by name and add Reviewed-by tag. Fix commit message formatting.
>
> drivers/edac/versalnet_edac.c | 29 ++++++++++++++++++++++++-----
> 1 file changed, 24 insertions(+), 5 deletions(-)
No, thanks, we'll do the proper cleanup here:
https://lore.kernel.org/all/20251104093932.3838876-1-shubhrajyoti.datta@amd.com/T/#u
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2026-02-26 12:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-21 7:16 [PATCH] " Eric-Terminal
2026-02-22 2:44 ` Borislav Petkov
[not found] ` <CAKNPVZA36XvT7R+QWTOTvAeQNA-sZfnG-h5jV3FnKvKOxqiGtA@mail.gmail.com>
[not found] ` <FE3C5380-E82B-4EC8-B1C0-16026CEEF8A2@alien8.de>
2026-02-22 10:39 ` Eric-Terminal
2026-02-23 13:47 ` Borislav Petkov
2026-02-23 14:58 ` Eric_Terminal
2026-02-26 6:54 ` Datta, Shubhrajyoti
2026-02-26 11:29 ` [PATCH v2] " Eric-Terminal
2026-02-26 12:59 ` Borislav Petkov [this message]
2026-02-26 16:52 ` Datta, Shubhrajyoti
2026-02-22 10:48 ` [PATCH] " Eric_Terminal
2026-02-23 8:54 ` Borislav Petkov
2026-02-23 10:08 ` Eric_Terminal
2026-02-23 10:40 ` Borislav Petkov
2026-02-23 10:52 ` Eric_Terminal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226125932.GAaaBDtCAp5ueJVTib@fat_crate.local \
--to=bp@alien8.de \
--cc=ericterminal@gmail.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shubhrajyoti.datta@amd.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®