Re: memory leak in sr_ioctl.c in Linux 2.2.12/13

Jens Axboe (axboe@image.dk)
Mon, 6 Dec 1999 18:31:52 +0000


--17pEHd4RhPHOinZp
Content-Type: text/plain; charset=us-ascii

On Mon, Dec 06 1999, Martin Vogt wrote:
> Hello,
>
> The following program produces a few EINVAL errors
> and then only ENOMEM erros, because the file
> sr_ioctl.c has a memory leak.
>
> (It does not free the memory, when returning EINVAL)

Ouch! Alan, here's the simple fix against 2.2.14-pre11.

-- 
*  Jens Axboe <axboe@image.dk>
*  Linux CD-ROM Maintainer
*  http://www.kernel.dk

--17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sr_leak.diff"

--- sr_ioctl.c~ Mon Dec 6 18:28:18 1999 +++ sr_ioctl.c Mon Dec 6 18:30:02 1999 @@ -750,8 +750,11 @@ lba = (((msf.cdmsf_min0 * CD_SECS) + msf.cdmsf_sec0) * CD_FRAMES + msf.cdmsf_frame0) - CD_MSF_OFFSET; - if (lba < 0 || lba >= scsi_CDs[target].capacity) + + if (lba < 0 || lba >= scsi_CDs[target].capacity) { + scsi_free(raw); return -EINVAL; + } rc = sr_read_sector(target, lba, blocksize, raw); if (!rc)

--17pEHd4RhPHOinZp--

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