Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp578833iog; Mon, 13 Jun 2022 08:29:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v5nbqt7FfVG4PXKoPw3UdDjTA/gMy2xoXnlu+TQmvc28wbo1pTB81xKF784d0MUaASISI8 X-Received: by 2002:a62:8101:0:b0:51b:b859:7043 with SMTP id t1-20020a628101000000b0051bb8597043mr129598pfd.25.1655134195524; Mon, 13 Jun 2022 08:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134195; cv=none; d=google.com; s=arc-20160816; b=HRleZ5LKMlyk+rtMTjZXBR8bZTflxecRnjRWTXBtGyvBZOSgFT/JGmSwVR3467bUBO S3AuNxqOslRTaWqIGvIRvXOZ7d4rWbVkqCvTyKBMITh4uB/POUce1AfG1CHRhQ15+1Vt ps7i8F2JLXWRKVntlQZxFdrg1NX71cjO7exveeXTAsyu+GoKOnFhVmYZye+mpx1pM2Gx //MMPItslCavZans40kwKT1Q6/p6hXgghcq2u17E7v6Ctlvn6fT8HosPk++7C7IavkUZ WJLjbsGUGG2glCA0UPaS5x4kQhoIsXWYeDaD3IttCnVHijx5Tj5UhO1VM8U6rG/g+zoV vjoA== 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=tuZWQgaQYTHtbvWi6Q4nhSwb/lKeX4HDygucjwK5LDA=; b=mIv7UqE086x9XLljz4H22CvPbn6IKMPKlh8fAkf6krSSb/Lav4PvA4gLJ6zgx9jRxz ++6LR55si+L8oxuLq95OIrqj7U1vlV9+JRfgwtsul5+azlQFzEsNo4Uzl1xYtPQOtvDs QGRBeeruz1XY+2crr7GhStj3I44BPOhFlbjO1xSrFfIzYEvQorMRZeUn5f63qTjrsLwp ahV2uSrNSXSDdyv6oktGiOuE+6N1gbqYI1jcRCg9aGYsII7jNVl25xpz85gpyJDh/kfA ud09AQYbcOve6WRwmSR7iehlYjAYzlUtDjg8KdI/xymmPLzDs5cDObnwLGV5/KTD1XzJ ncFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Uvo690n8; 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 g67-20020a636b46000000b004051d974ce4si9296547pgc.458.2022.06.13.08.29.43; Mon, 13 Jun 2022 08:29:55 -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=Uvo690n8; 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 S1355214AbiFMLhz (ORCPT + 99 others); Mon, 13 Jun 2022 07:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354998AbiFMLaX (ORCPT ); Mon, 13 Jun 2022 07:30:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A329340A14; Mon, 13 Jun 2022 03:46:14 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 3F54860FDB; Mon, 13 Jun 2022 10:46:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C0D8C34114; Mon, 13 Jun 2022 10:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117173; bh=Myz9vzViL/HBud6lFQmSkcpC+pwSlSnK5jjzbx/TERQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uvo690n8OVTDTvDPx7p0LAJuG9Av0GXQ4v1IQdpSAoPo/qKgLs+wg73g2pSPBgpJG aJAxfjEhhd2fJ/LHQgy25lG2GPUlChVcRULyT8C5TiAhFuDINtmRJ/Y06/9q2dvgGT 8BUXCRrw6suD/ysJ8qu1D+1NK0iZAb/Kz4RLQOLk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Sasha Levin Subject: [PATCH 5.4 315/411] firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle Date: Mon, 13 Jun 2022 12:09:48 +0200 Message-Id: <20220613094938.187946773@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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 b6180023eba7..2858e05636e9 100644 --- a/drivers/firmware/dmi-sysfs.c +++ b/drivers/firmware/dmi-sysfs.c @@ -603,7 +603,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