Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7348448imu; Tue, 22 Jan 2019 04:39:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN78eDMGGoku/g9HBrIAo69E5UseZOVgyd5jbFbNBeWroJXpYmY0m62mcs/Z9A8y8PZ1UPfj X-Received: by 2002:a65:6684:: with SMTP id b4mr31929591pgw.55.1548160795386; Tue, 22 Jan 2019 04:39:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548160795; cv=none; d=google.com; s=arc-20160816; b=fBwufG53XXVqp24H/pwLKyWk8Vaq2Fpbwa5tMuAQTuDZfeOj3WIRkkXUYCwxRCrmMO RBVHdlPFa7GsjBoS87BiUVmmMhY/c2gOpcFicka1bUyG4DPsFlwL1ZG66+pT5a2oFXhX UJc2O68OKcuwIu4ySwvH5K7+LvVYXQtSLmPIuhGophphiscN33rVxV3a7KuhBowou6Xz p6WTZDiQQwkewjXVQAF4bUv2eT9HkiXupDNApLdQrjdiwAFHsLFwxe2Bj4ZBTCjpMJ0x TXHpNeaZ4mLG/M7icEkRGnUpHcyW7J2m0v9rU0ARoaGghOKKpGomEWo/qiANTQdCJTma CcQw== 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=WXgHImjFGo4fO+Y0XIp2bHNTPnAINNJsMdSa1yL7pKY=; b=oY6omQJMW0LQOaF9OLSHLSqQu2vnyvvP2fqY1H261p1Tszstelq7fOBgZ4jWvP0RkF RWUd7P4SeUWm/o9JfRie78uojardTPujwdwF8WrMzRmemkqFZhK9hNd+Zl6TIPmLBoh2 LdtUxiOdgk53gzozWnZNseEca5TgWatCvAtgFLdIdplTa11G9HGPkLQaCB+gUXJjHQKF OjFQ0uGB4pJAS8owNglVFRM2GsAp3dt0Efnn2iBltG8dYz2HOujPwBw9hN2chGCXuaav 4rNhRfu6aVBhttCT7t5c0F5rPI9jmbHdrcJz19EerGv80SI5VKcHtxe0bQ6QE9FgDdi0 JFpQ== 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 w16si10163255plp.321.2019.01.22.04.39.39; Tue, 22 Jan 2019 04:39:55 -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 S1728431AbfAVMiQ (ORCPT + 99 others); Tue, 22 Jan 2019 07:38:16 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:41476 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728417AbfAVMiQ (ORCPT ); Tue, 22 Jan 2019 07:38:16 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6EA525587D8FE7E92D81; Tue, 22 Jan 2019 20:38:14 +0800 (CST) Received: from huawei.com (10.175.104.208) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Tue, 22 Jan 2019 20:38:05 +0800 From: Liu Jian To: CC: , , Subject: [PATCH v5] driver: uio: fix possible memory leak in uio_open Date: Wed, 23 Jan 2019 06:38:24 +0800 Message-ID: <1548196704-352035-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 'listener' 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 v4-v5: correct 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