[PATCH] Bug wrt failing init of scsi modules

Kurt Garloff (garloff@suse.de)
Fri, 27 Aug 1999 03:03:22 +0200


--gj572EiMnwbLXET9
Content-Type: multipart/mixed; boundary=qDbXVdCdHGoSgWSk

--qDbXVdCdHGoSgWSk
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Linus, hi Alan,

attached is a bugfix for the following situation:
scsi_register_device_module() gets called and registers the device (sd, sr)
right at the beginning.
If this functions fails a little bit later in the ->init() function, then
the device does not get removed from the list of devices pointed to by
scsi_devicelist. [The (out_of_space) case is handled correctly, BTW.]

This leaves us with the device getting removed, as module init fails.
However the pointer scsi_devicelist points to the removed device resulting
in kernel Oopses on further SCSI operations.
Aug 26 23:45:57 kurt kernel: Unable to handle kernel paging request at=20
virtual address c8c1cb30
Aug 26 23:45:57 kurt kernel: EIP: 0010:[scan_scsis_single+1402/2064]
Aug 26 23:45:57 kurt kernel: esi: c8c1cb18 edi: c5091df4 ...
=20
You can loose the ability to access your harddisks by inserting sd_mod in a
kernel with sd compiled in because of this bug.
=20
Attached is a patch to fix it.
Patch is against 2.2.12, but 2.3.15 and 2.0.38 should be affected as well.
=20
--=20
Kurt Garloff <garloff@suse.de> Wuppertal, FRG
PGP2 key: See mail header, key servers Linux kernel development
SuSE GmbH, N=FCrnberg, FRG SCSI drivers: tmscsim(DC390), DC395

--qDbXVdCdHGoSgWSk
Content-Type: text/plain; charset=us-ascii
Content-Description: 22x-scsi-mod-unregister.diff
Content-Disposition: attachment; filename="22x-scsi-mod-unregister.diff"
Content-Transfer-Encoding: quoted-printable

--- linux-2.2.12/drivers/scsi/scsi.c.orig Mon Aug 9 21:04:40 1999
+++ linux-2.2.12/drivers/scsi/scsi.c Fri Aug 27 02:53:47 1999
@@ -3110,6 +3110,7 @@
Scsi_Device * SDpnt;
struct Scsi_Host * shpnt;
int out_of_space =3D 0;
+ int no_detect =3D 0;
=20
if (tpnt->next) return 1;
=20
@@ -3123,7 +3124,7 @@
for(SDpnt =3D shpnt->host_queue; SDpnt;=20
SDpnt =3D SDpnt->next)
{
- if(tpnt->detect) SDpnt->attached +=3D (*tpnt->detect)(SDpnt);
+ if(tpnt->detect) SDpnt->attached +=3D (no_detect =3D (*tpnt->d=
etect)(SDpnt));
}
}
=20
@@ -3132,7 +3133,15 @@
* init function.
*/
if(tpnt->init && tpnt->dev_noticed)
- if ((*tpnt->init)()) return 1;
+ if ((*tpnt->init)())=20
+ {
+ /* We don't need full unregister and use our knowledge about
+ * the structure of scsi_devicelist instead. KG, 99/08/27 */
+ /* scsi_unregister_device (tpnt); */
+ SDpnt->attached -=3D no_detect;
+ scsi_devicelist =3D scsi_devicelist->next;
+ return 1;
+ }
=20
/*
* Now actually connect the devices to the new driver.

--qDbXVdCdHGoSgWSk--

--gj572EiMnwbLXET9
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i

iQCVAwUBN8Xj2haQN/7O/JIVAQEAbAP/Ycc3Rm7Buob95Nvi+GB9v3TTCWiiLv/W
pT+Zm0PReXDUeLdykuqsUpVV+dFPfyBb3sJc919vVcUezqKaCok52MDMTBXQ2B4R
W661DDnmQYHQa7ziCx1eCpwGLbMz9t79IMyI8XOhKEPG4afdoRxHUUVkusjjWLda
bpK5bpRP+zI=
=54oh
-----END PGP SIGNATURE-----

--gj572EiMnwbLXET9--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/