From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH] tty: 8250: replace snprintf in show functions with sysfs_emit
Date: Fri, 15 Oct 2021 08:57:56 +0200 [thread overview]
Message-ID: <YWkmdELuWa6ITIIR@kroah.com> (raw)
In-Reply-To: <1634280682-5002-1-git-send-email-wangqing@vivo.com>
On Thu, Oct 14, 2021 at 11:51:22PM -0700, Qing Wang wrote:
> show() must not use snprintf() when formatting the value to be
> returned to user space.
Why must it not? What is broken in the existing code?
>
> Fix the coccicheck warnings:
> WARNING: use scnprintf or sprintf.
>
> Signed-off-by: Qing Wang <wangqing@vivo.com>
> ---
> drivers/tty/serial/8250/8250_aspeed_vuart.c | 6 +++---
> drivers/tty/serial/8250/8250_port.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> index 2350fb3..082b9bd 100644
> --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
> +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> @@ -82,7 +82,7 @@ static ssize_t lpc_address_show(struct device *dev,
> addr = (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRH) << 8) |
> (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRL));
>
> - return snprintf(buf, PAGE_SIZE - 1, "0x%x\n", addr);
> + return sysfs_emit(buf - 1, "0x%x\n", addr);
what is the buf-1 thing here for?
Doing a tree-wide change for this type of thing might not be wanted by
many maintainers, especially if you introduce bugs like this :(
greg k-h
WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Qing Wang <wangqing@vivo.com>
Cc: Jiri Slaby <jirislaby@kernel.org>, Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@aj.id.au>,
linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: 8250: replace snprintf in show functions with sysfs_emit
Date: Fri, 15 Oct 2021 08:57:56 +0200 [thread overview]
Message-ID: <YWkmdELuWa6ITIIR@kroah.com> (raw)
In-Reply-To: <1634280682-5002-1-git-send-email-wangqing@vivo.com>
On Thu, Oct 14, 2021 at 11:51:22PM -0700, Qing Wang wrote:
> show() must not use snprintf() when formatting the value to be
> returned to user space.
Why must it not? What is broken in the existing code?
>
> Fix the coccicheck warnings:
> WARNING: use scnprintf or sprintf.
>
> Signed-off-by: Qing Wang <wangqing@vivo.com>
> ---
> drivers/tty/serial/8250/8250_aspeed_vuart.c | 6 +++---
> drivers/tty/serial/8250/8250_port.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> index 2350fb3..082b9bd 100644
> --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
> +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> @@ -82,7 +82,7 @@ static ssize_t lpc_address_show(struct device *dev,
> addr = (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRH) << 8) |
> (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRL));
>
> - return snprintf(buf, PAGE_SIZE - 1, "0x%x\n", addr);
> + return sysfs_emit(buf - 1, "0x%x\n", addr);
what is the buf-1 thing here for?
Doing a tree-wide change for this type of thing might not be wanted by
many maintainers, especially if you introduce bugs like this :(
greg k-h
WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Qing Wang <wangqing@vivo.com>
Cc: Jiri Slaby <jirislaby@kernel.org>, Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@aj.id.au>,
linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: 8250: replace snprintf in show functions with sysfs_emit
Date: Fri, 15 Oct 2021 08:57:56 +0200 [thread overview]
Message-ID: <YWkmdELuWa6ITIIR@kroah.com> (raw)
In-Reply-To: <1634280682-5002-1-git-send-email-wangqing@vivo.com>
On Thu, Oct 14, 2021 at 11:51:22PM -0700, Qing Wang wrote:
> show() must not use snprintf() when formatting the value to be
> returned to user space.
Why must it not? What is broken in the existing code?
>
> Fix the coccicheck warnings:
> WARNING: use scnprintf or sprintf.
>
> Signed-off-by: Qing Wang <wangqing@vivo.com>
> ---
> drivers/tty/serial/8250/8250_aspeed_vuart.c | 6 +++---
> drivers/tty/serial/8250/8250_port.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> index 2350fb3..082b9bd 100644
> --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
> +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> @@ -82,7 +82,7 @@ static ssize_t lpc_address_show(struct device *dev,
> addr = (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRH) << 8) |
> (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRL));
>
> - return snprintf(buf, PAGE_SIZE - 1, "0x%x\n", addr);
> + return sysfs_emit(buf - 1, "0x%x\n", addr);
what is the buf-1 thing here for?
Doing a tree-wide change for this type of thing might not be wanted by
many maintainers, especially if you introduce bugs like this :(
greg k-h
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-10-15 6:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 6:51 [PATCH] tty: 8250: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-15 6:51 ` Qing Wang
2021-10-15 6:51 ` Qing Wang
2021-10-15 6:57 ` Greg Kroah-Hartman [this message]
2021-10-15 6:57 ` Greg Kroah-Hartman
2021-10-15 6:57 ` Greg Kroah-Hartman
[not found] ` <AOQACwDzEi5UM3m3ezm-D4o5.9.1634281082401.Hmail.wangqing@vivo.com>
2021-10-15 7:13 ` 回复: " 王擎
2021-10-15 7:13 ` 王擎
2021-10-15 7:13 ` 王擎
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=YWkmdELuWa6ITIIR@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=linux-aspeed@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.