From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86386C43217 for ; Wed, 23 Nov 2022 09:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237095AbiKWJHe (ORCPT ); Wed, 23 Nov 2022 04:07:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237218AbiKWJHO (ORCPT ); Wed, 23 Nov 2022 04:07:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4C26105A85 for ; Wed, 23 Nov 2022 01:06:55 -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 51E4A61B59 for ; Wed, 23 Nov 2022 09:06:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46658C433C1; Wed, 23 Nov 2022 09:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669194414; bh=3ck9Xe5tg1QfdZeBDOx83UjQJzLEsPFRPeEwmuhrhc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rXm1XIct4c7fCtyKSd0XABzqJfb6CWmXkbdXRke8PsXVRmSAzPZHMZ8rwiuXYd157 myx2QFlL4/CnN4chkHi0I3MOCvKz0fVdI+cANjuE9ecG244Et8FeHu3ZB+2NzN/0V/ E3hSvmjGkj469pn508VOt04scc9j335a+Ht1Fank= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Juergen Gross , Sasha Levin Subject: [PATCH 4.19 070/114] xen/pcpu: fix possible memory leak in register_pcpu() Date: Wed, 23 Nov 2022 09:50:57 +0100 Message-Id: <20221123084554.677714252@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123084551.864610302@linuxfoundation.org> References: <20221123084551.864610302@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yang Yingliang [ Upstream commit da36a2a76b01b210ffaa55cdc2c99bc8783697c5 ] In device_add(), dev_set_name() is called to allocate name, if it returns error, the name need be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup(). Fixes: f65c9bb3fb72 ("xen/pcpu: Xen physical cpus online/offline sys interface") Signed-off-by: Yang Yingliang Reviewed-by: Juergen Gross Link: https://lore.kernel.org/r/20221110152441.401630-1-yangyingliang@huawei.com Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- drivers/xen/pcpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/pcpu.c b/drivers/xen/pcpu.c index cdc6daa7a9f6..9cf7085a260b 100644 --- a/drivers/xen/pcpu.c +++ b/drivers/xen/pcpu.c @@ -228,7 +228,7 @@ static int register_pcpu(struct pcpu *pcpu) err = device_register(dev); if (err) { - pcpu_release(dev); + put_device(dev); return err; } -- 2.35.1