Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359379
b: refs/heads/master
c: 94960e8
h: refs/heads/master
i:
  359377: df44607
  359375: edb997b
v: v3
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent a7b17f5 commit bc5acb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9475af6e44d2c17583243c253e2464467b52fa50
refs/heads/master: 94960e8c2e69d1e4c01c10c7b00bc0f7eba49fa1
31 changes: 15 additions & 16 deletions trunk/net/sctp/associola.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,32 +1591,31 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
/* Set an association id for a given association */
int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
{
int assoc_id;
int error = 0;
bool preload = gfp & __GFP_WAIT;
int ret;

/* If the id is already assigned, keep it. */
if (asoc->assoc_id)
return error;
retry:
if (unlikely(!idr_pre_get(&sctp_assocs_id, gfp)))
return -ENOMEM;
return 0;

if (preload)
idr_preload(gfp);
spin_lock_bh(&sctp_assocs_id_lock);
error = idr_get_new_above(&sctp_assocs_id, (void *)asoc,
idr_low, &assoc_id);
if (!error) {
idr_low = assoc_id + 1;
/* 0 is not a valid id, idr_low is always >= 1 */
ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT);
if (ret >= 0) {
idr_low = ret + 1;
if (idr_low == INT_MAX)
idr_low = 1;
}
spin_unlock_bh(&sctp_assocs_id_lock);
if (error == -EAGAIN)
goto retry;
else if (error)
return error;
if (preload)
idr_preload_end();
if (ret < 0)
return ret;

asoc->assoc_id = (sctp_assoc_t) assoc_id;
return error;
asoc->assoc_id = (sctp_assoc_t)ret;
return 0;
}

/* Free the ASCONF queue */
Expand Down

0 comments on commit bc5acb4

Please sign in to comment.