Re: Re: [PATCH] tty/serial: Check for null pointer after calling devm_ioremap

From: Jiasheng Jiang
Date: Thu Jan 13 2022 - 03:02:36 EST


On Thu, Jan 13, 2022 at 03:35:14PM +0800, Jiri Slaby wrote:
>> 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;
>> + }
>
> what about using devm_ioremap_resource() and have only one if there?

Well, I check the comment of the devm_ioremap_resource() and notice that
it checks and requests region before ioremap.
And the usage example is fit for the situation.
But I have still have no idea what the concrete advantages of the
devm_ioremap_resource(), like fixing something or improve the efficiency.
Please give me more detail.

Sincerely thanks,
Jiang