Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 254998
b: refs/heads/master
c: 3a5c374
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Jul 18, 2011
1 parent f654b96 commit 0ca2a5e
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 64 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: 680ba7ca630f5816af9c80a946520be76b2167a5
refs/heads/master: 3a5c3743f15f27237ab025736a981e2d0c9fdfed
1 change: 1 addition & 0 deletions trunk/drivers/hwmon/asus_atk0110.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ static int atk_debugfs_gitm_get(void *p, u64 *val)
else
err = -EIO;

ACPI_FREE(ret);
return err;
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ static struct attribute *it87_attributes_label[] = {
};

static const struct attribute_group it87_group_label = {
.attrs = it87_attributes_vid,
.attrs = it87_attributes_label,
};

/* SuperIO detection - will change isa_address if a chip is found */
Expand Down
11 changes: 11 additions & 0 deletions trunk/drivers/hwmon/max1111.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ struct max1111_data {
struct spi_transfer xfer[2];
uint8_t *tx_buf;
uint8_t *rx_buf;
struct mutex drvdata_lock;
/* protect msg, xfer and buffers from multiple access */
};

static int max1111_read(struct device *dev, int channel)
Expand All @@ -48,19 +50,25 @@ static int max1111_read(struct device *dev, int channel)
uint8_t v1, v2;
int err;

/* writing to drvdata struct is not thread safe, wait on mutex */
mutex_lock(&data->drvdata_lock);

data->tx_buf[0] = (channel << MAX1111_CTRL_SEL_SH) |
MAX1111_CTRL_PD0 | MAX1111_CTRL_PD1 |
MAX1111_CTRL_SGL | MAX1111_CTRL_UNI | MAX1111_CTRL_STR;

err = spi_sync(data->spi, &data->msg);
if (err < 0) {
dev_err(dev, "spi_sync failed with %d\n", err);
mutex_unlock(&data->drvdata_lock);
return err;
}

v1 = data->rx_buf[0];
v2 = data->rx_buf[1];

mutex_unlock(&data->drvdata_lock);

if ((v1 & 0xc0) || (v2 & 0x3f))
return -EINVAL;

Expand Down Expand Up @@ -176,6 +184,8 @@ static int __devinit max1111_probe(struct spi_device *spi)
if (err)
goto err_free_data;

mutex_init(&data->drvdata_lock);

data->spi = spi;
spi_set_drvdata(spi, data);

Expand Down Expand Up @@ -213,6 +223,7 @@ static int __devexit max1111_remove(struct spi_device *spi)

hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group);
mutex_destroy(&data->drvdata_lock);
kfree(data->rx_buf);
kfree(data->tx_buf);
kfree(data);
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/media/radio/si4713-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ static int si4713_write_econtrol_string(struct si4713_device *sdev,
char ps_name[MAX_RDS_PS_NAME + 1];

len = control->size - 1;
if (len > MAX_RDS_PS_NAME) {
if (len < 0 || len > MAX_RDS_PS_NAME) {
rval = -ERANGE;
goto exit;
}
Expand All @@ -1057,7 +1057,7 @@ static int si4713_write_econtrol_string(struct si4713_device *sdev,
char radio_text[MAX_RDS_RADIO_TEXT + 1];

len = control->size - 1;
if (len > MAX_RDS_RADIO_TEXT) {
if (len < 0 || len > MAX_RDS_RADIO_TEXT) {
rval = -ERANGE;
goto exit;
}
Expand Down
19 changes: 16 additions & 3 deletions trunk/fs/ceph/mds_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,12 +1438,15 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
struct dentry *temp;
char *path;
int len, pos;
unsigned seq;

if (dentry == NULL)
return ERR_PTR(-EINVAL);

retry:
len = 0;
seq = read_seqbegin(&rename_lock);
rcu_read_lock();
for (temp = dentry; !IS_ROOT(temp);) {
struct inode *inode = temp->d_inode;
if (inode && ceph_snap(inode) == CEPH_SNAPDIR)
Expand All @@ -1455,10 +1458,12 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
len += 1 + temp->d_name.len;
temp = temp->d_parent;
if (temp == NULL) {
rcu_read_unlock();
pr_err("build_path corrupt dentry %p\n", dentry);
return ERR_PTR(-EINVAL);
}
}
rcu_read_unlock();
if (len)
len--; /* no leading '/' */

Expand All @@ -1467,9 +1472,12 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
return ERR_PTR(-ENOMEM);
pos = len;
path[pos] = 0; /* trailing null */
rcu_read_lock();
for (temp = dentry; !IS_ROOT(temp) && pos != 0; ) {
struct inode *inode = temp->d_inode;
struct inode *inode;

spin_lock(&temp->d_lock);
inode = temp->d_inode;
if (inode && ceph_snap(inode) == CEPH_SNAPDIR) {
dout("build_path path+%d: %p SNAPDIR\n",
pos, temp);
Expand All @@ -1478,21 +1486,26 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
break;
} else {
pos -= temp->d_name.len;
if (pos < 0)
if (pos < 0) {
spin_unlock(&temp->d_lock);
break;
}
strncpy(path + pos, temp->d_name.name,
temp->d_name.len);
}
spin_unlock(&temp->d_lock);
if (pos)
path[--pos] = '/';
temp = temp->d_parent;
if (temp == NULL) {
rcu_read_unlock();
pr_err("build_path corrupt dentry\n");
kfree(path);
return ERR_PTR(-EINVAL);
}
}
if (pos != 0) {
rcu_read_unlock();
if (pos != 0 || read_seqretry(&rename_lock, seq)) {
pr_err("build_path did not end path lookup where "
"expected, namelen is %d, pos is %d\n", len, pos);
/* presumably this is only possible if racing with a
Expand Down
13 changes: 12 additions & 1 deletion trunk/fs/cifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ build_path_from_dentry(struct dentry *direntry)
char dirsep;
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
unsigned seq;

if (direntry == NULL)
return NULL; /* not much we can do if dentry is freed and
Expand All @@ -68,37 +69,47 @@ build_path_from_dentry(struct dentry *direntry)
dfsplen = 0;
cifs_bp_rename_retry:
namelen = dfsplen;
seq = read_seqbegin(&rename_lock);
rcu_read_lock();
for (temp = direntry; !IS_ROOT(temp);) {
namelen += (1 + temp->d_name.len);
temp = temp->d_parent;
if (temp == NULL) {
cERROR(1, "corrupt dentry");
rcu_read_unlock();
return NULL;
}
}
rcu_read_unlock();

full_path = kmalloc(namelen+1, GFP_KERNEL);
if (full_path == NULL)
return full_path;
full_path[namelen] = 0; /* trailing null */
rcu_read_lock();
for (temp = direntry; !IS_ROOT(temp);) {
spin_lock(&temp->d_lock);
namelen -= 1 + temp->d_name.len;
if (namelen < 0) {
spin_unlock(&temp->d_lock);
break;
} else {
full_path[namelen] = dirsep;
strncpy(full_path + namelen + 1, temp->d_name.name,
temp->d_name.len);
cFYI(0, "name: %s", full_path + namelen);
}
spin_unlock(&temp->d_lock);
temp = temp->d_parent;
if (temp == NULL) {
cERROR(1, "corrupt dentry");
rcu_read_unlock();
kfree(full_path);
return NULL;
}
}
if (namelen != dfsplen) {
rcu_read_unlock();
if (namelen != dfsplen || read_seqretry(&rename_lock, seq)) {
cERROR(1, "did not end path lookup where expected namelen is %d",
namelen);
/* presumably this is only possible if racing with a rename
Expand Down
22 changes: 12 additions & 10 deletions trunk/fs/cramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static DEFINE_MUTEX(read_mutex);
/* These macros may change in future, to provide better st_ino semantics. */
#define OFFSET(x) ((x)->i_ino)

static unsigned long cramino(struct cramfs_inode *cino, unsigned int offset)
static unsigned long cramino(const struct cramfs_inode *cino, unsigned int offset)
{
if (!cino->offset)
return offset + 1;
Expand All @@ -61,7 +61,7 @@ static unsigned long cramino(struct cramfs_inode *cino, unsigned int offset)
}

static struct inode *get_cramfs_inode(struct super_block *sb,
struct cramfs_inode *cramfs_inode, unsigned int offset)
const struct cramfs_inode *cramfs_inode, unsigned int offset)
{
struct inode *inode;
static struct timespec zerotime;
Expand Down Expand Up @@ -317,7 +317,7 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
/* Set it all up.. */
sb->s_op = &cramfs_ops;
root = get_cramfs_inode(sb, &super.root, 0);
if (!root)
if (IS_ERR(root))
goto out;
sb->s_root = d_alloc_root(root);
if (!sb->s_root) {
Expand Down Expand Up @@ -423,6 +423,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
{
unsigned int offset = 0;
struct inode *inode = NULL;
int sorted;

mutex_lock(&read_mutex);
Expand All @@ -449,8 +450,8 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s

for (;;) {
if (!namelen) {
mutex_unlock(&read_mutex);
return ERR_PTR(-EIO);
inode = ERR_PTR(-EIO);
goto out;
}
if (name[namelen-1])
break;
Expand All @@ -462,17 +463,18 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
if (retval > 0)
continue;
if (!retval) {
struct cramfs_inode entry = *de;
mutex_unlock(&read_mutex);
d_add(dentry, get_cramfs_inode(dir->i_sb, &entry, dir_off));
return NULL;
inode = get_cramfs_inode(dir->i_sb, de, dir_off);
break;
}
/* else (retval < 0) */
if (sorted)
break;
}
out:
mutex_unlock(&read_mutex);
d_add(dentry, NULL);
if (IS_ERR(inode))
return ERR_CAST(inode);
d_add(dentry, inode);
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/exofs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ struct dentry *exofs_get_parent(struct dentry *child)
unsigned long ino = exofs_parent_ino(child);

if (!ino)
return NULL;
return ERR_PTR(-ESTALE);

return d_obtain_alias(exofs_iget(child->d_inode->i_sb, ino));
}
Expand Down
31 changes: 9 additions & 22 deletions trunk/fs/hppfs/hppfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ static int file_removed(struct dentry *dentry, const char *file)
static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
struct nameidata *nd)
{
struct dentry *proc_dentry, *new, *parent;
struct dentry *proc_dentry, *parent;
struct qstr *name = &dentry->d_name;
struct inode *inode;
int err, deleted;

Expand All @@ -149,23 +150,9 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
else if (deleted)
return ERR_PTR(-ENOENT);

err = -ENOMEM;
parent = HPPFS_I(ino)->proc_dentry;
mutex_lock(&parent->d_inode->i_mutex);
proc_dentry = d_lookup(parent, &dentry->d_name);
if (proc_dentry == NULL) {
proc_dentry = d_alloc(parent, &dentry->d_name);
if (proc_dentry == NULL) {
mutex_unlock(&parent->d_inode->i_mutex);
goto out;
}
new = (*parent->d_inode->i_op->lookup)(parent->d_inode,
proc_dentry, NULL);
if (new) {
dput(proc_dentry);
proc_dentry = new;
}
}
proc_dentry = lookup_one_len(name->name, parent, name->len);
mutex_unlock(&parent->d_inode->i_mutex);

if (IS_ERR(proc_dentry))
Expand All @@ -174,13 +161,11 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
err = -ENOMEM;
inode = get_inode(ino->i_sb, proc_dentry);
if (!inode)
goto out_dput;
goto out;

d_add(dentry, inode);
return NULL;

out_dput:
dput(proc_dentry);
out:
return ERR_PTR(err);
}
Expand Down Expand Up @@ -690,8 +675,10 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
struct inode *proc_ino = dentry->d_inode;
struct inode *inode = new_inode(sb);

if (!inode)
if (!inode) {
dput(dentry);
return ERR_PTR(-ENOMEM);
}

if (S_ISDIR(dentry->d_inode->i_mode)) {
inode->i_op = &hppfs_dir_iops;
Expand All @@ -704,7 +691,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
inode->i_fop = &hppfs_file_fops;
}

HPPFS_I(inode)->proc_dentry = dget(dentry);
HPPFS_I(inode)->proc_dentry = dentry;

inode->i_uid = proc_ino->i_uid;
inode->i_gid = proc_ino->i_gid;
Expand Down Expand Up @@ -737,7 +724,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
sb->s_fs_info = proc_mnt;

err = -ENOMEM;
root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root);
root_inode = get_inode(sb, dget(proc_mnt->mnt_sb->s_root));
if (!root_inode)
goto out_mntput;

Expand Down
12 changes: 4 additions & 8 deletions trunk/fs/ufs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru

lock_ufs(dir->i_sb);
ino = ufs_inode_by_name(dir, &dentry->d_name);
if (ino) {
if (ino)
inode = ufs_iget(dir->i_sb, ino);
if (IS_ERR(inode)) {
unlock_ufs(dir->i_sb);
return ERR_CAST(inode);
}
}
unlock_ufs(dir->i_sb);
d_add(dentry, inode);
return NULL;
if (IS_ERR(inode))
return ERR_CAST(inode);
return d_splice_alias(inode, dentry);
}

/*
Expand Down
Loading

0 comments on commit 0ca2a5e

Please sign in to comment.