Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4248511imu; Mon, 7 Jan 2019 19:06:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN7U1sC9Q8nyL0vXgNP9YoEi8Oo+M4NIZ4xn6Oa5y3vdFCuMyQjHu8p2aun9SC5mjQcv/vdA X-Received: by 2002:a17:902:8a91:: with SMTP id p17mr51946plo.316.1546916812561; Mon, 07 Jan 2019 19:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546916812; cv=none; d=google.com; s=arc-20160816; b=SgpDbp84scTo24Nsbl+Qsn3p+Z36W3kJrn4C4OBaLU+C92RaNAzSbowKHsEApp9PVv SGDne2dMLWRONJ6NDZ8+yuPn08qoq7HUNyGP1k6Pkr1v1MaodV6lIuBI0DtY8gjvhLxZ Zkyx/qmUOmAxe9OP2KnYZr5srQz5Ivezgtj48JBY7I7JOoZI6NDNKitGr3FxbN0tUKcT c38z4BS9Ajb326et+nsOEzmuEHE2BlcIUwVDs9t3vmnWNLZQwzloW6rQZHoMYRdif3BE o01s/aJMtJkKzI78gyyRwkCGM+G7flummxwOu92cP041/VGWqSg1kI7IkM4b4spilEY/ Oylg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=UKVLJHQTqsDWzdK01TvqgiQ7pwxbjXaSM02dF5TAoT0=; b=svlw0/qgPRMZeFWJTqZWMnyH77+S/eppoY8DWu4PZEmmjJXa+/g82Nu7Icw26GheIA J30CorPvbNWqT6/ZXIHRzmg5FU6vxxnfPXTzBI1ZQaM+NZREuIPBsSg/xnor/EbPnKSh 52sMTSzTwGyAGm2Hc02qL6AyUQu4kMQ+eRw9tswV+nj1zNbLb/5nhSC1EKwtx5YIGKpP W+c4hjhRhxA4Y2NU/Z1vNT21pCVILQ7boZO4XfL8msw7G9Uai/iVZJ/nBVVXTJFEMU6H vX15HAXeslqqx+gGKjTK+CYIML7Q5VBQN5VSYONO9wUTVqrYc0maipbHWV0XsLn+aS/k oVpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd3si62227879plb.286.2019.01.07.19.06.37; Mon, 07 Jan 2019 19:06:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727423AbfAHDBL (ORCPT + 99 others); Mon, 7 Jan 2019 22:01:11 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:17123 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727051AbfAHDBK (ORCPT ); Mon, 7 Jan 2019 22:01:10 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3CD36B6B0D1FE2ECD628; Tue, 8 Jan 2019 11:01:08 +0800 (CST) Received: from huawei.com (10.175.104.208) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Tue, 8 Jan 2019 11:01:01 +0800 From: Liu Jian To: , CC: , Subject: [PATCH 1/2] driver: uio: fix possible memory leak in __uio_register_device Date: Tue, 8 Jan 2019 21:01:47 +0800 Message-ID: <1546952508-186003-2-git-send-email-liujian56@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546952508-186003-1-git-send-email-liujian56@huawei.com> References: <1546952508-186003-1-git-send-email-liujian56@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.208] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: liujian 'idev' is malloced in __uio_register_device() and leak free it before leaving from the uio_get_minor() error handing case, it will cause memory leak. Fixes: a93e7b331568 ("uio: Prevent device destruction while fds are open") Signed-off-by: Liu Jian Reviewed-by: Hamish Martin --- drivers/uio/uio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 1313422..7280552 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -940,8 +940,10 @@ int __uio_register_device(struct module *owner, atomic_set(&idev->event, 0); ret = uio_get_minor(idev); - if (ret) + if (ret) { + kfree(idev); return ret; + } idev->dev.devt = MKDEV(uio_major, idev->minor); idev->dev.class = &uio_class; -- 2.7.4