Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1175509iog; Sat, 25 Jun 2022 02:55:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uVGtrrzqFxtl0iVCk8PMXkaPSYoY91gdlgvkXmHFzDyZFKmsPkoJJslixg58Pe9NfK0cQg X-Received: by 2002:a63:8341:0:b0:40d:268f:d8ed with SMTP id h62-20020a638341000000b0040d268fd8edmr3100473pge.232.1656150956336; Sat, 25 Jun 2022 02:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656150956; cv=none; d=google.com; s=arc-20160816; b=bJLWfurplzLcNdY3WyvIFzGiTmFH/jA4O8SPUTQ/tXoj6IJnIyotjl9OEcIbk8/Hv3 Gu6Zx+abovhqk0Zg0HLPiLfAK7jKw8siEAvT9VqWL1dDhK1ns9PNIbYC/r/chuCT+Du+ hjUrU1KdLpypYZKUYOaCF2dXdF9H6BUfyDBH1R6fxvbdRu262ZAq14+eDF0dROOgGkG0 Qzwd37CNdOrqqf024HVfKx6XOohfyXtIHaIuZr0mshdyPsFiuXhXQPbmdb+U4gCHaZFj 5oufgqi4e7WuvSb/g01M2jQvWqoHCqs5ZVpzOnONwOfntoh8+7zRoBJ6erfkEVvi3gzB Fq6A== 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=uB2oWR8NsSdQAFVzXw5uvOrjc7pVL5G+Muv9tgl5WUM=; b=JJYWXvaPzYthHqRBf/RJErTcMsSdylkwltzDqrqvmDAJDxKK9Zym+d1Sd3ByC+tRN3 1B8p3s8T1Tz0uiY6ec7MjRDCFmm2OWwVJyZoBoVGpOqY54NWG0/Z7NPrrtq/kd2JnVCg fICGIADxq7Pe6FrgeWc+fii7dS5Z1XsEg8xUEYogLMX9fPTIHoaFdvC+rELPnD3GKBaw Ze86ULEEHYrsEelC23aDEUcvT0C1XD1ym+bvrFIOYdzUZbXUw2QB2qaZvTuhsQt1xj46 ZtUfoH8BdcPHl/1LKLZVB1cEa2gJRapECLqlTVtMwfhaidffUHO4eiEym4b5mm50LEl4 VWDw== 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 l7-20020a633e07000000b003fd31d844f7si5810148pga.538.2022.06.25.02.55.44; Sat, 25 Jun 2022 02:55:56 -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 S232399AbiFYJtn (ORCPT + 99 others); Sat, 25 Jun 2022 05:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232437AbiFYJtk (ORCPT ); Sat, 25 Jun 2022 05:49:40 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C473B393EF for ; Sat, 25 Jun 2022 02:49:38 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 52Q2oyvoAP8Ap52Q2oqOnW; Sat, 25 Jun 2022 11:49:36 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 25 Jun 2022 11:49:36 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc/xive: Fix some incorrect memory allocation Date: Sat, 25 Jun 2022 11:49:31 +0200 Message-Id: <2ebb28e9de76d35b75c137f9944c2dfd893d34fa.1656150559.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 '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. 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. --- 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); } } -- 2.34.1