Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp701078ybm; Fri, 29 May 2020 10:03:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylcvaWv/Fb+90QwpuEer4tuG93SlARkYW1kRB1BGdcszy9oizROVCqO9I8Ycyi5oZmvVGw X-Received: by 2002:a17:906:f155:: with SMTP id gw21mr8393392ejb.388.1590771825000; Fri, 29 May 2020 10:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590771824; cv=none; d=google.com; s=arc-20160816; b=j9uvju4YISb/PMVJ15yK+p55fJulvDMuLM4NvpPoLywIXYGvQ8I0tyic4Rsv1e21KY uUFOGGa3zDMUV8stk1Uwzpj97N1+Ej0GOx1jd3JazUJ1D6RUYJB54PFNl6EUqyUFAMTU Bo1HcD+N8hDcPXIjy7QfAShviwHfXrqoT7PK4sCpX13rJbaOl9Zt+KLXJ2HDyUomR6GF Lo3zWY2jnreex935WyfRYrfINEcBjRe6iQdaS+2i0tae1gyH3WniX7ypd4nvGaJygfhH 29tefwLmIUh40Dkg2TR09Bej7MKzGTeZhsRobgc4H3Jx/IFzYnmJxR+5bKyYUgpTl/Rh 1/KA== 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=86iZN/fpp5PCF98K69UKzJAZA1tKM0+S010WABMG7/c=; b=ZJ0bXKG2x67kh+GhUSkKOs9rrAI54jiV13aO+b36LODqownFGNUOcf3Fk02YDIOlUn 717vZtg5ygiPDnl47QPTtcVtShF/FWLWjyCaJNH3K1NQZBxk64J3mpBtlYva/HTRWLxu Bh46LvGM3APmFNlpwF5mGLlJdSINjmHmtZJHKprSp0h2ClukDzohEOPumMWO9//V90oY 1FEqhcFf2ZkppVOehc03jlBbvKyBpuLdMKsx2BbQ1Z2wg3mm3Ot4JAz6hx7TScMx9HvA kaD/UwfBc6/2kHVr9W+M3XhGErRjtlKXkdwDYF/YlhYrgShkt+h20lGclxJIqRImH2Av LX/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o1BepfCS; 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 u24si5491949edt.170.2020.05.29.10.03.19; Fri, 29 May 2020 10:03:44 -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=o1BepfCS; 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 S1727090AbgE2Q6z (ORCPT + 99 others); Fri, 29 May 2020 12:58:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:49340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727062AbgE2Q6y (ORCPT ); Fri, 29 May 2020 12:58:54 -0400 Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (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 3F6662077D; Fri, 29 May 2020 16:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590771534; bh=6tlfi/KlQAH4pctyASY3wzp34+ZnDnmq+U8F75IPPNA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=o1BepfCShtq/KsiMAGkedLZ/uPQFjJp0GSr5eUCWjKrkcXgJyr7qW6G4LRCpItAVO QcwMYsdtQcvPCBA9tfWHkMt4Zr8XEYAFRKHYxhiNMzj5zIbgbzjR+YQB1TZCT2WEh8 CQ6il1G6NyM8YWfrtvU91cjWCc1Ggh4YWfq0Xxqk= Received: by mail-il1-f181.google.com with SMTP id h3so3134587ilh.13; Fri, 29 May 2020 09:58:54 -0700 (PDT) X-Gm-Message-State: AOAM5307j/bSSzwhlv9WYMvdSP6nxv1ZtYnM1sjVuP1Rs8boWl8RtSoG zwE4LAKOBMbpiTBG5gZXQDTjCIKp5od1Xl9Z+QY= X-Received: by 2002:a92:5b0c:: with SMTP id p12mr8320222ilb.80.1590771533668; Fri, 29 May 2020 09:58:53 -0700 (PDT) MIME-Version: 1.0 References: <20200528185920.7314-1-wu000273@umn.edu> In-Reply-To: <20200528185920.7314-1-wu000273@umn.edu> From: Ard Biesheuvel Date: Fri, 29 May 2020 18:58:42 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] efi: Fix reference count leak in efivar_create_sysfs_entry. To: wu000273@umn.edu Cc: kjlu@umn.edu, 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:59, wrote: > > From: Qiushi Wu > > kobject_init_and_add() should be handled when it return an error, > because 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. > > Signed-off-by: Qiushi Wu This one is already fixed in linux-next > --- > drivers/firmware/efi/efivars.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c > index 78ad1ba8c987..26528a46d99e 100644 > --- a/drivers/firmware/efi/efivars.c > +++ b/drivers/firmware/efi/efivars.c > @@ -522,8 +522,10 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var) > ret = kobject_init_and_add(&new_var->kobj, &efivar_ktype, > NULL, "%s", short_name); > kfree(short_name); > - if (ret) > + if (ret) { > + kobject_put(&new_var->kobj); > return ret; > + } > > kobject_uevent(&new_var->kobj, KOBJ_ADD); > if (efivar_entry_add(new_var, &efivar_sysfs_list)) { > -- > 2.17.1 >