[PATCH] nubus: add a cleanup in nubus_init()

Haoxiang Li posted 1 patch 1 day, 13 hours ago
drivers/nubus/nubus.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] nubus: add a cleanup in nubus_init()
Posted by Haoxiang Li 1 day, 13 hours ago
If nubus_parent_device_register fails, call put_device()
to drop the device reference.

Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 drivers/nubus/nubus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index ab0f32b901c8..21706bdcb509 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -883,8 +883,10 @@ static int __init nubus_init(void)
 
 	nubus_proc_init();
 	err = nubus_parent_device_register();
-	if (err)
+	if (err) {
+		put_device(&nubus_parent);
 		return err;
+	}
 	nubus_scan_bus();
 	return 0;
 }
-- 
2.25.1
Re: [PATCH] nubus: add a cleanup in nubus_init()
Posted by kernel test robot 23 hours ago
Hi Haoxiang,

kernel test robot noticed the following build errors:

[auto build test ERROR on gerg-m68knommu/for-next]
[also build test ERROR on linus/master v6.18 next-20251212]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/nubus-add-a-cleanup-in-nubus_init/20251212-203606
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu.git for-next
patch link:    https://lore.kernel.org/r/20251212122930.36115-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [PATCH] nubus: add a cleanup in nubus_init()
config: m68k-defconfig (https://download.01.org/0day-ci/archive/20251213/202512131055.DdhG2azK-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251213/202512131055.DdhG2azK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512131055.DdhG2azK-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/nubus/nubus.c: In function 'nubus_init':
>> drivers/nubus/nubus.c:887:29: error: 'nubus_parent' undeclared (first use in this function); did you mean 'nubus_dirent'?
     887 |                 put_device(&nubus_parent);
         |                             ^~~~~~~~~~~~
         |                             nubus_dirent
   drivers/nubus/nubus.c:887:29: note: each undeclared identifier is reported only once for each function it appears in


vim +887 drivers/nubus/nubus.c

   876	
   877	static int __init nubus_init(void)
   878	{
   879		int err;
   880	
   881		if (!MACH_IS_MAC)
   882			return 0;
   883	
   884		nubus_proc_init();
   885		err = nubus_parent_device_register();
   886		if (err) {
 > 887			put_device(&nubus_parent);
   888			return err;
   889		}
   890		nubus_scan_bus();
   891		return 0;
   892	}
   893	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] nubus: add a cleanup in nubus_init()
Posted by Daniel Palmer 1 day, 13 hours ago
Hi Haoxiang,

On Fri, 12 Dec 2025 at 21:30, Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn> wrote:
> +++ b/drivers/nubus/nubus.c

> +               put_device(&nubus_parent);

nubus_parent seems to be in drivers/nubus/bus.c not
drivers/nubus/nubus.c? Does this compile?

Thanks!