mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Nam Cao <namcaov@gmail.com>
Cc: Johan Hovold <johan@kernel.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: serial: whiteheat: use stack instead of heap memory
Date: Sat, 4 Feb 2023 14:55:02 +0100	[thread overview]
Message-ID: <Y95jtuMbcDiPRw/F@kroah.com> (raw)
In-Reply-To: <20230204134651.22569-1-namcaov@gmail.com>

On Sat, Feb 04, 2023 at 02:46:51PM +0100, Nam Cao wrote:
> Some buffers in whiteheat_attach() are small and only used locally. Move
> them to the stack to avoid complications with heap memory.
> 
> Compile-tested only.

And that's the problem, you can't just compile test these things, the
code will blow up if you make these changes :(

All USB transfers need to come from memory that can be safely DMAed.
Stack memory is not that type of memory, you HAVE to allocate it
dynamically from the heap in order to have this guarantee.

So no, this patch is not acceptable, sorry.  You will see this pattern
in all USB drivers, all data must be dynamically allocated, even for 2
byte commands.

So yes, there was a reason we added this "complexity" to the driver, it
is required :)

sorry,

greg k-h

  reply	other threads:[~2023-02-04 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-04 13:46 Nam Cao
2023-02-04 13:55 ` Greg Kroah-Hartman [this message]
2023-02-04 14:01   ` Nam Cao

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=Y95jtuMbcDiPRw/F@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=namcaov@gmail.com \
    /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

all inboxes | Powered by JetHome®