[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6ab1684e-fc81-9840-7973-87966e4284e8@huawei.com>
Date: Sat, 12 Aug 2023 10:21:50 +0800
From: "zhangzekun (A)" <zhangzekun11@...wei.com>
To: Robin Murphy <robin.murphy@....com>
CC: <iommu@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
<baolu.lu@...ux.intel.com>, <robh@...nel.org>,
<nicolinc@...dia.com>, <john.g.garry@...cle.com>,
<kevin.tian@...el.com>, <will@...nel.org>, <joro@...tes.org>
Subject: Re: [RESEND PATCH 1/2] iommu/iova: Add check for cpu_rcache in
free_iova_rcaches
在 2023/8/11 21:32, Robin Murphy 写道:
> On 2023-08-11 14:02, Zhang Zekun wrote:
>> free_iova_rcaches() needs to check if cpu_rcache->loaded and
>> cpu_rcache->prev is NULL before freeing them.
>
> Why? iova_magazine_free() is just kfree(), and kfree(NULL) is
> perfectly valid, specifically to avoid having to make cleanup paths
> all fiddly and overcomplicated like this.
>
> Thanks,
> Robin.
>
Hi, Robin
Thanks for your review, I have missed that kfree() can handle NULL and
it is safe
to iterate through all cpus, because __alloc_percpu() will alloc a
zero-filled area,
and pointers passed to kfree() will be either NULL or a vaild one. There
is no need
to add check before these pointers.
Thanks,
Zekun
Powered by blists - more mailing lists