lkml.org 
[lkml]   [1997]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: SCSI disk devices
Hello Everyone,


While we mention the scsidev program, I grabbed scsidev-1.5 (the
latest?)
and had it segfault. Here is what I had to fix:

There are a number of problems with get_serial_number() function. I only
saw these when using the '-s' option.

1) It has some early returns, before setting '->serial'.
The call for 'if (show_serial)' does not expect it, and does
not check for NULL after the call.
- set '->serial' to 'no_serial' right at the start of the function.

2) The ioctl says the output buffer size is 1024. This is wrong,
it is only 1024-8. I got segfaults because of this.
- use:
((int *)buffer)[0] = 0; /* length of input buffer */
((int *)buffer)[1] = 1024-8; /* length of output buffer */
cmd = ...

3) If the ioctl fails, '->serial' is set to 'no_serial' but we
still proceed to copy the serial number from the buffer.
- after the ioctl replace:
if (status) ...
... a block ...
/* Copy information to identical...
with:
if (!status) {
... a block ...
}
/* Copy information to identical...

4) And while we are here, I would trim the serial number (in the above
block) before the malloc (still in 'buffer') rather than after. Not
a real problem.


Actually, I think this program *is* alpha status, it looks like it was
never properly cleaned up for release (often does not check returned
values
etc.) but it *does* work and is very nice. If Eric is busy, better
release
alpha than not at all...


--
Eyal Lebedinsky (eyal@eyal.emu.id.au)

\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.125 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site