From patchwork Tue May 9 23:58:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 98957 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp2075320qge; Tue, 9 May 2017 16:58:56 -0700 (PDT) X-Received: by 10.98.87.203 with SMTP id i72mr2887069pfj.151.1494374335914; Tue, 09 May 2017 16:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494374335; cv=none; d=google.com; s=arc-20160816; b=wko/P/TBf9HJFGoXQJL0qt3G2nhNPVyCulOJzX7auTfMWWlmFjQ1yVLecxXkMNt8ES uUeZqRWj4Eodht5LWbrLHKCCzTfubAwwAhICLbsTEBYblWXYaIdJKLZCLb/BveVYrCYv 01Wpv9+HSd7fwdbrWmslARjo2QHynrkVUoBBNsQy17bYdmyB/JvnfNsw35WtcctWiyXV m/5MoPR8+yrZp3tDfpkg01d4IvhtbHtkOnF5dhVI8GKYX1FWuGUAvlmPkOtTqxPuBX/8 rBG6rAIxYPhmnjf+IWlh+ugSYmOKJkuKwdiFpSABokWND5YOGFiI94Bzbra3cjK6wK2/ ESDA== 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:dkim-signature:arc-authentication-results; bh=3IK54An9Vx1VFnUWpC4Lk5pmv22ZpaSiezDaO26zKAY=; b=mYypmWmW0V5A9yStVgWoZ+hGoLRPZfDFHTJVefadueBLtyqE3tDIAMahm7JsQJ9xe/ 0OHGoRI/WHS0KYQXsFF3iJetYajG2djxmYMCf52GIYpJ9eg+Pi1/OZ34GWDQd6HaBjQi qtNW2gQLHKgadqggS3X4uaxPMftnGhqN0T7UX3566fKlh/xr8Sw9oUyGn+RhgufGg+vl utoGekGZIEMRa1beHQYi8mX50C3bkPjIBWOVQwjVnJEGJGcOe8KgN4y4Qq+fkrfJqYtX S/OJBe0A1pTW+oulop3girgaRGCFOdGLZaWX6DqMZtU/p3eaoTkRqFt3TYALNfzWSGGs 5aLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si1358894pgn.129.2017.05.09.16.58.55; Tue, 09 May 2017 16:58:55 -0700 (PDT) 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; dkim=pass header.i=@ti.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751043AbdEIX6g (ORCPT + 25 others); Tue, 9 May 2017 19:58:36 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:21876 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750733AbdEIX6f (ORCPT ); Tue, 9 May 2017 19:58:35 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v49NwYYc007823; Tue, 9 May 2017 18:58:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1494374314; bh=YNTQUoVn7vpjyI8XjiiY6mP6lTsou9Dk0lqXjhhAMb0=; h=From:To:CC:Subject:Date; b=H2ZvtdfheuNMyyTcXz/UbA+IusNsSiYQqYzHvWm8GDM4k/Ruvq1WEXqZCWb37UVW5 tD1UhUGUUIDk7d8vtKgJNECDzsn+NW6zTwz4W2S54igJcOEO9iq3fz/EYI83cOLAom PKlAsZUtXh0HorVj5CcyxYrnr1jsfYk3veB22I2o= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v49NwYiE002141; Tue, 9 May 2017 18:58:34 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Tue, 9 May 2017 18:58:33 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v49NwXWE016341; Tue, 9 May 2017 18:58:33 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.167]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id v49NwX321265; Tue, 9 May 2017 18:58:33 -0500 (CDT) From: Suman Anna To: Greg Kroah-Hartman CC: , Suman Anna Subject: [PATCH] uio: fix incorrect memory leak cleanup Date: Tue, 9 May 2017 18:58:24 -0500 Message-ID: <20170509235824.43458-1-s-anna@ti.com> X-Mailer: git-send-email 2.12.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 75f0aef6220d ("uio: fix memory leak") has fixed up some memory leaks during the failure paths of the addition of uio attributes, but still is not correct entirely. A kobject_uevent() failure still needs a kobject_put() and the kobject container structure allocation failure before the kobject_init() doesn't need a kobject_put(). Fix this properly. Fixes: 75f0aef6220d ("uio: fix memory leak") Signed-off-by: Suman Anna --- drivers/uio/uio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.12.0 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 1c196f87e9d9..ff04b7f8549f 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -279,7 +279,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) map = kzalloc(sizeof(*map), GFP_KERNEL); if (!map) { ret = -ENOMEM; - goto err_map_kobj; + goto err_map; } kobject_init(&map->kobj, &map_attr_type); map->mem = mem; @@ -289,7 +289,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) goto err_map_kobj; ret = kobject_uevent(&map->kobj, KOBJ_ADD); if (ret) - goto err_map; + goto err_map_kobj; } for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) { @@ -308,7 +308,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) portio = kzalloc(sizeof(*portio), GFP_KERNEL); if (!portio) { ret = -ENOMEM; - goto err_portio_kobj; + goto err_portio; } kobject_init(&portio->kobj, &portio_attr_type); portio->port = port; @@ -319,7 +319,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) goto err_portio_kobj; ret = kobject_uevent(&portio->kobj, KOBJ_ADD); if (ret) - goto err_portio; + goto err_portio_kobj; } return 0;