public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@SteelEye.com>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: [PATCH] aic7xxx: add back locking
Date: Tue, 17 May 2005 16:09:52 -0500	[thread overview]
Message-ID: <1116364192.4989.54.camel@mulgrave> (raw)

Tampering with the settings has to be done under the host lock ...
slave_alloc isn't called under any lock, so this has to be done
explicitly.

James

--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -645,7 +645,9 @@ ahc_linux_slave_alloc(struct scsi_device
 	struct ahc_linux_target *targ;
 	struct scsi_target *starget = device->sdev_target;
 	struct ahc_linux_device *dev;
-	u_int target_offset;
+	unsigned int target_offset;
+	unsigned long flags;
+	int retval = -ENOMEM;
 
 	target_offset = starget->id;
 	if (starget->channel != 0)
@@ -654,12 +656,14 @@ ahc_linux_slave_alloc(struct scsi_device
 	ahc = *((struct ahc_softc **)device->host->hostdata);
 	if (bootverbose)
 		printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id);
+	ahc_lock(ahc, &flags);
 	targ = ahc->platform_data->targets[target_offset];
 	if (targ == NULL) {
 		targ = ahc_linux_alloc_target(ahc, starget->channel, starget->id);
 		struct seeprom_config *sc = ahc->seep_config;
 		if (targ == NULL)
-			return -ENOMEM;
+			goto out;
+
 		if (sc) {
 			unsigned short scsirate;
 			struct ahc_devinfo devinfo;
@@ -701,10 +705,13 @@ ahc_linux_slave_alloc(struct scsi_device
 	if (dev == NULL) {
 		dev = ahc_linux_alloc_device(ahc, targ, device->lun);
 		if (dev == NULL)
-			return -ENOMEM;
+			goto out;
 	}
+	retval = 0;
 
-	return 0;
+ out:
+	ahc_unlock(ahc, &flags);
+	return retval;
 }
 
 static int



                 reply	other threads:[~2005-05-17 21:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1116364192.4989.54.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox