From: "Pandey, Radhey Shyam" <radheys@amd.com>
To: Myeonghun Pak <mhun512@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Michal Simek <michal.simek@amd.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Ijae Kim <ae878000@gmail.com>
Subject: Re: [PATCH] char: xilinx_hwicap: unregister class on init errors
Date: Tue, 23 Jun 2026 17:56:09 +0530 [thread overview]
Message-ID: <ddc6210a-303c-44ec-881f-d902946eb6a6@amd.com> (raw)
In-Reply-To: <20260623085604.89284-1-mhun512@gmail.com>
> hwicap_module_init() registers icap_class before reserving the
> character-device region and registering the platform driver. If either
> of those later steps fails, the init path must undo the successful class
> registration before returning an error.
>
> Route the chrdev registration failure through a class unwind label, and
> let the platform-driver registration failure fall through the existing
> chrdev unwind before unregistering the class. The normal module exit path
> is unchanged.
>
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
>
> Fixes: ef141a0bb0dc ("[POWERPC] Xilinx: hwicap driver")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
>
> ---
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Thanks!
> drivers/char/xilinx_hwicap/xilinx_hwicap.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
> index 34a345dc5e..9bb5fa642f 100644
> --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
> +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
> @@ -760,7 +760,7 @@ static int __init hwicap_module_init(void)
> HWICAP_DEVICES,
> DRIVER_NAME);
> if (retval < 0)
> - return retval;
> + goto failed_class;
>
> retval = platform_driver_register(&hwicap_platform_driver);
> if (retval)
> @@ -771,6 +771,9 @@ static int __init hwicap_module_init(void)
> failed:
> unregister_chrdev_region(devt, HWICAP_DEVICES);
>
> + failed_class:
> + class_unregister(&icap_class);
> +
> return retval;
> }
>
prev parent reply other threads:[~2026-06-23 12:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 8:55 Myeonghun Pak
2026-06-23 12:26 ` Pandey, Radhey Shyam [this message]
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=ddc6210a-303c-44ec-881f-d902946eb6a6@amd.com \
--to=radheys@amd.com \
--cc=ae878000@gmail.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhun512@gmail.com \
--cc=michal.simek@amd.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®