lkml.org 
[lkml]   [2023]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RESEND PATCH 1/2] iommu/iova: Add check for cpu_rcache in free_iova_rcaches
From
在 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

\
 
 \ /
  Last update: 2023-08-12 04:22    [W:0.094 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site