From: Dingisoul <dingiso.kernel@gmail.com>
To: linux-mips@vger.kernel.org
Cc: tsbogend@alpha.franken.de
Subject: Question about gio_bus release function in sgi-ip22-gio
Date: Thu, 26 Feb 2026 17:16:45 -0500 [thread overview]
Message-ID: <d10eed82-c676-46e0-a126-b0aa5691d9df@gmail.com> (raw)
Dear maintainers,
I have a question regarding the sgi-ip22-gio implementation
in the MIPS kernel.
`gio_bus` is declared as a static struct device variable.
However, its release function calls kfree() on the device
pointer, which would free a statically allocated variable —
an undefined behavior:
static void gio_bus_release(struct device *dev)
{
kfree(dev);
}
static struct device gio_bus = {
.init_name = "gio",
.release = &gio_bus_release,
};
My concern is that this could become an actual problem in
`ip22_gio_init`. If `device_register()` fails, `put_device()`
is called, which decrements the refcount to zero and triggers
the release function:
static int __init ip22_gio_init(void)
{
unsigned int pbdma __maybe_unused;
int ret;
ret = device_register(&gio_bus);
if (ret) {
put_device(&gio_bus);
return ret;
}
...
}
Could this result in undefined behavior if the registration
ever fails? Would it make sense to provide a no-op release
function instead, given that `gio_bus` is statically allocated?
Thank you for your time and consideration.
Best regards,
Rubio
reply other threads:[~2026-02-26 22:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=d10eed82-c676-46e0-a126-b0aa5691d9df@gmail.com \
--to=dingiso.kernel@gmail.com \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/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