The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ted Unangst <tedu@coverity.com>
To: linux-kernel@vger.kernel.org
Subject: missing spin_unlock in tcp_v4_get_port
Date: Mon, 22 Aug 2005 14:17:36 -0700	[thread overview]
Message-ID: <430A40F0.6030601@coverity.com> (raw)

There appears to be a missing spin_unlock in tcp_v4_get_port.

                 do {    rover++;
                         if (rover > high)
                                 rover = low;
                         head = &tcp_bhash[tcp_bhashfn(rover)];
                         spin_lock(&head->lock);
head->lock is acquired.
                         tb_for_each(tb, node, &head->chain)
                                 if (tb->port == rover)
                                         goto next;
we don't find what we want.  break out of while loop.
                         break;
                 next:
                         spin_unlock(&head->lock);
                 } while (--remaining > 0);
                 tcp_port_rover = rover;
                 spin_unlock(&tcp_portalloc_lock);

                 /* Exhausted local port range during search? */
                 ret = 1;
                 if (remaining <= 0)
                         goto fail;
here we go to fail; head->lock is still acquired.
....
fail_unlock:
         spin_unlock(&head->lock);
fail:
         local_bh_enable();
         return ret;

Is this a real bug?  The same code was also copy-pasted into 
tcp_v6_get_port.


-- 
Ted Unangst             www.coverity.com             Coverity, Inc.

             reply	other threads:[~2005-08-22 21:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-22 21:17 Ted Unangst [this message]
2005-08-22 21:25 ` missing spin_unlock in tcp_v4_get_port David S. Miller

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=430A40F0.6030601@coverity.com \
    --to=tedu@coverity.com \
    --cc=linux-kernel@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