Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3593215pxb; Mon, 24 Jan 2022 13:03:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYuyipPnTYHeLS4ZDASSm46qjAdk0aiNTnHT1XEu0O3BAaH2kp/fBZar7OjseWSunentdK X-Received: by 2002:a17:902:ab8f:b0:14a:adaa:93f2 with SMTP id f15-20020a170902ab8f00b0014aadaa93f2mr15617032plr.131.1643058229297; Mon, 24 Jan 2022 13:03:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058229; cv=none; d=google.com; s=arc-20160816; b=VPby8ESJIVu3yluwA+vk8PoNd1fIwGgWob00ysBd+iYbmhb1rd1P92TXUVFYdu67Kz VwV9g0lVvSaf9iOCt+pA7hcsXKOScwJ6lnBpTfbn6z5h5qt7bxx6kL3yE4SQ5FoB1qAq AoHUNJe/M5T6Ey/0Am6BhbXxx87GPtt/jA3EQU96Rf6p75ujk9NQy8+k7Y/lGOAJmEsU J+GLa57XDnatzwcM7PQT+Y8wkE88eUGbGhhH201sdO/wlOaDc4OwxepmK7mggijTmG08 Y8w/nKENmC1MTWJy49bqe4sPQP2pNXv8ZNkezaBa+3jq1i3txN6HyDwQZplvq296xOmN XkFA== 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=smb6Q7VRjUSNrKcIh+4AkEQwpavq/Lkqq/LQl92meF4=; b=iGcAHgHIabd5TYRDg0VBRrfRcJKEdrjpCYg7AVeou0eEkFS4+K1OEZG0sWm8P+tZHU K9bQGOjOjJDuwUZrH4h0hTbpeZOxIUc8qEHF+QY48xa6HzCP4Bcx3QfXegJcmNezza0v a8VCowBAvXFUwpl0eK1dejXflI0GVtH+nkiRQVVO4nxNGEz2lpBwnxAAQJ1Q22ycSV1a hRu05BkQICqXcp6ISLHp4E2UBS3caRvxuAl/v99fj8yFAPL80CQsYWM8UQ50KAzEzlGu Vv/YEJA7hyRpmfNladRdOEOuEQOhy6MB13Qr8guC7soiXpBK7nnkKzp45UIKkqyu7d01 4YxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=loPmA3Vf; 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 l5si12648916plt.395.2022.01.24.13.03.25; Mon, 24 Jan 2022 13:03:49 -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=loPmA3Vf; 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 S1383554AbiAXU1W (ORCPT + 99 others); Mon, 24 Jan 2022 15:27:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357833AbiAXTvz (ORCPT ); Mon, 24 Jan 2022 14:51:55 -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 654B0C041890; Mon, 24 Jan 2022 11:24:39 -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 05AB36129A; Mon, 24 Jan 2022 19:24:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0067EC340E5; Mon, 24 Jan 2022 19:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052278; bh=sGOvretFgauqF2/LGbvj1iZr7JxVo+3umuYUrti16Ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=loPmA3VfwmSWpFR5H+jGCQU2kZ3U1ll6fPVih3tkLU/r/0fEzhCsvaW1nc0WXEMlX eXEs0CNycmAZvjvl/sCAorpY9yxPDxKxvM3T1mlox13y3R0ji3uI5TWgffgexXjInY 8N2CA4hB9Lr1/ImDCYAYsFV9YqiXlNXwncdj/0wg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Helge Deller Subject: [PATCH 4.19 221/239] parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries Date: Mon, 24 Jan 2022 19:44:19 +0100 Message-Id: <20220124183950.132688245@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 @@ -992,8 +992,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);