From: David Jeffery Date: Wed, 11 Apr 2012 16:14:25 +0000 (-0400) Subject: [SCSI] st: fix memory leak with >1MB tape I/O X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7c018a901c3fef2af9d713ba849e8e52eb82dde1;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [SCSI] st: fix memory leak with >1MB tape I/O There is a memory leak in the st driver when sending large enough reads or writes using st's direct I/O path. As part of mapping the application's memory, a buffer to hold page pointers is allocated and the count of mapped pages is stored in field do_dio. A non-zero do_dio marks that direct I/O is in use. But do_dio is only 1 byte in size. Mapping 256 4k pages overflows do_dio and causes it to be set to 0, like direct I/O option was not used. When the I/O completes, the buffer to hold the page pointers is not freed, and the page counts of the mapped pages are not reduced. Every I/O of this size then leaks memory. The size of do_dio needs to be increased to prevent it wrapping around. Signed-off-by: David Jeffery Acked-by: Kai Mäkisara Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h index ea35632b986c..b548923785ed 100644 --- a/drivers/scsi/st.h +++ b/drivers/scsi/st.h @@ -35,8 +35,8 @@ struct st_request { /* The tape buffer descriptor. */ struct st_buffer { unsigned char dma; /* DMA-able buffer */ - unsigned char do_dio; /* direct i/o set up? */ unsigned char cleared; /* internal buffer cleared after open? */ + unsigned short do_dio; /* direct i/o set up? */ int buffer_size; int buffer_blocks; int buffer_bytes;