Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753723AbbKWQkR (ORCPT ); Mon, 23 Nov 2015 11:40:17 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:34561 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751672AbbKWQkP (ORCPT ); Mon, 23 Nov 2015 11:40:15 -0500 Date: Mon, 23 Nov 2015 22:10:01 +0530 From: Sudip Mukherjee To: Matias =?iso-8859-1?Q?Bj=F8rling?= Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH] lightnvm: fix memory leak Message-ID: <20151123164001.GA7500@sudip-pc> References: <1448274911-8651-1-git-send-email-sudipm.mukherjee@gmail.com> <56532D23.6090107@lightnvm.io> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <56532D23.6090107@lightnvm.io> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1513 Lines: 44 On Mon, Nov 23, 2015 at 04:13:39PM +0100, Matias Bj?rling wrote: > On 11/23/2015 11:35 AM, Sudip Mukherjee wrote: > >If copy_to_user() fails we returned error but we missed releasing > >devices. > > > >Signed-off-by: Sudip Mukherjee > >--- > > drivers/lightnvm/core.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > >diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c > >index f659e60..6688b60 100644 > >--- a/drivers/lightnvm/core.c > >+++ b/drivers/lightnvm/core.c > >@@ -721,8 +721,11 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg) > > > > devices->nr_devices = i; > > > >- if (copy_to_user(arg, devices, sizeof(struct nvm_ioctl_get_devices))) > >+ if (copy_to_user(arg, devices, > >+ sizeof(struct nvm_ioctl_get_devices))) { > >+ kfree(devices); > > return -EFAULT; > >+ } > > > > kfree(devices); > > return 0; > > > > Thanks Sudip, it seems like this error is in some of the others > ioctl's as well. Do you want to send a patch with the fixes for them > all? I can find a similar error in nvm_ioctl_info(). I will have a close look tomorrow and send a patch. Is this patch applied or should I send a combined patch fixing all these similar errors? regards sudip -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/