Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp702386ybm; Fri, 29 May 2020 10:05:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdlQlYzooyg8+lgbpbYFjvlpuTEEi9g54mQQKtofCkOM2Cn8b1x99IFONLyw91nvI7j0uh X-Received: by 2002:a17:906:f1cf:: with SMTP id gx15mr8219202ejb.471.1590771917260; Fri, 29 May 2020 10:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590771917; cv=none; d=google.com; s=arc-20160816; b=imLO5rnXfZ9xq1s0cFgIYTSS0Fh3ptBhGqsd46KWQ/qBzY4JRrYmNOvk/+yK7E5Hjc bpP19Qbz+B8bc5ZsD94XZxM4S2oY2hbljgTgHLi+6GweSF4irvqrCQadpYRM09lVnrkq Z6CWm5rL8aBtQH3yjLN1G44cpq/2GyCLJ+uw1dZiSV1v9cJdhwHw2WJ9AsMIwXdTUJiL 2tdRTcZvMOrbJUR4htMtaRUKbz9IDk6X7MFZXFWMBYkFu/RhtVq5ZIFM/mbTNZUgE1fP rpZ/muUlyUMDLZD2iH9xQ/la0sevNuYrU89fGyekRaLvMIrpW6hVSMxMdTctH3m1GOUA 1qsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aN48iKqvQng7KoNjHR/TM/Skr64VUmQQskoffb+vE9k=; b=g07uhOXTcfIKeSEjECUCr6ZLXqucnjF22pLb0sw2/0ejheVqvs66Vz6HGP8f/cHAK6 BSpIlRLu8OhYcJi9n9Oc3ClflXSiMJkD/DCwFAAHOv2P4k16f3O42s6zQXj9iDcD1pQQ 1C3xzWxP2922Ckskp2/b/oS16mrhlXaMxWmdbPZkrYtRFh4qyA5ZcmnoToAV+pcw+lFh gZ7aaJ9m2pM1VzMNzUgB6Y2a+RulY25EhxO4/emAdrtr74jD8wGKx09YoLMIl5U2Zfzb w8GTcF9BaxLqsT7DzWJEAp5GySqiyop5XW0UaL1vF/eswYz0FYA2zvLjmpWWXyEDBpEU 5DmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="y/DC8EP8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j16si6006827ejy.558.2020.05.29.10.04.53; Fri, 29 May 2020 10:05:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="y/DC8EP8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbgE2RAr (ORCPT + 99 others); Fri, 29 May 2020 13:00:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:50810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbgE2RAr (ORCPT ); Fri, 29 May 2020 13:00:47 -0400 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FCC720723; Fri, 29 May 2020 17:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590771646; bh=6Y/1Q0Q2wmCQFvKEA1F9i6YDgw/p9PU/aktrD1/wuVM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=y/DC8EP8psJSBvA33c5yoTvtz9IzrRUIH6v9nj3yh2lV7l7rJmS598npf2hj/HZO/ cnItjYvNFdApUtLT9uE7lAWA32IPKtfpbaN7ckfj/xCAEhRREWDjiFIgSTvROjuDY9 9DFTNeNoA7yWrYrGrv3Y4tsKnBESid4iRW/tcGPE= Received: by mail-io1-f54.google.com with SMTP id d7so85296ioq.5; Fri, 29 May 2020 10:00:46 -0700 (PDT) X-Gm-Message-State: AOAM533ryn7W/WlZbdO3Ko0hmQd1qlQjweF2sgGpYs5GXMjvbBthEPdU xRUnKx3COuuJjSIrPzItr8MD0BUb2DGqsxOW4DA= X-Received: by 2002:a5d:81d7:: with SMTP id t23mr7599076iol.142.1590771646041; Fri, 29 May 2020 10:00:46 -0700 (PDT) MIME-Version: 1.0 References: <20200528183804.4497-1-wu000273@umn.edu> In-Reply-To: <20200528183804.4497-1-wu000273@umn.edu> From: Ard Biesheuvel Date: Fri, 29 May 2020 19:00:34 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] efi/esrt: Fix reference count leak in esre_create_sysfs_entry. To: wu000273@umn.edu Cc: kjlu@umn.edu, Peter Jones , Matt Fleming , linux-efi , Linux Kernel Mailing List 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 On Thu, 28 May 2020 at 20:38, wrote: > > From: Qiushi Wu > > kobject_init_and_add() takes reference even when it fails. > If this function returns an error, kobject_put() must be called to > properly clean up the memory associated with the object. Previous > commit "b8eb718348b8" fixed a similar problem. > > Fixes: 0bb549052d33 ("efi: Add esrt support") > Signed-off-by: Qiushi Wu > --- > drivers/firmware/efi/esrt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c > index e3d692696583..d5915272141f 100644 > --- a/drivers/firmware/efi/esrt.c > +++ b/drivers/firmware/efi/esrt.c > @@ -181,7 +181,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num) > rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL, > "entry%d", entry_num); > if (rc) { > - kfree(entry); Why are you removing this kfree() call? > + kobject_put(&entry->kobj); > return rc; > } > } > -- > 2.17.1 >