Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4278576imu; Mon, 7 Jan 2019 19:52:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5k+ODBKxmWxhly9HVDAEs6RqC0zTO9Ggl1MJufXWZOzA7Ict/ATDxClEv+X4ePFvZgTvsN X-Received: by 2002:a62:cd44:: with SMTP id o65mr160532pfg.222.1546919528203; Mon, 07 Jan 2019 19:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546919528; cv=none; d=google.com; s=arc-20160816; b=YTrpqBcV5/+e4gGTASNwk3hcpGDSFSRNvVyVwYjXkW1XSaP3gqVqsRQVWmUs+YXTXz IZ+QBB+B+0t18BRB39G2qC9Pklqb5m0fLTdUnDW/Ov95u6Hx8SvbtH29/3LkX92e4LGr 7Q9GJnlVDJueYME42nDAfEq7mgdvlFnZoJE7SXdvC0qgo0ImEeGjidmc7wCqH5fpvQCv EYIk1npRTGJkCN3IwpQ/4AB57iM3EXYRQrhOIy/+K7wMJlDBFwl7okDIs9dwB8QeNBkS kYNpioPjRt1IhVKslrcljUaUvJzX3JUhXaLl1WzI6b5ciStSZhKe7IsRP3E3q3nKnLX6 JETQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=Kx1Lh6C49/gfxgS93Nu+0Bbla38ibdGNOgRdjzLOz6E=; b=hCwBhn0k3FZeC02EtiZ4HOD0Jvr03Y4VlFHGxuXavBfyG3HtowLLC62TY2jOrXcB/6 F6bLqfDBeu940hOz7/xFGzQkdvHXLCJPdIaVI6j1AgkdrtyaTsHRO+Ei7APLpCFSxg3i kKYIEgS4j2nvvUpd1N2qq+PMmBbmtBhZD2d3FQCv8/zm3rcByj7s2M325rHQnty+7E6Q hJ+uBUiCR5GLCFhlJzxAPdEisQtJAqgcd9s3kcIyXdV2AogTvel4OtRuTtMcCX34jiBO RUTPLOK7JKlsrDdGl8/G8anI1cRZisX0h0wshSuhhWjTpFHPlrMiWgdeMBKDiM5rEFqA eDAA== 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 e126si13691739pfh.185.2019.01.07.19.51.39; Mon, 07 Jan 2019 19:52:08 -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 S1727430AbfAHDiG (ORCPT + 99 others); Mon, 7 Jan 2019 22:38:06 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:50758 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727030AbfAHDiG (ORCPT ); Mon, 7 Jan 2019 22:38:06 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 376BE17A2E0A2CA9A783; Tue, 8 Jan 2019 11:38:04 +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:37:54 +0800 From: Liu Jian To: CC: , , Subject: [PATCH v4] driver: uio: fix possible memory leak in uio_open Date: Tue, 8 Jan 2019 21:38:43 +0800 Message-ID: <1546954723-197902-1-git-send-email-liujian56@huawei.com> X-Mailer: git-send-email 2.7.4 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 If 'idev->info' is NULL, we need to free 'listerner' Fixes: 57c5f4df0a5a ("uio: fix crash after the device is unregistered") Signed-off-by: Liu Jian --- v1->v2: rename the "err_infoopen" to "err_idev_info" v2->3: put the extra info after the "--" v3-v4: add git log drivers/uio/uio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 1313422..b4ae2d9 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -491,18 +491,19 @@ static int uio_open(struct inode *inode, struct file *filep) if (!idev->info) { mutex_unlock(&idev->info_lock); ret = -EINVAL; - goto err_alloc_listener; + goto err_idev_info; } if (idev->info && idev->info->open) ret = idev->info->open(idev->info, inode); mutex_unlock(&idev->info_lock); if (ret) - goto err_infoopen; + goto err_idev_info; return 0; -err_infoopen: +err_idev_info: + filep->private_data = NULL; kfree(listener); err_alloc_listener: -- 2.7.4