mirror of
https://github.com/versity/scoutfs.git
synced 2025-12-23 05:25:18 +00:00
Merge pull request #205 from versity/auke/scar
Changes from static analysis.
This commit is contained in:
@@ -857,7 +857,7 @@ static int find_zone_extent(struct super_block *sb, struct scoutfs_alloc_root *r
|
||||
.zone = SCOUTFS_FREE_EXTENT_ORDER_ZONE,
|
||||
};
|
||||
struct scoutfs_extent found;
|
||||
struct scoutfs_extent ext;
|
||||
struct scoutfs_extent ext = {0,};
|
||||
u64 start;
|
||||
u64 len;
|
||||
int nr;
|
||||
|
||||
@@ -435,8 +435,8 @@ static int lookup_mounted_client_item(struct super_block *sb, u64 rid)
|
||||
if (ret == -ENOENT)
|
||||
ret = 0;
|
||||
|
||||
kfree(super);
|
||||
out:
|
||||
kfree(super);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -2188,7 +2188,7 @@ int scoutfs_inode_walk_writeback(struct super_block *sb, bool write)
|
||||
struct scoutfs_inode_info *si;
|
||||
struct scoutfs_inode_info *tmp;
|
||||
struct inode *inode;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
spin_lock(&inf->writeback_lock);
|
||||
|
||||
|
||||
@@ -954,6 +954,9 @@ static int copy_alloc_detail_to_user(struct super_block *sb, void *arg,
|
||||
if (args->copied == args->nr)
|
||||
return -EOVERFLOW;
|
||||
|
||||
/* .type and .pad need clearing */
|
||||
memset(&ade, 0, sizeof(struct scoutfs_ioctl_alloc_detail_entry));
|
||||
|
||||
ade.blocks = blocks;
|
||||
ade.id = id;
|
||||
ade.meta = !!meta;
|
||||
@@ -1369,7 +1372,7 @@ static long scoutfs_ioc_get_referring_entries(struct file *file, unsigned long a
|
||||
ent.d_type = bref->d_type;
|
||||
ent.name_len = name_len;
|
||||
|
||||
if (copy_to_user(uent, &ent, sizeof(struct scoutfs_ioctl_dirent)) ||
|
||||
if (copy_to_user(uent, &ent, offsetof(struct scoutfs_ioctl_dirent, name[0])) ||
|
||||
copy_to_user(&uent->name[0], bref->dent.name, name_len) ||
|
||||
put_user('\0', &uent->name[name_len])) {
|
||||
ret = -EFAULT;
|
||||
|
||||
@@ -1103,9 +1103,15 @@ static void scoutfs_net_listen_worker(struct work_struct *work)
|
||||
conn->notify_down,
|
||||
conn->info_size,
|
||||
conn->req_funcs, "accepted");
|
||||
/*
|
||||
* scoutfs_net_alloc_conn() can fail due to ENOMEM. If this
|
||||
* is the only thing that does so, there's no harm in trying
|
||||
* to see if kernel_accept() can get enough memory to try accepting
|
||||
* a new connection again. If that then fails with ENOMEM, it'll
|
||||
* shut down the conn anyway. So just retry here.
|
||||
*/
|
||||
if (!acc_conn) {
|
||||
sock_release(acc_sock);
|
||||
ret = -ENOMEM;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ static int handle_request(struct super_block *sb, struct omap_request *req)
|
||||
ret = 0;
|
||||
out:
|
||||
free_rids(&priv_rids);
|
||||
if (ret < 0) {
|
||||
if ((ret < 0) && (req != NULL)) {
|
||||
ret = scoutfs_server_send_omap_response(sb, req->client_rid, req->client_id,
|
||||
NULL, ret);
|
||||
free_req(req);
|
||||
|
||||
@@ -1062,7 +1062,7 @@ static char *role_str(int role)
|
||||
[LEADER] = "leader",
|
||||
};
|
||||
|
||||
if (role < 0 || role > ARRAY_SIZE(roles) || !roles[role])
|
||||
if (role < 0 || role >= ARRAY_SIZE(roles) || !roles[role])
|
||||
return "invalid";
|
||||
|
||||
return roles[role];
|
||||
|
||||
@@ -856,14 +856,14 @@ static int search_sorted_file(struct super_block *sb,
|
||||
if (pos > SCOUTFS_SRCH_BLOCK_SAFE_BYTES) {
|
||||
/* can only be inconsistency :/ */
|
||||
ret = -EIO;
|
||||
break;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = decode_entry(srb->entries + pos, &sre, &prev);
|
||||
if (ret <= 0) {
|
||||
/* can only be inconsistency :/ */
|
||||
ret = -EIO;
|
||||
break;
|
||||
goto out;
|
||||
}
|
||||
pos += ret;
|
||||
prev = sre;
|
||||
@@ -1865,7 +1865,7 @@ static int compact_logs(struct super_block *sb,
|
||||
if (pos > SCOUTFS_SRCH_BLOCK_SAFE_BYTES) {
|
||||
/* can only be inconsistency :/ */
|
||||
ret = -EIO;
|
||||
break;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = decode_entry(srb->entries + pos, sre, &prev);
|
||||
@@ -2301,7 +2301,7 @@ out:
|
||||
scoutfs_inc_counter(sb, srch_compact_error);
|
||||
|
||||
scoutfs_block_writer_forget_all(sb, &wri);
|
||||
queue_compact_work(srinf, sc->nr > 0 && ret == 0);
|
||||
queue_compact_work(srinf, sc != NULL && sc->nr > 0 && ret == 0);
|
||||
|
||||
kfree(sc);
|
||||
}
|
||||
|
||||
@@ -512,9 +512,9 @@ static int scoutfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||
|
||||
sbi = kzalloc(sizeof(struct scoutfs_sb_info), GFP_KERNEL);
|
||||
sb->s_fs_info = sbi;
|
||||
sbi->sb = sb;
|
||||
if (!sbi)
|
||||
return -ENOMEM;
|
||||
sbi->sb = sb;
|
||||
|
||||
ret = assign_random_id(sbi);
|
||||
if (ret < 0)
|
||||
|
||||
Reference in New Issue
Block a user