[PATCH] 2.2.11 ide-cd.c CDROMREADAUDIO bug

Eric Lammerts (eric@scintilla.utwente.nl)
Sun, 15 Aug 1999 03:21:41 +0200 (CEST)


The patch below fixes a bug in ide-cd.c. In the CDROMREADAUDIO ioctl
it does:

if (lba < 0 || lba >= toc->capacity)
return -EINVAL;

Seems OK at first sight, but the ATAPI spec (8020rev26.pdf) says:

> but the exact definition of the returned logical block address is
> modified to allow returning a possibly inexact value (but one with a
> known error boundary) based on CD-ROM table of contents data. This
> error boundary occurs when the last track is an audio track, and
> could cause the last block to be +/- 75 sectors from the actual end
> of the track.

So the fix is easy:

--- linux/drivers/block/ide-cd.c.orig Wed Aug 11 19:26:13 1999
+++ linux/drivers/block/ide-cd.c Sun Aug 15 03:17:21 1999
@@ -2188,7 +2188,8 @@
else
return -EINVAL;

- if (lba < 0 || lba >= toc->capacity)
+ /* toc->capacity is inexact when the last track is audio */
+ if (lba < 0 || lba >= toc->capacity + 75)
return -EINVAL;

buf = (char *) kmalloc (CDROM_NBLOCKS_BUFFER*CD_FRAMESIZE_RAW,

(I knew it was a bad move to buy an IDE cdrom drive :-))

-- 
Eric Lammerts <eric@scintilla.utwente.nl>                   -o)
                                                            /\\
Al is je pc'tje nog zo snel, Microsoft vertraagt hem wel.  _\_v

- 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/