diff mbox series

[2/2] Add error checking and returning for transport_register_device() in scsi_sysfs_add_host()

Message ID 20240126115759.1361058-1-ingyujang25@unist.ac.kr
State Superseded
Headers show
Series None | expand

Commit Message

(학생) 장인규 (컴퓨터공학과) Jan. 26, 2024, 11:57 a.m. UTC
The function transport_register_device() can return error code.
However, scsi_sysfs_add_host() currently does not check return value
of transport_register_device() and always returns 0.
Also, return value of scsi_sysfs_add_host() is
checked at drivers/scsi/hosts.c:307.

Therefore, this commit adds error checking for transport_register_device()
and returning error code in scsi_sysfs_add_host().

Signed-off-by: Ingyu Jang <ingyujang25@unist.ac.kr>
---
 drivers/scsi/scsi_sysfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 24f6eefb6803..88f1b901d01b 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1621,7 +1621,11 @@  EXPORT_SYMBOL(scsi_register_interface);
  **/
 int scsi_sysfs_add_host(struct Scsi_Host *shost)
 {
-	transport_register_device(&shost->shost_gendev);
+	int ret;
+
+	ret = transport_register_device(&shost->shost_gendev);
+	if (ret) 
+		return ret;
 	transport_configure_device(&shost->shost_gendev);
 	return 0;
 }