From: Jiri Slaby <jirislaby@kernel.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>, gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: timbuart: Check for null res pointer
Date: Mon, 20 Dec 2021 14:29:38 +0100 [thread overview]
Message-ID: <13b27c0f-f3a5-1176-7d80-5a6d0ce52925@kernel.org> (raw)
In-Reply-To: <20211220082127.883885-1-jiasheng@iscas.ac.cn>
On 20. 12. 21, 9:21, Jiasheng Jiang wrote:
> The return value of platform_get_resource() needs to be checked.
> To avoid use of error pointer in case that there is no suitable
> resource.
>
> Fixes: ab4382d27412 ("tty: move drivers/serial/ to drivers/tty/serial/")
Barely.
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> drivers/tty/serial/timbuart.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c
> index 08941eabe7b1..262154d2f40f 100644
> --- a/drivers/tty/serial/timbuart.c
> +++ b/drivers/tty/serial/timbuart.c
> @@ -312,9 +312,14 @@ static const char *timbuart_type(struct uart_port *port)
> */
> static void timbuart_release_port(struct uart_port *port)
> {
> + struct resource *res;
> + int size;
> struct platform_device *pdev = to_platform_device(port->dev);
> - int size =
> - resource_size(platform_get_resource(pdev, IORESOURCE_MEM, 0));
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + size = 0;
How can this happen and what happens when you pass zero size to
release_mem_region?
> + else
> + size = resource_size(res);
>
> if (port->flags & UPF_IOREMAP) {
> iounmap(port->membase);
--
js
suse labs
next prev parent reply other threads:[~2021-12-20 13:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-20 8:21 Jiasheng Jiang
2021-12-20 13:29 ` Jiri Slaby [this message]
2021-12-20 15:40 ` Greg KH
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=13b27c0f-f3a5-1176-7d80-5a6d0ce52925@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jiasheng@iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.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
all inboxes | Powered by JetHome®