From: "Cédric Le Goater" <clg@kaod.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc/xive: Fix some incorrect memory allocation
Date: Sat, 25 Jun 2022 13:29:35 +0200 [thread overview]
Message-ID: <d48bcb6b-41f7-8243-6094-cf80beffe68a@kaod.org> (raw)
In-Reply-To: <2ebb28e9de76d35b75c137f9944c2dfd893d34fa.1656150559.git.christophe.jaillet@wanadoo.fr>
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 <christophe.jaillet@wanadoo.fr>
> ---
> 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);
> }
> }
prev parent reply other threads:[~2022-06-25 11:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-25 9:49 [PATCH] powerpc/xive: Fix some incorrect memory allocation Christophe JAILLET
2022-06-25 11:29 ` Cédric Le Goater [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d48bcb6b-41f7-8243-6094-cf80beffe68a@kaod.org \
--to=clg@kaod.org \
--cc=benh@kernel.crashing.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).