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

TC: Handle device_register() errors.

Make the TURBOchannel driver bail out if the call to device_register()
failed.

Signed-off-by: Levente Kurusa <levex@linux.com>
Acked-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Cc: Linux MIPS <linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/6673/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Levente Kurusa and committed by
Ralf Baechle
5bb7889f ab6c15bc

+8 -2
+8 -2
drivers/tc/tc.c
··· 129 129 130 130 tc_device_get_irq(tdev); 131 131 132 - device_register(&tdev->dev); 132 + if (device_register(&tdev->dev)) { 133 + put_device(&tdev->dev); 134 + goto out_err; 135 + } 133 136 list_add_tail(&tdev->node, &tbus->devices); 134 137 135 138 out_err: ··· 151 148 152 149 INIT_LIST_HEAD(&tc_bus.devices); 153 150 dev_set_name(&tc_bus.dev, "tc"); 154 - device_register(&tc_bus.dev); 151 + if (device_register(&tc_bus.dev)) { 152 + put_device(&tc_bus.dev); 153 + return 0; 154 + } 155 155 156 156 if (tc_bus.info.slot_size) { 157 157 unsigned int tc_clock = tc_get_speed(&tc_bus) / 100000;