The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
Cc: Andreas Noever <andreas.noever@gmail.com>,
	Mika Westerberg <westeri@kernel.org>,
	Yehezkel Bernat <YehezkelShB@gmail.com>,
	Mike Rapoport <rppt@kernel.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thunderbolt: debugfs: Replace get_zeroed_page() with kzalloc()
Date: Mon, 10 Aug 2026 12:51:58 +0200	[thread overview]
Message-ID: <20260810105158.GG893316@black.igk.intel.com> (raw)
In-Reply-To: <20260808223829.3117-1-mahad.ibrahim.dev@gmail.com>

Hi,

On Sat, Aug 08, 2026 at 10:38:29PM +0000, Mahad Ibrahim wrote:
> validate_and_copy_from_user() allocates a page to store data from
> userspace via get_zeroed_page(), and then returns it as a buffer.
> Neither the function itself nor its callers require struct page access.
> 
> This buffer can easily be allocated with kzalloc() as there is nothing
> special about it that requires going through the page allocator.
> kzalloc(), which internally reduces to kmalloc() with __GFP_ZERO,
> provides a better API and kfree() does not need to know the size of the
> freed object. Additionally it removes the casts of (void *) and
> (unsigned long) which only obfuscate the code.
> 
> Replace get_zeroed_page() with kzalloc() and free_page() with kfree().
> 
> Compile-tested only; no USB4 hardware available.

I tested this on Intel HW and works fine.

> Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com/
> Signed-off-by: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>

Applied to thunderbolt.git/next with Mike's ack. Thanks!

      parent reply	other threads:[~2026-08-10 10:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08 22:38 [PATCH] thunderbolt: debugfs: Replace get_zeroed_page() with kzalloc() Mahad Ibrahim
2026-08-08 23:01 ` Mahad Ibrahim
2026-08-10  8:44 ` Mike Rapoport
2026-08-10 10:51 ` Mika Westerberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260810105158.GG893316@black.igk.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mahad.ibrahim.dev@gmail.com \
    --cc=rppt@kernel.org \
    --cc=westeri@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox