Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1251948iog; Sat, 25 Jun 2022 04:56:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vsTi1802SBOb7t91ZKE0j3UBvSgIokxQanXk87sQPt7XTzpFqtRXpFTU8jtfVtcKKcNZjf X-Received: by 2002:a17:906:7a0e:b0:722:e8ce:8c7f with SMTP id d14-20020a1709067a0e00b00722e8ce8c7fmr3577843ejo.405.1656158189813; Sat, 25 Jun 2022 04:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656158189; cv=none; d=google.com; s=arc-20160816; b=dCMimetnLhdjpguTtX4hYAKB3TMKCad8hvsHZMZfnsNXlyFYiH604GeNP79w7L1BuJ Iw0zX3LBPGy99Kfp8vlkynXiSpRybq7O91tGsAKGw2WmLqld7fqjQ6jEMpklfqkbRDmb 3NXcTWJqu1VhK7Hspx7ADEF6XCbN/sffvFtXH9UUBpy4MwFjfiS754lKZ6Bm0FrIDM6D W42uEszM0yjJJV5H8ZwixeC1I8qBTu5HNlP5TETJH5fSegj155eg+xxy4FUA7ubopUMP 8Rqae6OVjPwrbihNzmyPcIIyj4hCQXS/5hl1S5JtI3O3VNO64cMGDZxSkpGzwoKPxkwd /mwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=3N0Ekda2J3gcnnwz4N9RjB4Ed6BL3Y3/bb5mKrPatPQ=; b=RSuwLgGd5n/MP/zI1FaQs5bWVBorJ4OJaOS64lepUY2Z6hDIrmYG5G05wFyUGH9UD6 Osc0R8UJcnuX3bIaN/GW0y59WBLjwQ3DE9lzd+kjU66uStX0lRh+B1FToxQT9ryPbbgM Y6xvYFLU79j7sSVFyxavk3oCXLfHx5ic7mhs6wBvx/jd2MeRPWD3HYb2tftPNdcGkZjc L02PX80wcVeqWL3hVI3+HLrVMgKTDdl6mSn2k47pvFgsdTguqYtKeI+POHAdGxSxU6Cm 7QJY1ItKqDL5UYnMT0tGpiYhWK/zkd/I/+1Wq8DXpmy+EYxQhKE0em7mm0GBVXiA9Eyr xJpw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a056402280b00b00435dad43328si8302531ede.569.2022.06.25.04.55.59; Sat, 25 Jun 2022 04:56:29 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232691AbiFYLiH (ORCPT + 99 others); Sat, 25 Jun 2022 07:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232653AbiFYLiF (ORCPT ); Sat, 25 Jun 2022 07:38:05 -0400 Received: from 10.mo552.mail-out.ovh.net (10.mo552.mail-out.ovh.net [87.98.187.244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 394A311C1E for ; Sat, 25 Jun 2022 04:38:01 -0700 (PDT) Received: from mxplan5.mail.ovh.net (unknown [10.109.143.118]) by mo552.mail-out.ovh.net (Postfix) with ESMTPS id 2B89624A8F; Sat, 25 Jun 2022 11:29:37 +0000 (UTC) Received: from kaod.org (37.59.142.107) by DAG4EX1.mxp5.local (172.16.2.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9; Sat, 25 Jun 2022 13:29:36 +0200 Authentication-Results: garm.ovh; auth=pass (GARM-107S001e52cdebf-f225-43ef-b594-73954c12a390, 4F3A6162F3CBF85AFED954EB26FB80209C915413) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Message-ID: Date: Sat, 25 Jun 2022 13:29:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] powerpc/xive: Fix some incorrect memory allocation Content-Language: en-US To: Christophe JAILLET , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras CC: , , References: <2ebb28e9de76d35b75c137f9944c2dfd893d34fa.1656150559.git.christophe.jaillet@wanadoo.fr> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: <2ebb28e9de76d35b75c137f9944c2dfd893d34fa.1656150559.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [37.59.142.107] X-ClientProxiedBy: DAG6EX2.mxp5.local (172.16.2.52) To DAG4EX1.mxp5.local (172.16.2.31) X-Ovh-Tracer-GUID: 8095d44e-4afb-4333-bd47-84e426c9d3f6 X-Ovh-Tracer-Id: 17411197634755070825 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrudeguddggedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgihesthejredttdefjeenucfhrhhomhepveorughrihgtpgfnvggpifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeeifeehtdevfeeuhfelheekkeefieeivdfhgeevueeijeetjeekueeggedujeeiieenucffohhmrghinhepohiilhgrsghsrdhorhhgnecukfhppedtrddtrddtrddtpdefjedrheelrddugedvrddutdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehmgihplhgrnhehrdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugihpphgtqdguvghvsehlihhsthhsrdhoiihlrggsshdrohhrghdpoffvtefjohhsthepmhhoheehvd X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Hello Christophe, On 6/25/22 11:49, Christophe JAILLET wrote: > 'xibm->count' really looks like a number of bits (see how it is used in > __xive_irq_bitmap_alloc()), so use the bitmap API to allocate and free this > bitmap. > > This improves semantic and potentially avoids some over memory allocation. This is correct and > Fixes: eac1e731b59e ("powerpc/xive: guest exploitation of the XIVE interrupt controller") > Signed-off-by: Christophe JAILLET > --- > I don't cross compile, so this patch is NOT compile-tested. Nathan provided a fix for it already : http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220623182509.3985625-1-nathanl@linux.ibm.com/ Thanks, C. > --- > arch/powerpc/sysdev/xive/spapr.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c > index 7d5128676e83..fdbebb14b7de 100644 > --- a/arch/powerpc/sysdev/xive/spapr.c > +++ b/arch/powerpc/sysdev/xive/spapr.c > @@ -57,7 +57,7 @@ static int __init xive_irq_bitmap_add(int base, int count) > spin_lock_init(&xibm->lock); > xibm->base = base; > xibm->count = count; > - xibm->bitmap = kzalloc(xibm->count, GFP_KERNEL); > + xibm->bitmap = bitmap_zalloc(xibm->count, GFP_KERNEL); > if (!xibm->bitmap) { > kfree(xibm); > return -ENOMEM; > @@ -75,7 +75,7 @@ static void xive_irq_bitmap_remove_all(void) > > list_for_each_entry_safe(xibm, tmp, &xive_irq_bitmaps, list) { > list_del(&xibm->list); > - kfree(xibm->bitmap); > + bitmap_free(xibm->bitmap); > kfree(xibm); > } > }