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

scsi: drivers: base: Propagate errors through the transport component

The transport registration may fail. Make sure the errors are propagated
to the callers.

Link: https://lore.kernel.org/r/20200106185817.640331-3-krisman@collabora.com
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Gabriel Krisman Bertazi and committed by
Martin K. Petersen
cd7ea70b 7c1ef338

+11 -6
+8 -3
drivers/base/transport_class.c
··· 30 30 #include <linux/attribute_container.h> 31 31 #include <linux/transport_class.h> 32 32 33 + static int transport_remove_classdev(struct attribute_container *cont, 34 + struct device *dev, 35 + struct device *classdev); 36 + 33 37 /** 34 38 * transport_class_register - register an initial transport class 35 39 * ··· 176 172 * routine is simply a trigger point used to add the device to the 177 173 * system and register attributes for it. 178 174 */ 179 - 180 - void transport_add_device(struct device *dev) 175 + int transport_add_device(struct device *dev) 181 176 { 182 - attribute_container_device_trigger(dev, transport_add_class_device); 177 + return attribute_container_device_trigger_safe(dev, 178 + transport_add_class_device, 179 + transport_remove_classdev); 183 180 } 184 181 EXPORT_SYMBOL_GPL(transport_add_device); 185 182
+3 -3
include/linux/transport_class.h
··· 62 62 container_of(x, struct transport_container, ac) 63 63 64 64 void transport_remove_device(struct device *); 65 - void transport_add_device(struct device *); 65 + int transport_add_device(struct device *); 66 66 void transport_setup_device(struct device *); 67 67 void transport_configure_device(struct device *); 68 68 void transport_destroy_device(struct device *); 69 69 70 - static inline void 70 + static inline int 71 71 transport_register_device(struct device *dev) 72 72 { 73 73 transport_setup_device(dev); 74 - transport_add_device(dev); 74 + return transport_add_device(dev); 75 75 } 76 76 77 77 static inline void