Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3678505pxb; Mon, 24 Jan 2022 15:08:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyl0xA4NuDylobACJx8bl5FWDHP2gyTi1Hlgb8Nqd21IHMIZuFhSEwI5TK6As2xZ1Bz4RvI X-Received: by 2002:a17:90a:428f:: with SMTP id p15mr585145pjg.132.1643065718403; Mon, 24 Jan 2022 15:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065718; cv=none; d=google.com; s=arc-20160816; b=s0ubJ5Aj1SaRzGi2Y5I+1UwraTNswnAKCQDL93mq008RD2inD49irpEx0szsKdnqQO UR8d2aRBFa93Ye3GoYqXJewalx2qRV2hLLUXVXhNjc8VW/zLY2ObBP8hJffVrIDXrGk2 4nA6LXD6gkPt1A5Xac2buVpzWgSLX7Ek3Eu2U9xKZePoRh+ArM8EvzuV+c2t/XxYwCHv vUB36Lqj3x2ZvuzjpUmGBKqBNhEUSaHBgOqsw0LyuQbOcwEuO3OmCBqsgKTGVVybo3r/ /Xramuqqk0UVnEDlYUcXze4F9oB8xjdPm8KtbqfE0Wur2feBflNy27lEUzZ4Ec+F7u9H jzsw== 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=neCYLovQTF2VL6DDNVAWB/GynJLSb+MrNMr4qwlPBzU=; b=Turk7h1lVNX58evKYC6v5MDyxvcQ+XJAS6KoSjjfi9488nF/pbY3xnvwa9qhsueCTN mMOgghCNDJPS1IhyIGRvuefKEOVdUJPrwJxI/NBnaJ+CrytwyRcbkUqHqUs6VtS08qVc qaq6BzJfiHInL7/2GQgcPY5OLF2S22pTkv9WDwAzwqAMYYWKVxAy44m1Mvav17O+Ssf+ dlFwwtL/iAHhUFNZEvn9yY+YMacodGAPSVEYreo1thztQ5/s9nt4ON88sCWVdelGvSGt 6ArKoJTrINlxZ8YvsSuNAvqDzGIffFt0fEUoBIbHJ3Z4AoUciUQQ+dCopOCFHza0bVYu J3aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BZ4ArYuB; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si12688102plq.475.2022.01.24.15.08.26; Mon, 24 Jan 2022 15:08:38 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=BZ4ArYuB; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1843716AbiAXXF2 (ORCPT + 99 others); Mon, 24 Jan 2022 18:05:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1583332AbiAXWRi (ORCPT ); Mon, 24 Jan 2022 17:17:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 492AEC0613A0; Mon, 24 Jan 2022 12:48:43 -0800 (PST) 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 D93A060F54; Mon, 24 Jan 2022 20:48:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE361C340E7; Mon, 24 Jan 2022 20:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057322; bh=x1ittnNsJWwt1zDpNreQd8A+qpmVXaypmHKKZugegkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BZ4ArYuB9T4b0bx0JEfxDhTLguJTgNSOANWXI4oz4DKuP4fGetEuMuw9WCUqV/VTm CSZjp/CrPH61alOdz6Y6siZzsrH7EUU1plOIuELPBlDFXcR55AfpjxB8kN8+x3y1nR 8F37/gOe8yLS2LECx/kSb3Ri6t3ekSpWOUB6FIzY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Helge Deller Subject: [PATCH 5.15 774/846] parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries Date: Mon, 24 Jan 2022 19:44:51 +0100 Message-Id: <20220124184127.661919511@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin commit d24846a4246b6e61ecbd036880a4adf61681d241 upstream. 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 memory leak by calling kobject_put(). Fixes: 73f368cf679b ("Kobject: change drivers/parisc/pdc_stable.c to use kobject_init_and_add") Signed-off-by: Miaoqian Lin Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/parisc/pdc_stable.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c @@ -979,8 +979,10 @@ pdcs_register_pathentries(void) entry->kobj.kset = paths_kset; err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL, "%s", entry->name); - if (err) + if (err) { + kobject_put(&entry->kobj); return err; + } /* kobject is now registered */ write_lock(&entry->rw_lock);