Skip to content

Commit e6fb56b

Browse files
cgzonespcmoore
authored andcommitted
selinux: add likely hints for fast paths
In the network hashtable lookup code add likely() compiler hints in the fast path, like already done in sel_netif_sid(). Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 9cc034b commit e6fb56b

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

security/selinux/ibpkey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int sel_ib_pkey_sid(u64 subnet_prefix, u16 pkey_num, u32 *sid)
184184

185185
rcu_read_lock();
186186
pkey = sel_ib_pkey_find(subnet_prefix, pkey_num);
187-
if (pkey) {
187+
if (likely(pkey)) {
188188
*sid = pkey->psec.sid;
189189
rcu_read_unlock();
190190
return 0;

security/selinux/netnode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int sel_netnode_sid(const void *addr, u16 family, u32 *sid)
253253

254254
rcu_read_lock();
255255
node = sel_netnode_find(addr, family);
256-
if (node != NULL) {
256+
if (likely(node != NULL)) {
257257
*sid = node->nsec.sid;
258258
rcu_read_unlock();
259259
return 0;

security/selinux/netport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ int sel_netport_sid(u8 protocol, u16 pnum, u32 *sid)
186186

187187
rcu_read_lock();
188188
port = sel_netport_find(protocol, pnum);
189-
if (port != NULL) {
189+
if (likely(port != NULL)) {
190190
*sid = port->psec.sid;
191191
rcu_read_unlock();
192192
return 0;

0 commit comments

Comments
 (0)