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 v2] tty/serial: Check for null pointer after calling devm_ioremap
Date: Thu, 13 Jan 2022 08:35:14 +0100 [thread overview]
Message-ID: <58ebc58b-f8fc-06a7-b152-1709894da8e3@kernel.org> (raw)
In-Reply-To: <20220107144852.4081390-1-jiasheng@iscas.ac.cn>
On 07. 01. 22, 15:48, Jiasheng Jiang wrote:
> As the possible failure of the devres_alloc(), the devm_ioremap()
> may return NULL pointer.
> And the 'port->membase' will be used in mlb_usio_startup() without the
> check.
> Therefore, in order to avoid the dereference of the NULL pointer, it
> should be better to add the check to guarantee the success of the probe.
>
> Fixes: ba44dc043004 ("serial: Add Milbeaut serial control")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog
>
> v1 -> v2
>
> * Change 1. Refine the commit message to be more clear.
> ---
> drivers/tty/serial/milbeaut_usio.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/tty/serial/milbeaut_usio.c b/drivers/tty/serial/milbeaut_usio.c
> index 8f2cab7f66ad..1ecbf6d0dc79 100644
> --- a/drivers/tty/serial/milbeaut_usio.c
> +++ b/drivers/tty/serial/milbeaut_usio.c
> @@ -523,6 +523,10 @@ static int mlb_usio_probe(struct platform_device *pdev)
> }
> port->membase = devm_ioremap(&pdev->dev, res->start,
> resource_size(res));
> + if (!port->membase) {
> + ret = -ENOMEM;
> + goto failed;
> + }
Hi,
what about using devm_ioremap_resource() and have only one if there?
thanks,
--
js
suse labs
prev parent reply other threads:[~2022-01-13 7:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-07 14:48 [PATCH v2] tty/serial: Check for null pointer after calling devm_ioremap Jiasheng Jiang
2022-01-13 7:35 ` Jiri Slaby [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=58ebc58b-f8fc-06a7-b152-1709894da8e3@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;
as well as URLs for NNTP newsgroup(s).