Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nubus: Call put_device() in bus initialization error path

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>
Link: https://patch.msgid.link/478d5f080d74b6688c9e3f9132e3fe251e997ad7.1765610469.git.fthain@linux-m68k.org
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

authored by

Finn Thain and committed by
Geert Uytterhoeven
f16a9577 8f0b4cce

+12 -16
+2 -11
drivers/nubus/bus.c
··· 51 51 } 52 52 EXPORT_SYMBOL(nubus_driver_unregister); 53 53 54 - static struct device nubus_parent = { 55 - .init_name = "nubus", 56 - }; 57 - 58 54 static int __init nubus_bus_register(void) 59 55 { 60 56 return bus_register(&nubus_bus_type); 61 57 } 62 58 postcore_initcall(nubus_bus_register); 63 - 64 - int __init nubus_parent_device_register(void) 65 - { 66 - return device_register(&nubus_parent); 67 - } 68 59 69 60 static void nubus_device_release(struct device *dev) 70 61 { ··· 70 79 kfree(board); 71 80 } 72 81 73 - int nubus_device_register(struct nubus_board *board) 82 + int nubus_device_register(struct device *parent, struct nubus_board *board) 74 83 { 75 - board->dev.parent = &nubus_parent; 84 + board->dev.parent = parent; 76 85 board->dev.release = nubus_device_release; 77 86 board->dev.bus = &nubus_bus_type; 78 87 dev_set_name(&board->dev, "slot.%X", board->slot);
+9 -3
drivers/nubus/nubus.c
··· 41 41 42 42 LIST_HEAD(nubus_func_rsrcs); 43 43 44 + static struct device nubus_parent = { 45 + .init_name = "nubus", 46 + }; 47 + 44 48 /* Meaning of "bytelanes": 45 49 46 50 The card ROM may appear on any or all bytes of each long word in ··· 833 829 list_add_tail(&fres->list, &nubus_func_rsrcs); 834 830 } 835 831 836 - if (nubus_device_register(board)) 832 + if (nubus_device_register(&nubus_parent, board)) 837 833 put_device(&board->dev); 838 834 } 839 835 ··· 886 882 return 0; 887 883 888 884 nubus_proc_init(); 889 - err = nubus_parent_device_register(); 890 - if (err) 885 + err = device_register(&nubus_parent); 886 + if (err) { 887 + put_device(&nubus_parent); 891 888 return err; 889 + } 892 890 nubus_scan_bus(); 893 891 return 0; 894 892 }
+1 -2
include/linux/nubus.h
··· 162 162 unsigned char *nubus_dirptr(const struct nubus_dirent *nd); 163 163 164 164 /* Declarations relating to driver model objects */ 165 - int nubus_parent_device_register(void); 166 - int nubus_device_register(struct nubus_board *board); 165 + int nubus_device_register(struct device *parent, struct nubus_board *board); 167 166 int nubus_driver_register(struct nubus_driver *ndrv); 168 167 void nubus_driver_unregister(struct nubus_driver *ndrv); 169 168 int nubus_proc_show(struct seq_file *m, void *data);