public inbox for linux-mips@vger.kernel.org
 help / color / mirror / Atom feed
* Question about gio_bus release function in sgi-ip22-gio
@ 2026-02-26 22:16 Dingisoul
  0 siblings, 0 replies; only message in thread
From: Dingisoul @ 2026-02-26 22:16 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-02-26 22:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 22:16 Question about gio_bus release function in sgi-ip22-gio Dingisoul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox