Re: Inconsistent test in s[dr].c (2.0.18)?

Gerd Knorr (kraxel@cs.tu-berlin.de)
Fri, 13 Sep 1996 23:14:28 +0200 (MET DST)


On Tue, 10 Sep 1996, Julian Thompson wrote:

> Hi,
>
> A friend's machine recently logged a "Running low on SCSI DMA buffers"
> warning, and being curious I located the two kernel source files that
> output this message, these being drivers/scsi/s[dr].c.
>
> There's a section of code (starting at around line 861 of sr.c, and
> line 764 of sd.c, kernel 2.0.18) that performs the test that can cause
> this message to be output. I noticed that the conditional tests are
> slightly different, and I wondered if one was perhaps wrong.
>
> The test in sr.c reads:
>
> if (((long) sgpnt[count].address) + sgpnt[count].length >
> ISA_DMA_THRESHOLD && SCpnt->host->unchecked_isa_dma)
>
> while in sd.c it reads:
>
> if (((long) sgpnt[count].address) + sgpnt[count].length - 1 >
> ISA_DMA_THRESHOLD && (SCpnt->host->unchecked_isa_dma) &&
> !sgpnt[count].alt_address)
>
> It seems that an off by one error was corrected in sd.c, but the
> change never made it to sr.c.. I searched back through the patches,
> and found that the two tests became different in the 1.1.2 patch
> (i.e. nearly 2.5 years ago :-).
>
Wow, do you have all the patches since 1.1.2 on your hard disk?

To get serious, the off-by-one bug does'nt really break anything, as the
DMA-buffers are aligned. That's why nobody found this last two years...

The warning is'nt critical, but adding the third check (for valid
alt_address) is a good idea. It seems it is'nt nessesary, but a useful
optimation (hav'nt written this code, but checked it out as I'm
rewriting the sr driver :-).

> I don't know how important the difference is, but I thought I'd point
> it out to you SCSI hackers (Drew, Eric, Leonard, ...) - I just want
> the kernel to be perfect ;-)
>
> Julian
>
>

--
Gerd Knorr <kraxel@cs.tu-berlin.de> | http://wwwwbs.cs.tu-berlin.de/~kraxel/

Linux hackers are funny people: They count the time in patchlevels.