Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > fc11cd6e1c513a17304da94a5390f3cd > files > 3412

kernel-2.6.18-194.11.1.el5.src.rpm

From: mchristi@redhat.com <mchristi@redhat.com>
Date: Wed, 11 Feb 2009 18:12:04 -0600
Subject: [scsi] handle work queue and shost_data setup failures
Message-id: 12343975242580-git-send-email-mchristi@redhat.com
O-Subject: [PATCH] RHEL 5.4: scsi: handle work queue and shost_data setup failures
Bugzilla: 450862
RH-Acked-by: David Milburn <dmilburn@redhat.com>
RH-Acked-by: Tomas Henzl <thenzl@redhat.com>
RH-Acked-by: Doug Ledford <dledford@redhat.com>

From: Mike Christie <mchristi@redhat.com>

This is for BZ 450862.

If the shost->work_q or shost_data fail to be allocated we never
return a error to the caller, so later when the driver or scsi-ml
go to ref the field you get an oops or error message indicating
the work q as not created.

This patch has us a return a -EXYZ value.

Patch is upstream here:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=77cca462c69d827fabee0ef3fdab86109c2fe8d8

I could not replicate this in a real setup. Patch was made and tested
by Emulex. I just did a boot up test to make sure that I did not add
a regression in the tests.

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 260835d..fd4dd52 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -219,18 +219,24 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
 
 	get_device(&shost->shost_gendev);
 
-	if (shost->transportt->host_size &&
-	    (shost->shost_data = kmalloc(shost->transportt->host_size,
-					 GFP_KERNEL)) == NULL)
-		goto out_del_classdev;
+	if (shost->transportt->host_size) {
+		shost->shost_data = kzalloc(shost->transportt->host_size,
+					 GFP_KERNEL);
+		if (shost->shost_data == NULL) {
+			error = -ENOMEM;
+			goto out_del_classdev;
+		}
+	}
 
 	if (shost->transportt->create_work_queue) {
 		snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d",
 			shost->host_no);
 		shost->work_q = create_singlethread_workqueue(
 					shost->work_q_name);
-		if (!shost->work_q)
+		if (!shost->work_q) {
+			error = -EINVAL;
 			goto out_free_shost_data;
+		}
 	}
 
 	error = scsi_sysfs_add_host(shost);