* [PATCH] nubus: Call put_device() in bus initialization error path
@ 2025-12-13 7:21 Finn Thain
2025-12-13 8:58 ` Daniel Palmer
2026-01-26 11:21 ` Geert Uytterhoeven
0 siblings, 2 replies; 3+ messages in thread
From: Finn Thain @ 2025-12-13 7:21 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Haoxiang Li, Daniel Palmer, linux-m68k, linux-kernel
The error path for bus initialization is missing a call to put_device().
Add that call. This error path will probably never actually execute, but
any kernel source code may be subject to static checking or re-use.
Cc: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Cc: Daniel Palmer <daniel@0x0f.com>
Suggested-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
Tested on a Mac IIfx.
---
drivers/nubus/bus.c | 13 ++-----------
drivers/nubus/nubus.c | 12 +++++++++---
include/linux/nubus.h | 3 +--
3 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/nubus/bus.c b/drivers/nubus/bus.c
index 12df4d88970c..b7d417385d98 100644
--- a/drivers/nubus/bus.c
+++ b/drivers/nubus/bus.c
@@ -51,21 +51,12 @@ void nubus_driver_unregister(struct nubus_driver *ndrv)
}
EXPORT_SYMBOL(nubus_driver_unregister);
-static struct device nubus_parent = {
- .init_name = "nubus",
-};
-
static int __init nubus_bus_register(void)
{
return bus_register(&nubus_bus_type);
}
postcore_initcall(nubus_bus_register);
-int __init nubus_parent_device_register(void)
-{
- return device_register(&nubus_parent);
-}
-
static void nubus_device_release(struct device *dev)
{
struct nubus_board *board = to_nubus_board(dev);
@@ -79,9 +70,9 @@ static void nubus_device_release(struct device *dev)
kfree(board);
}
-int nubus_device_register(struct nubus_board *board)
+int nubus_device_register(struct device *parent, struct nubus_board *board)
{
- board->dev.parent = &nubus_parent;
+ board->dev.parent = parent;
board->dev.release = nubus_device_release;
board->dev.bus = &nubus_bus_type;
dev_set_name(&board->dev, "slot.%X", board->slot);
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index ab0f32b901c8..197c8c0de199 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -41,6 +41,10 @@ module_param_named(populate_procfs, nubus_populate_procfs, bool, 0);
LIST_HEAD(nubus_func_rsrcs);
+static struct device nubus_parent = {
+ .init_name = "nubus",
+};
+
/* Meaning of "bytelanes":
The card ROM may appear on any or all bytes of each long word in
@@ -829,7 +833,7 @@ static void __init nubus_add_board(int slot, int bytelanes)
list_add_tail(&fres->list, &nubus_func_rsrcs);
}
- if (nubus_device_register(board))
+ if (nubus_device_register(&nubus_parent, board))
put_device(&board->dev);
}
@@ -882,9 +886,11 @@ static int __init nubus_init(void)
return 0;
nubus_proc_init();
- err = nubus_parent_device_register();
- if (err)
+ err = device_register(&nubus_parent);
+ if (err) {
+ put_device(&nubus_parent);
return err;
+ }
nubus_scan_bus();
return 0;
}
diff --git a/include/linux/nubus.h b/include/linux/nubus.h
index 4d103ac8f5c7..b8710c825d64 100644
--- a/include/linux/nubus.h
+++ b/include/linux/nubus.h
@@ -162,8 +162,7 @@ void nubus_seq_write_rsrc_mem(struct seq_file *m,
unsigned char *nubus_dirptr(const struct nubus_dirent *nd);
/* Declarations relating to driver model objects */
-int nubus_parent_device_register(void);
-int nubus_device_register(struct nubus_board *board);
+int nubus_device_register(struct device *parent, struct nubus_board *board);
int nubus_driver_register(struct nubus_driver *ndrv);
void nubus_driver_unregister(struct nubus_driver *ndrv);
int nubus_proc_show(struct seq_file *m, void *data);
--
2.49.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nubus: Call put_device() in bus initialization error path
2025-12-13 7:21 [PATCH] nubus: Call put_device() in bus initialization error path Finn Thain
@ 2025-12-13 8:58 ` Daniel Palmer
2026-01-26 11:21 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Palmer @ 2025-12-13 8:58 UTC (permalink / raw)
To: Finn Thain; +Cc: Geert Uytterhoeven, Haoxiang Li, linux-m68k, linux-kernel
Hi Finn,
On Sat, 13 Dec 2025 at 16:21, Finn Thain <fthain@linux-m68k.org> wrote:
> Tested on a Mac IIfx.
I quickly tested on QEMU's quadra machine and no problems there. Will
test on an LC475 a bit later.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nubus: Call put_device() in bus initialization error path
2025-12-13 7:21 [PATCH] nubus: Call put_device() in bus initialization error path Finn Thain
2025-12-13 8:58 ` Daniel Palmer
@ 2026-01-26 11:21 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2026-01-26 11:21 UTC (permalink / raw)
To: Finn Thain; +Cc: Haoxiang Li, Daniel Palmer, linux-m68k, linux-kernel
On Sat, 13 Dec 2025 at 08:21, Finn Thain <fthain@linux-m68k.org> wrote:
> The error path for bus initialization is missing a call to put_device().
> Add that call. This error path will probably never actually execute, but
> any kernel source code may be subject to static checking or re-use.
>
> Cc: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> Cc: Daniel Palmer <daniel@0x0f.com>
> Suggested-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> Signed-off-by: Finn Thain <fthain@linux-m68k.org>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k tree for v6.20.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-26 11:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-13 7:21 [PATCH] nubus: Call put_device() in bus initialization error path Finn Thain
2025-12-13 8:58 ` Daniel Palmer
2026-01-26 11:21 ` Geert Uytterhoeven
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®