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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78D54C64E7B for ; Mon, 30 Nov 2020 01:52:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 442D32076A for ; Mon, 30 Nov 2020 01:52:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="oGYp8psM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726669AbgK3Bw1 (ORCPT ); Sun, 29 Nov 2020 20:52:27 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:33813 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgK3Bw1 (ORCPT ); Sun, 29 Nov 2020 20:52:27 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4CkpB92ch4z9sVD; Mon, 30 Nov 2020 12:51:45 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1606701105; bh=xlIwgzjEPzyGOCP0bGlo84nJNsiFMwgliSsNWMJmGPY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=oGYp8psM5s7iCfh0zl1U86fugKwvbASdl8DteUCKa2vvvMf2Cj005dkMUX5VcDclt qnDlMQRu+2n1LKZD37QeFsmkVkHQeTaqSRF/K5vW3Fpm1GLzm+pIdfbBFXakuRT6+7 7IrTzA03pca6fSkBoqdTzgicOKZ2O9ALaB19NAU9dTlN1NvqLgxloYM/fSAKJ3rXli ur4KdHEQQvMMIRbPIg64Or3epMyKM2Pgb4fGOs5JOaeiwt7GEduSJHujY8uKpL96c+ 9W/a6l9V6IG5Njgn7JQBHhq8rnCSG03PMgdi52yVgGSRhNP/D7ZDCutp8vAUJvaky6 HNKYpkrKdHMSQ== From: Michael Ellerman To: Qinglang Miao , Benjamin Herrenschmidt , Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Qinglang Miao Subject: Re: [PATCH 2/3] powerpc/pseries/hotplug-cpu: fix memleak in dlpar_cpu_add_by_count In-Reply-To: <20201128102001.95323-1-miaoqinglang@huawei.com> References: <20201128102001.95323-1-miaoqinglang@huawei.com> Date: Mon, 30 Nov 2020 12:51:44 +1100 Message-ID: <871rgby5lb.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Qinglang Miao writes: > 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(+) This is already fixed in my next by: a40fdaf1420d ("Revert "powerpc/pseries/hotplug-cpu: Remove double free in error path"") cheers > 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