Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3555982pxb; Mon, 24 Jan 2022 12:08:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1zZRvRA0/TBIfUpypmwojeqUczowLvtDTfu8dnnTSeW9GqJ72nRCUHbsbLQKFsA4zuuC8 X-Received: by 2002:a65:494f:: with SMTP id q15mr12918861pgs.333.1643054889106; Mon, 24 Jan 2022 12:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054889; cv=none; d=google.com; s=arc-20160816; b=pHaYf4UILsipOfcqXkgDGgk9d2+atQUVrGLDF2DUE7wkJVYPCKYHTYTQmICPuc2tJM 3Iv3HDyD667cQ4H9a9FFDHbXcTvuAABvEaG2066RNIl00kz4P6uPlrrl1hAXsurBnTra BBKiHJORjQwVQ434sew0hUZW/4UHHJl2ExC4BGARGqUGGKfc7Lq48ggpfebByrUEfeX/ WH9hMsYy1ssrX+tftQL3+6fDmTxp63yXJmRXtlSsW79pUr8qzVjSgQ+/q0FAmhgRJmfe cCeIRShKW7V/gV0sOP6Nmxwx3Guwpb3tN63Zyee0vc01enB8lubgbM9u8re5zsUS0Ce1 wNGw== 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=gQqHfWCx29Ouk8gvOma8GI0YTCc6I63/1G92AyItZ8mHz+93XzVgMqvKZxZni6hYYh eKEb5Sa3N28/zH8hkcHqlVNtZKbc+CU0oJfVykhF/ULLG58/x8GORW1YEWksIu6dcoHX +tx/vXtn0dloOk/WFfgb/BehneJy81rdZNvvr70hDbH2wGPBqSHVRyQ8nfs8Wa6YeUU4 mbi4jIofeWSyHsHRWaMXq0j7rq0FqxH5cO5SdwowPrbI9CQjrePFMb/46oRvrlaR2aeN ow+uP74f8DG5YluAmBHnF24PhaSpE5cMweDRkAl7l9l7EFitU4PhIx2IYP99RuxJ5aIJ 0Gvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h5khCtPt; 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 v9si269614pjg.10.2022.01.24.12.07.56; Mon, 24 Jan 2022 12:08:09 -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=h5khCtPt; 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 S237484AbiAXTHD (ORCPT + 99 others); Mon, 24 Jan 2022 14:07:03 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:57774 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345676AbiAXTAy (ORCPT ); Mon, 24 Jan 2022 14:00:54 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id D5A08B81238; Mon, 24 Jan 2022 19:00:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E114FC340E7; Mon, 24 Jan 2022 19:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050851; bh=sGOvretFgauqF2/LGbvj1iZr7JxVo+3umuYUrti16Ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h5khCtPti/6XMR/3WB6H+1EB5CMpD8XkH7Pn0WJGQGj5mNGEawyjAJMj3HC6SIDpQ h0j35m6NP6UK3q3EwfomJ9vSyPSgU+mL+IXMYNX5s1S7b+PfYCFzpyIZshNgwoVtN5 yqI/O2UWvMBJFLa7kN1tP0nd4x2kCB8+vC8QrpPY= 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.9 132/157] parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries Date: Mon, 24 Jan 2022 19:43:42 +0100 Message-Id: <20220124183936.967542931@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@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);