Commit b0bb3273 authored by Rik van Riel's avatar Rik van Riel Committed by James Bottomley

[PATCH] Re: [CHECKER] 112 potential memory leaks in 2.5.48

On Wed, 5 Feb 2003, Rik van Riel wrote:
> On Tue, 4 Feb 2003, Andy Chou wrote:

Thanks for the checker output.  First patch below...

> > [BUG]
> > u1/acc/linux/2.5.48/drivers/scsi/sr_ioctl.c:188:sr_do_ioctl:
> > ERROR:LEAK:85:188:Memory leak [Allocated from:
> > /u1/acc/linux/2.5.48/drivers/scsi/sr_ioctl.c:85:scsi_allocate_request]
>
> Bug indeed, I've created a patch to fix the possible leak of
> a scsi request, but can't figure out the bounce buffer logic...

The patch below fixes the scsi request leak. I'm not sure
how the bounce buffer thing is supposed to work (Christoph?
James?) so I'm not touching that at the moment.

Linus, could you please apply this patch (against today's
bk tree) ?

thank you,

Rik
--
Bravely reimplemented by the knights who say "NIH".
http://www.surriel.com/		http://guru.conectiva.com/
Current spamtrap:  <a href=mailto:"october@surriel.com">october@surriel.com</a>


===== drivers/scsi/sr_ioctl.c 1.27 vs edited =====
parent 21cd9dc6
...@@ -99,7 +99,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct cdrom_generic_command *cgc) ...@@ -99,7 +99,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct cdrom_generic_command *cgc)
if (bounce_buffer == NULL) { if (bounce_buffer == NULL) {
printk("SCSI DMA pool exhausted."); printk("SCSI DMA pool exhausted.");
err = -ENOMEM; err = -ENOMEM;
goto out; goto out_free;
} }
memcpy(bounce_buffer, cgc->buffer, cgc->buflen); memcpy(bounce_buffer, cgc->buffer, cgc->buflen);
cgc->buffer = bounce_buffer; cgc->buffer = bounce_buffer;
...@@ -107,7 +107,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct cdrom_generic_command *cgc) ...@@ -107,7 +107,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct cdrom_generic_command *cgc)
retry: retry:
if (!scsi_block_when_processing_errors(SDev)) { if (!scsi_block_when_processing_errors(SDev)) {
err = -ENODEV; err = -ENODEV;
goto out; goto out_free;
} }
scsi_wait_req(SRpnt, cgc->cmd, cgc->buffer, cgc->buflen, scsi_wait_req(SRpnt, cgc->cmd, cgc->buffer, cgc->buflen,
...@@ -179,6 +179,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct cdrom_generic_command *cgc) ...@@ -179,6 +179,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct cdrom_generic_command *cgc)
memcpy(cgc->sense, SRpnt->sr_sense_buffer, sizeof(*cgc->sense)); memcpy(cgc->sense, SRpnt->sr_sense_buffer, sizeof(*cgc->sense));
/* Wake up a process waiting for device */ /* Wake up a process waiting for device */
out_free:
scsi_release_request(SRpnt); scsi_release_request(SRpnt);
SRpnt = NULL; SRpnt = NULL;
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment