From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Date: Sun, 15 Mar 2020 22:01:51 +0000 Subject: Re: [PATCH v3 3/3] KEYS: Use kvmalloc() to better handle large buffer allocation Message-Id: <74ec00b8-d7a7-0035-d650-710415660926@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: References: <20200313152102.1707-1-longman@redhat.com> <20200313152102.1707-4-longman@redhat.com> <20200313164306.GA907@sol.localdomain> <8f2f1787-88b0-f86d-991c-34cfd2f9b4aa@redhat.com> <20200315215253.GG224162@linux.intel.com> In-Reply-To: <20200315215253.GG224162@linux.intel.com> To: Jarkko Sakkinen Cc: Eric Biggers , David Howells , James Morris , "Serge E. Hallyn" , Mimi Zohar , keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, Sumit Garg , Jerry Snitselaar , Roberto Sassu , Chris von Recklinghausen On 3/15/20 5:52 PM, Jarkko Sakkinen wrote: > On Fri, Mar 13, 2020 at 01:49:57PM -0400, Waiman Long wrote: >>>> if (!tmpbuf || unlikely(ret > tmpbuflen)) { >>>> if (unlikely(tmpbuf)) >>>> - kzfree(tmpbuf); >>>> + __kvzfree(tmpbuf, tmpbuflen); >>> Both kzfree() and __kvzfree() handle a NULL pointer, so there's no need for the >>> NULL check first. >>> >> I would like to keep this one because of the unlikely annotation. > What (measurable) gain does it bring anyway? It is not a performance issue. I just want to indicate that the need to free should not happen at all. It match the unlikely tag in the if condition above. Cheers, Longman