Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751309AbdH2ApQ (ORCPT ); Mon, 28 Aug 2017 20:45:16 -0400 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:48298 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbdH2ApO (ORCPT ); Mon, 28 Aug 2017 20:45:14 -0400 x-originating-ip: 107.180.71.197 From: Long Li To: "K . Y . Srinivasan" , Haiyang Zhang , "James E . J . Bottomley" , devel@linuxdriverproject.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [PATCH] storvsc: fix memory leak on ring buffer busy Date: Mon, 28 Aug 2017 17:43:59 -0700 Message-Id: <20170829004359.28526-1-longli@exchange.microsoft.com> X-Mailer: git-send-email 2.14.0 X-CMAE-Envelope: MS4wfKeZQqgsfchguwpz5LWKjRAFJHpSYbiX837egU6zeNS8hJT06xEYSKaWK/QljL2W2/1oU7gn4n0qMtSvN9A8UXCfFqSK4SIj33OwABv0oMC1Vog1Ryly WNNUuY3qmYJGJ+wCFUlBX0olmB13vIENZ3WrsDDHVj354xfS6WrLIloZfk9ZJzw30gyeglqkd7j9Bk0JYLQA7hvvx9hqyWh1dKXh5O6csvbEviUC9gji+j90 rkZF4XmP6JVAbj4xYVw0/kGcmXNoX21r9TBQfT4jXk+pSE4R3wjL0T3ExWqhYhcV/xWKotsyQbGAnnBO0AbvuCSqSse/eNroU+twEt7BLQ3ACWmqEOrvybTu PMXYVUeCwgtUiEO5XY822OGf+Xx/l4kWZt055LaMgWZLIXsFFpY= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 977 Lines: 29 From: Long Li When storvsc is sending I/O to Hyper-v, it may allocate a bigger buffer descriptor for large data payload that can't fit into a pre-allocated buffer descriptor. This bigger buffer is freed on return path. If I/O request to Hyper-v fails due to ring buffer busy, the storvsc allocated buffer descriptor should also be freed. Signed-off-by: Long Li --- drivers/scsi/storvsc_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 009adb0..db52882 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1657,6 +1657,8 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) ret = storvsc_do_io(dev, cmd_request, smp_processor_id()); if (ret == -EAGAIN) { + if (payload_sz > sizeof(cmd_request->mpb)) + kfree(payload); /* no more space */ return SCSI_MLQUEUE_DEVICE_BUSY; } -- 2.7.4