Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp632825iog; Mon, 13 Jun 2022 09:32:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4sgA7vQi0ZyuZnDlcVSkBiLWvCWngpucwoZ+3qGyCsrNtewUoR5v5vN2BEyx21mw8asuJ X-Received: by 2002:a05:6a00:2344:b0:51c:157f:83d5 with SMTP id j4-20020a056a00234400b0051c157f83d5mr163630pfj.5.1655137940229; Mon, 13 Jun 2022 09:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137940; cv=none; d=google.com; s=arc-20160816; b=X4eg9UDav32GuW8JIH8yLUjqzhJVpL4ygJKpmRygUPH5t2cj/e/EHEjKGbUq2oT2m3 d1BpsCLgFCEZWx9OnZH975Hv+cD9H9r1OiiCt+u+ev6/YskuNdR6CUbkWmFPBEXxNGZw qetHt2CXwW35W0YPHjLyCfkn22Lva6SbB9cv/FKpoxxntet3Vf2sgrSf/dat7+KnNHSQ Vf0vfnyyFcu5moh5IQNZstmR3hH66dkrnWxMts5rgDzgoXUexaVhCJ3j/d1b2rm1TbtJ xjDEepT/RNrZfaTQucjnJHQ3mmD17jmMgkE4KitWivgf0KoaKq8eSKlg/PbN2LFeGxh4 16SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EBb1y7wmN5g7kWDNS3FGeyvOMJ8Nocsj9LNaPlW6pwc=; b=cobtdzJafQklHaVKmvz7NDeNndzU6alIBM7fxE99NzT0nOB0uyFaLv4r43k4sFnfaC HHjTNJoKMzcKBG8UTckj9WtLel8v4fHrh/piLY5WfxrrK81ozBv1B1+c9LXHsZaxcaAT l4ww2cG2E1gkTo5stDN1edEPZGxiFN/SRU3z860v64MjQlGapvYlRIrvHEa1LyPzL6EH mbTCnUnv/8+BVlKR4T2+vCeHacOFBZxDXUgbR1W8opVVKUp1nCW8zCtcqnT2p3idwOMY ZMQQCs9FRd9jF9pAKDth9XGiXI3BLH/pp510E7VpQ/sBwygQiICmT6aPqTdZVtJqJIhf TBUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tBgW3YJx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020aa79285000000b0051b4e546a3fsi8448210pfa.242.2022.06.13.09.32.07; Mon, 13 Jun 2022 09:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tBgW3YJx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245468AbiFMK1o (ORCPT + 99 others); Mon, 13 Jun 2022 06:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242862AbiFMKZN (ORCPT ); Mon, 13 Jun 2022 06:25:13 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03DD520F56; Mon, 13 Jun 2022 03:19:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 684C0CE1171; Mon, 13 Jun 2022 10:19:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AD33C36B07; Mon, 13 Jun 2022 10:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115569; bh=rqe1LHISFnnv3Z/S7gTCTi4SI/ic37tYHlVQ+3h2UqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tBgW3YJxeoKAgWB94JMOsMkA9QhPV630OtdV2K0FrSR/DQFIrG5yYIokRdEym01U0 IcEPtPaReXGHo4U+dXfPFR4Ll46+s6xS1KFQGHo1mZq1PBQ4cBSDE6CnnNACOgcLLq Q2BLWnGyhJjkvMRph3akpP3JhhXrQwxa2SRNvstk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Sasha Levin Subject: [PATCH 4.9 121/167] firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle Date: Mon, 13 Jun 2022 12:09:55 +0200 Message-Id: <20220613094909.163627244@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin [ Upstream commit 660ba678f9998aca6db74f2dd912fa5124f0fa31 ] kobject_init_and_add() takes reference even when it fails. According to the doc of kobject_init_and_add() If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Fix this issue by calling kobject_put(). Fixes: 948af1f0bbc8 ("firmware: Basic dmi-sysfs support") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220511071421.9769-1-linmq006@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/firmware/dmi-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c index ef76e5eecf0b..37f76daa2b3d 100644 --- a/drivers/firmware/dmi-sysfs.c +++ b/drivers/firmware/dmi-sysfs.c @@ -601,7 +601,7 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh, "%d-%d", dh->type, entry->instance); if (*ret) { - kfree(entry); + kobject_put(&entry->kobj); return; } -- 2.35.1