[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <25EFA2E0-5119-400F-A787-D2BDB78B8BE0@linux.dev>
Date: Fri, 12 Sep 2025 12:51:05 +0200
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Heiko Carstens <hca@...ux.ibm.com>
Cc: Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
linux-s390@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] s390/hypfs_sprp: Replace kzalloc() + copy_from_user()
with memdup_user()
On 12. Sep 2025, at 12:09, Thorsten Blum wrote:
> On 12. Sep 2025, at 11:56, Heiko Carstens wrote:
>> This is not an improvement and also incorrect, since kfree() may now
>> be called with an error pointer.
>
> Unless I'm missing something, kfree() works just fine with error
> pointers. See linux/slab.h:
>
> DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T))
And unless kzalloc() is required here, memdup_user() is an improvement,
since it uses kmalloc() internally and avoids unnecessarily zeroing the
memory before overwriting it with copy_from_user().
Thanks,
Thorsten
Powered by blists - more mailing lists