Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 107269
b: refs/heads/master
c: 67935df
h: refs/heads/master
i:
  107267: 4aeebe2
v: v3
  • Loading branch information
Alexey Dobriyan authored and Al Viro committed Aug 1, 2008
1 parent 3763241 commit 11a99bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 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: 8266602033d6adc6d10cb8811c1fd694767909b0
refs/heads/master: 67935df49dae836fa86621861979fafdfd37ae59
21 changes: 9 additions & 12 deletions trunk/fs/proc/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ static int xlate_proc_name(const char *name,
static DEFINE_IDR(proc_inum_idr);
static DEFINE_SPINLOCK(proc_inum_lock); /* protects the above */

#define PROC_DYNAMIC_FIRST 0xF0000000UL
#define PROC_DYNAMIC_FIRST 0xF0000000U

/*
* Return an inode number between PROC_DYNAMIC_FIRST and
* 0xffffffff, or zero on failure.
*/
static unsigned int get_inode_number(void)
{
int i, inum = 0;
unsigned int i;
int error;

retry:
Expand All @@ -326,21 +326,18 @@ static unsigned int get_inode_number(void)
else if (error)
return 0;

inum = (i & MAX_ID_MASK) + PROC_DYNAMIC_FIRST;

/* inum will never be more than 0xf0ffffff, so no check
* for overflow.
*/

return inum;
if (i > UINT_MAX - PROC_DYNAMIC_FIRST) {
spin_lock(&proc_inum_lock);
idr_remove(&proc_inum_idr, i);
spin_unlock(&proc_inum_lock);
}
return PROC_DYNAMIC_FIRST + i;
}

static void release_inode_number(unsigned int inum)
{
int id = (inum - PROC_DYNAMIC_FIRST) | ~MAX_ID_MASK;

spin_lock(&proc_inum_lock);
idr_remove(&proc_inum_idr, id);
idr_remove(&proc_inum_idr, inum - PROC_DYNAMIC_FIRST);
spin_unlock(&proc_inum_lock);
}

Expand Down

0 comments on commit 11a99bf

Please sign in to comment.