All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugene Teo <eteo@redhat.com>
To: lksctp-developers@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, Eugene Teo <eteo@redhat.com>
Subject: [2.6 patch] net/sctp/socket.c: add missing sctp_spin_unlock_irqrestore
Date: Sun, 26 Nov 2006 18:00:53 +0800	[thread overview]
Message-ID: <456965D5.1000302@redhat.com> (raw)

This patch adds a missing sctp_spin_unlock_irqrestore when returning
from "if(space_left<addrlen)" condition.

Signed-off-by: Eugene Teo <eteo@redhat.com>

  net/sctp/socket.c |   19 +++++++++++--------
  1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 935bc91..a5d4d75 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3955,7 +3955,7 @@ static int sctp_copy_laddrs_to_user(stru
         struct sctp_sockaddr_entry *addr;
         unsigned long flags;
         union sctp_addr temp;
-       int cnt = 0;
+       int cnt = 0, err = 0;
         int addrlen;

         sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
@@ -3968,21 +3968,24 @@ static int sctp_copy_laddrs_to_user(stru
                 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
                                                                 &temp);
                 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
-               if(space_left<addrlen)
-                       return -ENOMEM;
+               if(space_left<addrlen) {
+                       err = -ENOMEM;
+                       goto unlock;
+               }
                 temp.v4.sin_port = htons(port);
                 if (copy_to_user(*to, &temp, addrlen)) {
-                       sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
-                                                   flags);
-                       return -EFAULT;
+                       err = -EFAULT;
+                       goto unlock;
                 }
                 *to += addrlen;
                 cnt ++;
                 space_left -= addrlen;
         }
-       sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
+       err = cnt;

-       return cnt;
+unlock:
+       sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
+       return err;
  }

  /* Old API for getting list of local addresses. Does not work for 32-bit


-- 
eteo redhat.com  ph: +65 6490 4142  http://www.kernel.org/~eugeneteo
gpg fingerprint:  47B9 90F6 AE4A 9C51 37E0  D6E1 EA84 C6A2 58DF 8823

             reply	other threads:[~2006-11-26 10:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-26 10:00 Eugene Teo [this message]
2006-11-26 10:12 ` [2.6 patch] net/sctp/socket.c: add missing sctp_spin_unlock_irqrestore Al Viro
2006-11-26 10:19   ` Arjan van de Ven
2006-11-26 12:37   ` Eugene Teo

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=456965D5.1000302@redhat.com \
    --to=eteo@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lksctp-developers@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.