mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Clements <paul.clements@steeleye.com>
To: Pavel Machek <pavel@suse.cz>
Cc: kernel list <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: nbd: fix locking in case of error
Date: Thu, 18 Dec 2008 14:30:35 -0500	[thread overview]
Message-ID: <494AA4DB.5000807@steeleye.com> (raw)
In-Reply-To: <20081218183310.GA21260@elf.ucw.cz>

Pavel Machek wrote:
> This cleans up error handling some more, and prevents return with lock
> held from nbd_handle_req when nbd_send_req() fails. It also switches

>  static struct request *nbd_find_request(struct nbd_device *lo,
> @@ -467,10 +467,9 @@ static void nbd_handle_req(struct nbd_de
>  
>  	mutex_lock(&lo->tx_lock);
>  	if (unlikely(!lo->sock)) {
> -		mutex_unlock(&lo->tx_lock);
>  		printk(KERN_ERR "%s: Attempted send on closed socket\n",
>  		       lo->disk->disk_name);
> -		goto error_out;
> +		goto error_out_unlock;
>  	}
>  
>  	lo->active_req = req;
> @@ -478,7 +477,7 @@ static void nbd_handle_req(struct nbd_de
>  	if (nbd_send_req(lo, req) != 0) {
>  		printk(KERN_ERR "%s: Request send failed\n",
>  				lo->disk->disk_name);
> -		goto error_out;
> +		goto error_out_unlock;
>  	} else {
>  		spin_lock(&lo->queue_lock);
>  		list_add(&req->queuelist, &lo->queue_head);
> @@ -491,6 +490,8 @@ static void nbd_handle_req(struct nbd_de
>  
>  	return;
>  
> +error_out_unlock:
> +	mutex_unlock(&lo->tx_lock);
>  error_out:
>  	req->errors++;
>  	nbd_end_request(req);

Not sure I see the problem. tx_lock is unlocked in every return path 
AFAICS. You introduced the tx_lock problem with the previous patch, 
where the second error_out was not correct.

--
Paul

      reply	other threads:[~2008-12-18 19:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-18 18:33 Pavel Machek
2008-12-18 19:30 ` Paul Clements [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=494AA4DB.5000807@steeleye.com \
    --to=paul.clements@steeleye.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    /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

Powered by JetHome