summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2018-12-12 16:45:09 -0500
committerAmar Tumballi <amarts@redhat.com>2018-12-14 04:33:15 +0000
commitbfe2b5e1530efd364af7a175c8a1c89bc4cab0bb (patch)
tree2030f52c92661f8d285c9905481787dced506a91 /api
parent8293d21280fd6ddfc9bb54068cf87794fc6be207 (diff)
clang: Fix various missing checks for empty list
When using list_for_each_entry(_safe) functions, care needs to be taken that the list passed in are not empty, as these functions are not empty list safe. clag scan reported various points where this this pattern could be caught, and this patch fixes the same. Additionally the following changes are present in this patch, - Added an explicit op_ret setting in error case in the macro MAKE_INODE_HANDLE to address another clang issue reported - Minor refactoring of some functions in quota code, to address possible allocation failures in certain functions (which in turn cause possible empty lists to be passed around) Change-Id: I1e761a8d218708f714effb56fa643df2a3ea2cc7 Updates: bz#1622665 Signed-off-by: ShyamsundarR <srangana@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-fops.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index f59990aed1f..a534697fc12 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -5314,9 +5314,7 @@ glfs_recall_lease_fd(struct glfs *fs, struct gf_upcall *up_data)
inode_t *inode = NULL;
struct glfs_fd *glfd = NULL;
struct glfs_fd *tmp = NULL;
- struct list_head glfd_list = {
- 0,
- };
+ struct list_head glfd_list;
fd_t *fd = NULL;
uint64_t value = 0;
struct glfs_lease lease = {
@@ -5365,22 +5363,24 @@ glfs_recall_lease_fd(struct glfs *fs, struct gf_upcall *up_data)
}
UNLOCK(&inode->lock);
- list_for_each_entry_safe(glfd, tmp, &glfd_list, list)
- {
- LOCK(&glfd->lock);
+ if (!list_empty(&glfd_list)) {
+ list_for_each_entry_safe(glfd, tmp, &glfd_list, list)
{
- if (glfd->state != GLFD_CLOSE) {
- gf_msg_trace(THIS->name, 0,
- "glfd (%p) has held lease, "
- "calling recall cbk",
- glfd);
- glfd->cbk(lease, glfd->cookie);
+ LOCK(&glfd->lock);
+ {
+ if (glfd->state != GLFD_CLOSE) {
+ gf_msg_trace(THIS->name, 0,
+ "glfd (%p) has held lease, "
+ "calling recall cbk",
+ glfd);
+ glfd->cbk(lease, glfd->cookie);
+ }
}
- }
- UNLOCK(&glfd->lock);
+ UNLOCK(&glfd->lock);
- list_del_init(&glfd->list);
- GF_REF_PUT(glfd);
+ list_del_init(&glfd->list);
+ GF_REF_PUT(glfd);
+ }
}
out: