Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1703904rwb; Sat, 19 Nov 2022 01:48:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf7bd1CTTOD1sowGFfAe4v+CPmk+kr8nprs8JpEQy6q7fX1qhszxs34wwyvpUZreEhIP9j9h X-Received: by 2002:a17:902:a984:b0:188:feab:4fd3 with SMTP id bh4-20020a170902a98400b00188feab4fd3mr3096909plb.167.1668851329716; Sat, 19 Nov 2022 01:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668851329; cv=none; d=google.com; s=arc-20160816; b=vQSHviEeiy+NsYFM+9Ut2KT4Ik7EylXBktTR89RywXh/s8I5ncJAcDPfwW3Ye0jhJO vZ3obay4RIWX7rE5zGcbZnFNlYmcuXXHmz3fpvSTU6aom82DumDY1ba1/Rz/9Gu9Ftva 9dkzEngY+r67GOUQfh6B1aNgLuIRkP2l+ZtoLpfz/ESUnoA/Ha73ZqeJ0jQTR3Qngeb8 1oVNf2L74vMgF3SdD/hC9MJs+MJPdEquy3ZpN4z/WUjT3iqooYs/9GHf/MSLGcVRIUJM 7PhgInk2ew6xYUmwbbpQyLU8a8VbjXc+bxDg9q833xmFrv3Q8w9jt82S5davMsiBUI3m jzLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=3+idkMbADtGDpPRqk4DEwLrKhcTWkh5ZPEs36uKEKPE=; b=uMNtXLqqAKX/ciRI4kEsew7GUGvkPS94K+GgidteY9daDSRtBbjr3TgXScQTbcXmZW /6fexxhugVKuUs3GJdcqeKDhmiCl8pkPVYTJQWYlEN6jmZ7qiTjG13X3CUs7jixRm3pD EqP8JKlDNwm+fnbK67Ht1FHXTsaQhNlvmlQOMSBK9EQDsPF4JHsSxjcY0/7bguSFXFg5 3APUQvja0ikZ7EbtyLvMkmh06UMCfGAf/feUV7sG10UbwACKoWrfrhVlqHjYnrUP/Jo1 Go03HiLiNMz6RQqBdY0lyVTbb/SHuEXdDzb5iMQ4BvYqNsQleIKLBkeHD6D24D4rOeNz 67og== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a38-20020a056a001d2600b0053e8d0c9909si6475941pfx.221.2022.11.19.01.48.38; Sat, 19 Nov 2022 01:48:49 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232579AbiKSJCn (ORCPT + 91 others); Sat, 19 Nov 2022 04:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbiKSJCe (ORCPT ); Sat, 19 Nov 2022 04:02:34 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 692619A5DD for ; Sat, 19 Nov 2022 01:02:33 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NDnhk1qhNzHvsQ; Sat, 19 Nov 2022 17:01:58 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 19 Nov 2022 17:02:31 +0800 From: Xiu Jianfeng To: , , , , , , , CC: , , Subject: [PATCH 2/2] x86/xen: Fix memory leak in xen_init_lock_cpu() Date: Sat, 19 Nov 2022 16:59:23 +0800 Message-ID: <20221119085923.114889-3-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221119085923.114889-1-xiujianfeng@huawei.com> References: <20221119085923.114889-1-xiujianfeng@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 In xen_init_lock_cpu(), the @name has allocated new string by kasprintf(), if bind_ipi_to_irqhandler() fails, it should be freed, otherwise may lead to a memory leak issue, fix it. Fixes: 2d9e1e2f58b5 ("xen: implement Xen-specific spinlocks") Signed-off-by: Xiu Jianfeng --- arch/x86/xen/spinlock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c index 043c73dfd2c9..156d3e04c9ef 100644 --- a/arch/x86/xen/spinlock.c +++ b/arch/x86/xen/spinlock.c @@ -86,7 +86,8 @@ void xen_init_lock_cpu(int cpu) disable_irq(irq); /* make sure it's never delivered */ per_cpu(lock_kicker_irq, cpu) = irq; per_cpu(irq_name, cpu) = name; - } + } else + kfree(name); printk("cpu %d spinlock event irq %d\n", cpu, irq); } -- 2.17.1