public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Zhengchao Shao <shaozhengchao@huawei.com>,
	linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org
Cc: akpm@linux-foundation.org, paulkf@microgate.com,
	weiyongjun1@huawei.com, yuehaibing@huawei.com
Subject: Re: [PATCH] tty: synclink_gt: release resources when synclink_gt driver open failed
Date: Mon, 14 Nov 2022 06:44:29 +0100	[thread overview]
Message-ID: <70fe0136-87ab-ed6c-8d65-d57ecbdcdf2f@kernel.org> (raw)
In-Reply-To: <20221114010734.314910-1-shaozhengchao@huawei.com>

On 14. 11. 22, 2:07, Zhengchao Shao wrote:
> When synclink_gt driver open failed, it doesn't release resources.

But hdlc_close() does. Now, you call it (apart from the TTY layer) too.

> Compile tested only.

Hmm, NACK.

> Fixes: d4c63b7c7450 ("synclink_gt fix module reference")
> Fixes: 705b6c7b34f2 ("[PATCH] new driver synclink_gt")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>   drivers/tty/synclink_gt.c | 13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
> index 25e9befdda3a..4dea52486410 100644
> --- a/drivers/tty/synclink_gt.c
> +++ b/drivers/tty/synclink_gt.c
> @@ -1441,14 +1441,15 @@ static int hdlcdev_open(struct net_device *dev)
>   	/* generic HDLC layer open processing */
>   	rc = hdlc_open(dev);
>   	if (rc)
> -		return rc;
> +		goto err_open;
>   
>   	/* arbitrate between network and tty opens */
>   	spin_lock_irqsave(&info->netlock, flags);
>   	if (info->port.count != 0 || info->netcount != 0) {
>   		DBGINFO(("%s hdlc_open busy\n", dev->name));
>   		spin_unlock_irqrestore(&info->netlock, flags);
> -		return -EBUSY;
> +		rc = -EBUSY;
> +		goto err_open_busy;
>   	}
>   	info->netcount=1;
>   	spin_unlock_irqrestore(&info->netlock, flags);
> @@ -1458,7 +1459,7 @@ static int hdlcdev_open(struct net_device *dev)
>   		spin_lock_irqsave(&info->netlock, flags);
>   		info->netcount=0;
>   		spin_unlock_irqrestore(&info->netlock, flags);
> -		return rc;
> +		goto err_open_busy;
>   	}
>   
>   	/* assert RTS and DTR, apply hardware settings */
> @@ -1478,6 +1479,12 @@ static int hdlcdev_open(struct net_device *dev)
>   	else
>   		netif_carrier_off(dev);
>   	return 0;
> +
> +err_open_busy:
> +	hdlc_close(dev);
> +err_open:
> +	module_put(THIS_MODULE);
> +	return rc;
>   }
>   
>   /**

-- 
js
suse labs


  reply	other threads:[~2022-11-14  5:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14  1:07 [PATCH] tty: synclink_gt: release resources when synclink_gt driver open failed Zhengchao Shao
2022-11-14  5:44 ` Jiri Slaby [this message]
2022-11-14  7:19 ` Greg KH
2022-11-14 16:47 ` Paul Fulghum
     [not found]   ` <387F9F7B-C3AF-45BF-94ED-59348990B407@microgate.com>
2022-11-15 17:10     ` [PATCH] tty: synclink_gt: unwind actions in error path of net device open Greg Kroah-Hartman
2022-11-15 17:38       ` Paul Fulghum
2022-11-15 17:54         ` Greg Kroah-Hartman
2022-11-15 17:18     ` Paul Fulghum
2022-11-15 18:21 ` Paul Fulghum
2022-11-15 18:48   ` Greg KH
2022-11-18  3:09 ` [PATCH v2] tty:synclink_gt unwind actions in error path Paul Fulghum

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=70fe0136-87ab-ed6c-8d65-d57ecbdcdf2f@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulkf@microgate.com \
    --cc=shaozhengchao@huawei.com \
    --cc=weiyongjun1@huawei.com \
    --cc=yuehaibing@huawei.com \
    /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