Re: [PATCH 1/4] scsi: target: file: use kmalloc() to allocate temporary protection buffer
Hannes Reinecke <[email protected]> Wed, 1 Jul 2026 08:58:13 +0200
| Newsgroups | org.kernel.vger.target-devel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-scsi,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On 6/30/26 12:54 PM, Mike Rapoport (Microsoft) wrote: > fd_do_prot_unmap() uses __get_free_page() to allocate a temporary buffer > that is used to invalidate protection info for the unmapped region by > filling with 0xff pattern. > > This buffer can be allocated with kmalloc() as there's nothing special > about it to go directly to the page allocator. > > kmalloc() provides a better API that does not require ugly casts and > kfree() does not need to know the size of the freed object. > > Replace use of __get_free_page() with kmalloc(). > > Link: https://lore.kernel.org/all/[email protected] > Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> > --- > drivers/target/target_core_file.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c > index 62ced9f5102f..ab9824a4852f 100644 > --- a/drivers/target/target_core_file.c > +++ b/drivers/target/target_core_file.c > @@ -516,7 +516,7 @@ fd_do_prot_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb) > void *buf; > int rc; > > - buf = (void *)__get_free_page(GFP_KERNEL); > + buf = kmalloc(PAGE_SIZE, GFP_KERNEL); > if (!buf) { > pr_err("Unable to allocate FILEIO prot buf\n"); > return -ENOMEM; > @@ -524,7 +524,7 @@ fd_do_prot_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb) > > rc = fd_do_prot_fill(cmd->se_dev, lba, nolb, buf, PAGE_SIZE); > > - free_page((unsigned long)buf); > + kfree(buf); > > return rc; > } > Reviewed-by: Hannes Reinecke <[email protected]> Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich