From patchwork Tue Nov 24 13:26:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 7690801 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CE35DBF90C for ; Tue, 24 Nov 2015 13:28:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 017CC206F6 for ; Tue, 24 Nov 2015 13:28:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73042206F9 for ; Tue, 24 Nov 2015 13:27:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753974AbbKXN1q (ORCPT ); Tue, 24 Nov 2015 08:27:46 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:37666 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753778AbbKXN1N (ORCPT ); Tue, 24 Nov 2015 08:27:13 -0500 Received: by wmww144 with SMTP id w144so26341749wmw.0 for ; Tue, 24 Nov 2015 05:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=RUACsMlfqhA1k9sxDgvFlktvj2YFXb+QpWx+Y8oxQeg=; b=rtxXokybjKnKt9oUuumJo79HAS1+20MHmyCoyI5tP1tG4mqfjFKNsHtdd8IvVTdT+6 gVzP6i1eH0mB5tXqurgiv/2StgwIFLiH+hp/82HvbjwT8cJR9BRVCsVNt/7BE50f/8Md C7VQseNdq1CYZIpUIx+RTI2AXLh5hqI2G6WZw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=RUACsMlfqhA1k9sxDgvFlktvj2YFXb+QpWx+Y8oxQeg=; b=Ug01928WhdEqwrvy8z02fzdQ0tqjGvnlLhBaKHG7XF17MpdNVCujeOe8SN1bo6Og5A P50uO1qW2D5xTRgmSvxhjJMNnrEO62Pn+UIyIcSz1tf4rjAkb+KGiqNoBcs737pet8cZ NOR8Pu8gxrDic18Bbmm3fu5FcmHtWalzTKdDs6YG58+9+UZRPE7evZKUZdTrfHQJZ+RE eSibhPwyTlhbQWe3/7Xsv7RRdgv52KXOMM3fIGlBxBWLLk4BW+syLRXiQ0I/yrrBp+ZX 45WOow/ZsJdUWAnuZfUPdTfO+5k8v5HOIB2oDC7z6RQtcVdlb/ZpfDFkak2LBOk1OXMI FenQ== X-Gm-Message-State: ALoCoQkbpLi7kF1iggvJNEu5BAz+QDvKYVWfAQn/jw8BcNL5VEV2D6BcoUQnTYdmXBjTumLNCHP7 X-Received: by 10.194.185.234 with SMTP id ff10mr36656293wjc.170.1448371631718; Tue, 24 Nov 2015 05:27:11 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id w67sm18215045wmw.17.2015.11.24.05.27.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Nov 2015 05:27:11 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: hch@infradead.org, keith.busch@intel.com, sudipm.mukherjee@gmail.com, ww.tao0320@gmail.com, Sudip Mukherjee , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 4/5] lightnvm: fix ioctl memory leaks Date: Tue, 24 Nov 2015 14:26:47 +0100 Message-Id: <1448371608-18053-5-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448371608-18053-1-git-send-email-m@bjorling.me> References: <1448371608-18053-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sudip Mukherjee If copy_to_user() fails we returned error but we missed releasing devices. Signed-off-by: Sudip Mukherjee Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 5178645..ea50fa5 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -680,8 +680,10 @@ static long nvm_ioctl_info(struct file *file, void __user *arg) info->tgtsize = tgt_iter; up_write(&nvm_lock); - if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) + if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) { + kfree(info); return -EFAULT; + } kfree(info); return 0; @@ -724,8 +726,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;