Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754553AbbKWPNu (ORCPT ); Mon, 23 Nov 2015 10:13:50 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37062 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754413AbbKWPNl (ORCPT ); Mon, 23 Nov 2015 10:13:41 -0500 Message-ID: <56532D23.6090107@lightnvm.io> Date: Mon, 23 Nov 2015 16:13:39 +0100 From: =?windows-1252?Q?Matias_Bj=F8rling?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Sudip Mukherjee CC: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH] lightnvm: fix memory leak References: <1448274911-8651-1-git-send-email-sudipm.mukherjee@gmail.com> In-Reply-To: <1448274911-8651-1-git-send-email-sudipm.mukherjee@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1202 Lines: 35 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? -- 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/