From: Johan Hovold <johan@kernel.org>
To: Slark Xiao <slark_xiao@163.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: serial: use kmemdup instead of kmalloc + memcpy
Date: Mon, 20 Jun 2022 15:10:49 +0200 [thread overview]
Message-ID: <YrBx2eQYwiGcDC8m@hovoldconsulting.com> (raw)
In-Reply-To: <20220620105939.5128-1-slark_xiao@163.com>
On Mon, Jun 20, 2022 at 06:59:39PM +0800, Slark Xiao wrote:
> For code neat purpose, we can use kmemdup to replace
> kmalloc + memcpy.
>
> Signed-off-by: Slark Xiao <slark_xiao@163.com>
> ---
> drivers/usb/serial/opticon.c | 4 +---
> drivers/usb/serial/sierra.c | 4 +---
> 2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
> index aed28c35caff..bca6766a63e6 100644
> --- a/drivers/usb/serial/opticon.c
> +++ b/drivers/usb/serial/opticon.c
> @@ -208,7 +208,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
> priv->outstanding_bytes += count;
> spin_unlock_irqrestore(&priv->lock, flags);
>
> - buffer = kmalloc(count, GFP_ATOMIC);
> + buffer = kmemdup(buf, count, GFP_ATOMIC);
> if (!buffer)
> goto error_no_buffer;
>
> @@ -216,8 +216,6 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
> if (!urb)
> goto error_no_urb;
>
> - memcpy(buffer, buf, count);
> -
> usb_serial_debug_data(&port->dev, __func__, count, buffer);
>
> /* The connected devices do not have a bulk write endpoint,
Looks like we have the same pattern also in garmin_write_bulk(). Care to
include that one as well?
Johan
next prev parent reply other threads:[~2022-06-20 13:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 10:59 Slark Xiao
2022-06-20 13:10 ` Johan Hovold [this message]
2022-06-22 3:08 ` Slark Xiao
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=YrBx2eQYwiGcDC8m@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=slark_xiao@163.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®