]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.52/scsi-storvsc-fix-memory-leak-on-ring-buffer-busy.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / scsi-storvsc-fix-memory-leak-on-ring-buffer-busy.patch
1 From 0208eeaa650c5c866a3242201678a19e6dc4a14e Mon Sep 17 00:00:00 2001
2 From: Long Li <longli@microsoft.com>
3 Date: Mon, 28 Aug 2017 17:43:59 -0700
4 Subject: scsi: storvsc: fix memory leak on ring buffer busy
5
6 From: Long Li <longli@microsoft.com>
7
8 commit 0208eeaa650c5c866a3242201678a19e6dc4a14e upstream.
9
10 When storvsc is sending I/O to Hyper-v, it may allocate a bigger buffer
11 descriptor for large data payload that can't fit into a pre-allocated
12 buffer descriptor. This bigger buffer is freed on return path.
13
14 If I/O request to Hyper-v fails due to ring buffer busy, the storvsc
15 allocated buffer descriptor should also be freed.
16
17 [mkp: applied by hand]
18
19 Fixes: be0cf6ca301c ("scsi: storvsc: Set the tablesize based on the information given by the host")
20 Signed-off-by: Long Li <longli@microsoft.com>
21 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24 ---
25 drivers/scsi/storvsc_drv.c | 2 ++
26 1 file changed, 2 insertions(+)
27
28 --- a/drivers/scsi/storvsc_drv.c
29 +++ b/drivers/scsi/storvsc_drv.c
30 @@ -1559,6 +1559,8 @@ static int storvsc_queuecommand(struct S
31 ret = storvsc_do_io(dev, cmd_request);
32
33 if (ret == -EAGAIN) {
34 + if (payload_sz > sizeof(cmd_request->mpb))
35 + kfree(payload);
36 /* no more space */
37 return SCSI_MLQUEUE_DEVICE_BUSY;
38 }