[lkml]   [2004]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH] remember to check return value from __copy_to_user() in cdrom_read_cdda_old()


    Here's a patch to ensure that the return value from __copy_to_user() gets
    checked in cdrom_read_cdda_old().
    I assume that returning -EFAULT if the copy fails to copy all bytes is an
    appropriate action, but please correct me if I'm wrong.

    Signed-off-by: Jesper Juhl <>

    diff -up linux-2.6.9-rc1-bk13-orig/drivers/cdrom/cdrom.c linux-2.6.9-rc1-bk13/drivers/cdrom/cdrom.c
    --- linux-2.6.9-rc1-bk13-orig/drivers/cdrom/cdrom.c 2004-08-24 20:44:01.000000000 +0200
    +++ linux-2.6.9-rc1-bk13/drivers/cdrom/cdrom.c 2004-09-06 23:41:20.000000000 +0200
    @@ -1959,7 +1959,10 @@ static int cdrom_read_cdda_old(struct cd
    ret = cdrom_read_block(cdi, &cgc, lba, nr, 1, CD_FRAMESIZE_RAW);
    if (ret)
    - __copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr);
    + if (__copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr)) {
    + kfree(cgc.buffer);
    + return -EFAULT;
    + }
    ubuf += CD_FRAMESIZE_RAW * nr;
    nframes -= nr;
    lba += nr;

    I'm wondering if it would make sense to wrap this branch in unlikely()
    since it should rarely fail...?
    I should also mention that I've only compile tested this so far.

    Jesper Juhl

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:05    [W:0.020 / U:49.120 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site