Received: by 10.192.165.156 with SMTP id m28csp1079798imm; Wed, 11 Apr 2018 12:02:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+c1LKNtdd015a3YBJ9N5Iq5rF4Y5maMWhWjHujNdHjGE9deezJ5RpZDp9cHh6EkKGfRcP8 X-Received: by 2002:a17:902:8501:: with SMTP id bj1-v6mr6445699plb.239.1523473353381; Wed, 11 Apr 2018 12:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473353; cv=none; d=google.com; s=arc-20160816; b=G2+aAx82Y44amBIgfOgxCYZfGNFfnKDcb2Qq0fCH8Rcq5JFsLmOgrsCmkcCZ2Wzxv0 3aZPzj4L33KFlSRbonXX011C8pyhKwzPNWWpxcu8x3d4vVGiIsMnuEKuGStvmkNsIDOR Nc83BPXEVUrm+k5+H9bV6JKPZpvhHbUaX16FGjUmdTzgJak2QfZ1S5WdBROKIWFz2YZm H4/GRkEI8tu004ms0ittmpjFy5/Wpc8gkVRY3lBM0dfi9oM0QL86D/EUu7vxiQLe3YTM X6jhGUSceJDwLjU7slBYQjeDrnHgwJ7MBctW/NvEtFm+Lyld3Tl5pNmpIkYdFEwG4Uwf y8EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Im2uLmgXNJMqTNL8mPARNI9A4lqc8qYnEZSdJZrNFdk=; b=fPAX7ccDm7VdDB9ExEMfrseNROR8SuhHMWfocEerdXb0bKBQRwWVJfVM/4q5pN3HIm Ws+olGR9jtOeYUwnced3YgN4r8vNaYrZrwBOpRWgdlQskPQ5zhOQrya5bZroN2og4Ily N0pi+0FtVoWpo3drcFF2tTEwQNBQL8Z0diP6WxawnU1zkf6+0XhM3/LMYip7gRuro7ju nefeaeTHFm85M/l2fCgt00zToKE6IESfNTdohjyD081td8JaIfbJrDs6/rtuR2T9SA5H DKeQkdAvQi+jHouYLkCb2B+Y609glcdAR0tDd7UGxLIhcxASzi2gXN7YoWLstDdcwHTL qV2g== 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 z23si1142014pgc.484.2018.04.11.12.01.56; Wed, 11 Apr 2018 12:02:33 -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; 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 S933692AbeDKSzT (ORCPT + 99 others); Wed, 11 Apr 2018 14:55:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34946 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933673AbeDKSzQ (ORCPT ); Wed, 11 Apr 2018 14:55:16 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 74AC3C07; Wed, 11 Apr 2018 18:55:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suman Anna , Sasha Levin Subject: [PATCH 4.9 061/310] uio: fix incorrect memory leak cleanup Date: Wed, 11 Apr 2018 20:33:20 +0200 Message-Id: <20180411183624.855470858@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Suman Anna [ Upstream commit 0d83539092ddb1ab79b4d65bccb866bf07ea2ccd ] 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -279,7 +279,7 @@ static int uio_dev_add_attributes(struct 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 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 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 goto err_portio_kobj; ret = kobject_uevent(&portio->kobj, KOBJ_ADD); if (ret) - goto err_portio; + goto err_portio_kobj; } return 0;