Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2434465pxu; Sat, 28 Nov 2020 14:02:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmwu3mpKRbUm8t+NSjQ7hjF4GXwj6ufS1pFvZATSqFxIL+9rT+bGZH9C8NN7D0Lf4dXM8U X-Received: by 2002:a50:ee19:: with SMTP id g25mr1418650eds.163.1606600927967; Sat, 28 Nov 2020 14:02:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606600927; cv=none; d=google.com; s=arc-20160816; b=RHjsHnC2iy9rpPWW/bf1U9q67W5upIv6bXS1R/eeVcFL949BgO06UsmKTfvt86cqfQ hR8tRrjmVHsdxEL6krcXHDzUSEVuOjf5WH0ImTya2hSNbsLOYPwn5+DBfVmVH3GImvld MZUBHUiRGA/ZG2ABKv/XuLGVIrHQWVOPUHDnFz5fenkl0gNHZdMocP5gVKJZLPkYiGDy zd2/MNqJThCE63GWIBFlVhMbWD6ga3U9AmBo9smP90cgHWrZi0DU5fNQrv6lFESYENBv FFtPgMLgxtTVjPTAKKA6VAjE4YHycR6rYq3eMwp4efq6KyGM0UjYGcwJcor7v0sYL6cV locA== 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 :message-id:date:subject:cc:to:from; bh=oEg9sYWmkXAAF/jv12sS0pMXIjRGEwz+NKM34WiR30s=; b=AJIPP9kHb+F4RY8HjCYnaCgY6SXNCo2G1g/Kgqjv/lVNwC7QA+IDzkRZgbULFxMB/c b5YcKatJinBhd1WulPNUg729rhm7dmGtClyy4Z53bhkVEV6WTjxG0c1etb95kGLKfft+ W73BJxrgrOrEfT8C7pY/v8NLt6WI9kLGX2xYJpV10ufNEY3SMx4Nz8ahE2IR7w5L3Md3 xIagJPPMPrxNg2nL0eQgXACsKYSAsr1T36O/nA8zTxA3C1VVK8/+omYjDenn9tBfLCv9 NZkgul73CC+lS+zlcUEKzCi4SZtp06JNHNtffnwWUmIcQ7y3YoQIDWTqXhTJ2W8GlIuL Eqow== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si8167958edq.297.2020.11.28.14.01.45; Sat, 28 Nov 2020 14:02:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390751AbgK1Vva (ORCPT + 99 others); Sat, 28 Nov 2020 16:51:30 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8528 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730935AbgK1Sqj (ORCPT ); Sat, 28 Nov 2020 13:46:39 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CjnSQ2pHHzhXjM; Sat, 28 Nov 2020 18:15:34 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Sat, 28 Nov 2020 18:15:48 +0800 From: Qinglang Miao To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras CC: , , "Qinglang Miao" Subject: [PATCH 2/3] powerpc/pseries/hotplug-cpu: fix memleak in dlpar_cpu_add_by_count Date: Sat, 28 Nov 2020 18:20:01 +0800 Message-ID: <20201128102001.95323-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kfree(cpu_drcs) should be called when it fails to perform of_find_node_by_path("/cpus") in dlpar_cpu_add_by_count, otherwise there would be a memleak. In fact, the patch a0ff72f9f5a7 ought to remove kfree in find_dlpar_cpus_to_add rather than dlpar_cpu_add_by_count. I guess there might be a mistake when apply that one. Fixes: a0ff72f9f5a7 ("powerpc/pseries/hotplug-cpu: Remove double free in error path") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao --- arch/powerpc/platforms/pseries/hotplug-cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index f2837e33b..4bb1c9f2b 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -743,6 +743,7 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add) parent = of_find_node_by_path("/cpus"); if (!parent) { pr_warn("Could not find CPU root node in device tree\n"); + kfree(cpu_drcs); return -1; } -- 2.23.0