Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe342cf7 authored by David Howells's avatar David Howells
Browse files

afs: Fix checker warnings



Fix warnings raised by checker, including:

 (*) Warnings raised by unequal comparison for the purposes of sorting,
     where the endianness doesn't matter:

fs/afs/addr_list.c:246:21: warning: restricted __be16 degrades to integer
fs/afs/addr_list.c:246:30: warning: restricted __be16 degrades to integer
fs/afs/addr_list.c:248:21: warning: restricted __be32 degrades to integer
fs/afs/addr_list.c:248:49: warning: restricted __be32 degrades to integer
fs/afs/addr_list.c:283:21: warning: restricted __be16 degrades to integer
fs/afs/addr_list.c:283:30: warning: restricted __be16 degrades to integer

 (*) afs_set_cb_interest() is not actually used and can be removed.

 (*) afs_cell_gc_delay() should be provided with a sysctl.

 (*) afs_cell_destroy() needs to use rcu_access_pointer() to read
     cell->vl_addrs.

 (*) afs_init_fs_cursor() should be static.

 (*) struct afs_vnode::permit_cache needs to be marked __rcu.

 (*) afs_server_rcu() needs to use rcu_access_pointer().

 (*) afs_destroy_server() should use rcu_access_pointer() on
     server->addresses as the server object is no longer accessible.

 (*) afs_find_server() casts __be16/__be32 values to int in order to
     directly compare them for the purpose of finding a match in a list,
     but is should also annotate the cast with __force to avoid checker
     warnings.

 (*) afs_check_permit() accesses vnode->permit_cache outside of the RCU
     readlock, though it doesn't then access the value; the extraneous
     access is deleted.

False positives:

 (*) Conditional locking around the code in xdr_decode_AFSFetchStatus.  This
     can be dealt with in a separate patch.

fs/afs/fsclient.c:148:9: warning: context imbalance in 'xdr_decode_AFSFetchStatus' - different lock contexts for basic block

 (*) Incorrect handling of seq-retry lock context balance:

fs/afs/inode.c:455:38: warning: context imbalance in 'afs_getattr' - different
lock contexts for basic block
fs/afs/server.c:52:17: warning: context imbalance in 'afs_find_server' - different lock contexts for basic block
fs/afs/server.c:128:17: warning: context imbalance in 'afs_find_server_by_uuid' - different lock contexts for basic block

Errors:

 (*) afs_lookup_cell_rcu() needs to break out of the seq-retry loop, not go
     round again if it successfully found the workstation cell.

 (*) Fix UUID decode in afs_deliver_cb_probe_uuid().

 (*) afs_cache_permit() has a missing rcu_read_unlock() before one of the
     jumps to the someone_else_changed_it label.  Move the unlock to after
     the label.

 (*) afs_vl_get_addrs_u() is using ntohl() rather than htonl() when
     encoding to XDR.

 (*) afs_deliver_yfsvl_get_endpoints() is using htonl() rather than ntohl()
     when decoding from XDR.

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent a09acf4b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -243,9 +243,9 @@ void afs_merge_fs_addr4(struct afs_addr_list *alist, __be32 xdr, u16 port)
		    xport == a->sin6_port)
			return;
		if (xdr == a->sin6_addr.s6_addr32[3] &&
		    xport < a->sin6_port)
		    (u16 __force)xport < (u16 __force)a->sin6_port)
			break;
		if (xdr < a->sin6_addr.s6_addr32[3])
		if ((u32 __force)xdr < (u32 __force)a->sin6_addr.s6_addr32[3])
			break;
	}

@@ -280,7 +280,7 @@ void afs_merge_fs_addr6(struct afs_addr_list *alist, __be32 *xdr, u16 port)
		    xport == a->sin6_port)
			return;
		if (diff == 0 &&
		    xport < a->sin6_port)
		    (u16 __force)xport < (u16 __force)a->sin6_port)
			break;
		if (diff < 0)
			break;
+0 −20
Original line number Diff line number Diff line
@@ -96,26 +96,6 @@ int afs_register_server_cb_interest(struct afs_vnode *vnode,
	return 0;
}

/*
 * Set a vnode's interest on a server.
 */
void afs_set_cb_interest(struct afs_vnode *vnode, struct afs_cb_interest *cbi)
{
	struct afs_cb_interest *old_cbi = NULL;

	if (vnode->cb_interest == cbi)
		return;

	write_seqlock(&vnode->cb_lock);
	if (vnode->cb_interest != cbi) {
		afs_get_cb_interest(cbi);
		old_cbi = vnode->cb_interest;
		vnode->cb_interest = cbi;
	}
	write_sequnlock(&vnode->cb_lock);
	afs_put_cb_interest(afs_v2net(vnode), cbi);
}

/*
 * Remove an interest on a server.
 */
+3 −3
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
#include <keys/rxrpc-type.h>
#include "internal.h"

unsigned __read_mostly afs_cell_gc_delay = 10;
static unsigned __read_mostly afs_cell_gc_delay = 10;

static void afs_manage_cell(struct work_struct *);

@@ -75,7 +75,7 @@ struct afs_cell *afs_lookup_cell_rcu(struct afs_net *net,
			cell = rcu_dereference_raw(net->ws_cell);
			if (cell) {
				afs_get_cell(cell);
				continue;
				break;
			}
			ret = -EDESTADDRREQ;
			continue;
@@ -411,7 +411,7 @@ static void afs_cell_destroy(struct rcu_head *rcu)

	ASSERTCMP(atomic_read(&cell->usage), ==, 0);

	afs_put_addrlist(cell->vl_addrs);
	afs_put_addrlist(rcu_access_pointer(cell->vl_addrs));
	key_put(cell->anonymous_key);
	kfree(cell);

+3 −3
Original line number Diff line number Diff line
@@ -500,9 +500,9 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)

		b = call->buffer;
		r = call->request;
		r->time_low			= ntohl(b[0]);
		r->time_mid			= ntohl(b[1]);
		r->time_hi_and_version		= ntohl(b[2]);
		r->time_low			= b[0];
		r->time_mid			= htons(ntohl(b[1]));
		r->time_hi_and_version		= htons(ntohl(b[2]));
		r->clock_seq_hi_and_reserved 	= ntohl(b[3]);
		r->clock_seq_low		= ntohl(b[4]);

+1 −1
Original line number Diff line number Diff line
@@ -544,7 +544,7 @@ void afs_evict_inode(struct inode *inode)
	}
#endif

	afs_put_permits(vnode->permit_cache);
	afs_put_permits(rcu_access_pointer(vnode->permit_cache));
	_leave("");
}

Loading