From: Andrew Morton Subject: [patch 69/94] drivers/rapidio/devices/rio_mport_cdev.c: fix resource leak in error handling path in 'rio_dma_transfer()' Date: Fri, 17 Nov 2017 15:37:57 -0800 Message-ID: <20171117153757.cd4b2666b2c95ad982092995@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:56608 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030470AbdKQXh7 (ORCPT ); Fri, 17 Nov 2017 18:37:59 -0500 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: Linus Torvalds Cc: Christophe JAILLET , Logan Gunthorpe , Matt Porter , Alexandre Bounine , Lorenzo Stoakes , Jesper Nilsson , Christian =?ISO-8859-1?Q?K=F6ni?= =?ISO-8859-1?Q?g?= , mm-commits@vger.kernel.org, Andrew Morton From: Christophe JAILLET Subject: drivers/rapidio/devices/rio_mport_cdev.c: fix resource leak in error handling path in 'rio_dma_transfer()' If 'dma_map_sg()', we should branch to the existing error handling path to free some resources before returning. Link: http://lkml.kernel.org/r/61292a4f369229eee03394247385e955027283f8.1505687047.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET Reviewed-by: Logan Gunthorpe Cc: Matt Porter Cc: Alexandre Bounine Cc: Lorenzo Stoakes Cc: Jesper Nilsson Cc: Christian K_nig Signed-off-by: Andrew Morton --- drivers/rapidio/devices/rio_mport_cdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff -puN drivers/rapidio/devices/rio_mport_cdev.c~rapidio-fix-resources-leak-in-error-handling-path-in-rio_dma_transfer drivers/rapidio/devices/rio_mport_cdev.c --- a/drivers/rapidio/devices/rio_mport_cdev.c~rapidio-fix-resources-leak-in-error-handling-path-in-rio_dma_transfer +++ a/drivers/rapidio/devices/rio_mport_cdev.c @@ -963,7 +963,8 @@ rio_dma_transfer(struct file *filp, u32 req->sgt.sgl, req->sgt.nents, dir); if (nents == -EFAULT) { rmcd_error("Failed to map SG list"); - return -EFAULT; + ret = -EFAULT; + goto err_pg; } ret = do_dma_request(req, xfer, sync, nents); _