Close

The dreaded mmc_ioctl_cdrom_read_audio kernel bug

A project log for Silly software wishlist

Motivation to do some software projects by writing them down.

lion-mclionheadlion mclionhead 03/22/2020 at 05:470 Comments

Linux was a lot more reliable before it was heavily commercialized, but it's still the most reliable operating system.  

As lions do when they don't have to commute, it was back to transferring optical disks. This one was the lion kingdom's 1st encounter with CD rot. It was a swirly plant pattern inside the plastic. It's not scribbling from a human or a stain from a liquid but the propagation of a fungus.  The disk was manely unreadable after 30 years.

 Naturally, there are no web pages on the subject for the last 20 years.  The last time someone encountered CD rot was a Michael Bolton fan who since dropped offline, turned bald, had 3 marriages, & put 5 kids through college.  The disks have also lost the fresh plastic smell only lions of a certain age remember.

It was here that the lion kingdom discovered the famous mmc_ioctl_cdrom_read_audio kernel bug of at least 5 years.  It's clear that not enough people still rip CDs for the cdrom driver to be manetaned, so it hasn't been able to bypass bad sectors in decades.  The lion kingdom made a simple workaround 

In drivers/cdrom/cdrom.c -> cdrom_read_cdda_bpc:

It needs to check s for  nil

if (blk_execute_rq(q, cdi->disk, rq, 0)) {
    struct request_sense *s = rq->sense;
    pr_info("cdrom_read_cdda_bpc %d lba=%d s=%p\n", __LINE__, lba, s);
    ret = -EIO;
    if(s != 0)
    {
        cdi->last_sense = s->sense_key;
    }

Discussions