Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754517AbbKWKfZ (ORCPT ); Mon, 23 Nov 2015 05:35:25 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:36617 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754287AbbKWKfV (ORCPT ); Mon, 23 Nov 2015 05:35:21 -0500 From: Sudip Mukherjee To: Matias Bjorling Cc: linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [PATCH] lightnvm: fix memory leak Date: Mon, 23 Nov 2015 16:05:11 +0530 Message-Id: <1448274911-8651-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 976 Lines: 33 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; -- 1.9.1 -- 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/