public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-serial@vger.kernel.org>,
	<geert+renesas@glider.be>, <peter@hurleysoftware.com>,
	<sjoerd.simons@collabora.co.uk>
Subject: Re: [PATCH 1/2] serial: sh-sci: fix missing sci_cleanup_single() in sci_probe_single()
Date: Fri, 1 Jul 2022 12:25:23 +0800	[thread overview]
Message-ID: <46cdf509-c3ff-982d-33fe-ced7159f5093@huawei.com> (raw)
In-Reply-To: <Yr29tlTOTrBfJPBP@kroah.com>


On 2022/6/30 23:13, Greg KH wrote:
> On Thu, Jun 30, 2022 at 10:09:18PM +0800, Yang Yingliang wrote:
>> Add missing sci_cleanup_single() in error case in sci_probe_single()
>>
>> Fixes: f907c9ea8835 ("serial: sh-sci: Add support for GPIO-controlled modem lines")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>>   drivers/tty/serial/sh-sci.c | 20 +++++++++++++-------
>>   1 file changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
>> index 0075a1420005..ca5a58f01aff 100644
>> --- a/drivers/tty/serial/sh-sci.c
>> +++ b/drivers/tty/serial/sh-sci.c
>> @@ -3283,25 +3283,31 @@ static int sci_probe_single(struct platform_device *dev,
>>   		return ret;
>>   
>>   	sciport->gpios = mctrl_gpio_init(&sciport->port, 0);
>> -	if (IS_ERR(sciport->gpios))
>> -		return PTR_ERR(sciport->gpios);
>> +	if (IS_ERR(sciport->gpios)) {
>> +		ret = PTR_ERR(sciport->gpios);
>> +		goto err_cleanup_single;
>> +	}
>>   
>>   	if (sciport->has_rtscts) {
>>   		if (mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_CTS) ||
>>   		    mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_RTS)) {
>>   			dev_err(&dev->dev, "Conflicting RTS/CTS config\n");
>> -			return -EINVAL;
>> +			ret = -EINVAL;
>> +			goto err_cleanup_single;
>>   		}
>>   		sciport->port.flags |= UPF_HARD_FLOW;
>>   	}
>>   
>>   	ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
>> -	if (ret) {
>> -		sci_cleanup_single(sciport);
>> -		return ret;
>> -	}
>> +	if (ret)
>> +		goto err_cleanup_single;
>>   
>>   	return 0;
>> +
>> +err_cleanup_single:
>> +	sci_cleanup_single(sciport);
>> +
>> +	return ret;
>>   }
>>   
>>   static int sci_probe(struct platform_device *dev)
>> -- 
>> 2.25.1
>>
> How was this tested?
I found this by read the code, pm_runtime_enable() is called in 
sci_init_single(), but
pm_runtime_disable() is only called when uart_add_one_port() fails, so I 
add the
pm_runtime_disable() in other error case. Please correct me if I am wrong.

Thanks,
Yang
>
> thanks,
>
> greg k-h
> .

  reply	other threads:[~2022-07-01  4:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 14:09 [PATCH 1/2] serial: sh-sci: fix missing sci_cleanup_single() in sci_probe_single() Yang Yingliang
2022-06-30 14:09 ` [PATCH 2/2] serial: sh-sci: fix missing uart_unregister_driver() " Yang Yingliang
2022-06-30 15:13   ` Greg KH
2022-07-01  2:34     ` Yang Yingliang
2022-06-30 15:13 ` [PATCH 1/2] serial: sh-sci: fix missing sci_cleanup_single() " Greg KH
2022-07-01  4:25   ` Yang Yingliang [this message]
2022-07-07  8:47 ` Geert Uytterhoeven

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=46cdf509-c3ff-982d-33fe-ced7159f5093@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    --cc=sjoerd.simons@collabora.co.uk \
    /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