77 *
88 * Copyright (C) 2018 Red Hat, Inc.
99 */
10+
1011#include <linux/errno.h>
1112#include <linux/kernel.h>
1213#include <linux/list.h>
@@ -29,7 +30,7 @@ struct sidtab_str_cache {
2930};
3031
3132#define index_to_sid (index ) ((index) + SECINITSID_NUM + 1)
32- #define sid_to_index (sid ) ((sid) - (SECINITSID_NUM + 1))
33+ #define sid_to_index (sid ) ((sid) - (SECINITSID_NUM + 1))
3334
3435int sidtab_init (struct sidtab * s )
3536{
@@ -140,9 +141,11 @@ int sidtab_hash_stats(struct sidtab *sidtab, char *page)
140141 if (chain_len > max_chain_len )
141142 max_chain_len = chain_len ;
142143
143- return scnprintf (page , PAGE_SIZE , "entries: %d\nbuckets used: %d/%d\n"
144- "longest chain: %d\n" , entries ,
145- slots_used , SIDTAB_HASH_BUCKETS , max_chain_len );
144+ return scnprintf (page , PAGE_SIZE ,
145+ "entries: %d\nbuckets used: %d/%d\n"
146+ "longest chain: %d\n" ,
147+ entries , slots_used , SIDTAB_HASH_BUCKETS ,
148+ max_chain_len );
146149}
147150
148151static u32 sidtab_level_from_count (u32 count )
@@ -162,15 +165,15 @@ static int sidtab_alloc_roots(struct sidtab *s, u32 level)
162165 u32 l ;
163166
164167 if (!s -> roots [0 ].ptr_leaf ) {
165- s -> roots [0 ].ptr_leaf = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
166- GFP_ATOMIC );
168+ s -> roots [0 ].ptr_leaf =
169+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
167170 if (!s -> roots [0 ].ptr_leaf )
168171 return - ENOMEM ;
169172 }
170173 for (l = 1 ; l <= level ; ++ l )
171174 if (!s -> roots [l ].ptr_inner ) {
172- s -> roots [l ].ptr_inner = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
173- GFP_ATOMIC );
175+ s -> roots [l ].ptr_inner =
176+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
174177 if (!s -> roots [l ].ptr_inner )
175178 return - ENOMEM ;
176179 s -> roots [l ].ptr_inner -> entries [0 ] = s -> roots [l - 1 ];
@@ -203,16 +206,16 @@ static struct sidtab_entry *sidtab_do_lookup(struct sidtab *s, u32 index,
203206
204207 if (!entry -> ptr_inner ) {
205208 if (alloc )
206- entry -> ptr_inner = kzalloc (SIDTAB_NODE_ALLOC_SIZE ,
207- GFP_ATOMIC );
209+ entry -> ptr_inner = kzalloc (
210+ SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
208211 if (!entry -> ptr_inner )
209212 return NULL ;
210213 }
211214 }
212215 if (!entry -> ptr_leaf ) {
213216 if (alloc )
214- entry -> ptr_leaf = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
215- GFP_ATOMIC );
217+ entry -> ptr_leaf =
218+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
216219 if (!entry -> ptr_leaf )
217220 return NULL ;
218221 }
@@ -262,8 +265,7 @@ struct sidtab_entry *sidtab_search_entry_force(struct sidtab *s, u32 sid)
262265 return sidtab_search_core (s , sid , 1 );
263266}
264267
265- int sidtab_context_to_sid (struct sidtab * s , struct context * context ,
266- u32 * sid )
268+ int sidtab_context_to_sid (struct sidtab * s , struct context * context , u32 * sid )
267269{
268270 unsigned long flags ;
269271 u32 count , hash = context_compute_hash (context );
@@ -327,8 +329,8 @@ int sidtab_context_to_sid(struct sidtab *s, struct context *context,
327329 goto out_unlock ;
328330 }
329331
330- rc = services_convert_context (convert -> args ,
331- context , & dst_convert -> context ,
332+ rc = services_convert_context (convert -> args , context ,
333+ & dst_convert -> context ,
332334 GFP_ATOMIC );
333335 if (rc ) {
334336 context_destroy (& dst -> context );
@@ -338,8 +340,8 @@ int sidtab_context_to_sid(struct sidtab *s, struct context *context,
338340 dst_convert -> hash = context_compute_hash (& dst_convert -> context );
339341 target -> count = count + 1 ;
340342
341- hash_add_rcu (target -> context_to_sid ,
342- & dst_convert -> list , dst_convert -> hash );
343+ hash_add_rcu (target -> context_to_sid , & dst_convert -> list ,
344+ dst_convert -> hash );
343345 }
344346
345347 if (context -> len )
@@ -373,17 +375,17 @@ static void sidtab_convert_hashtable(struct sidtab *s, u32 count)
373375}
374376
375377static int sidtab_convert_tree (union sidtab_entry_inner * edst ,
376- union sidtab_entry_inner * esrc ,
377- u32 * pos , u32 count , u32 level ,
378+ union sidtab_entry_inner * esrc , u32 * pos ,
379+ u32 count , u32 level ,
378380 struct sidtab_convert_params * convert )
379381{
380382 int rc ;
381383 u32 i ;
382384
383385 if (level != 0 ) {
384386 if (!edst -> ptr_inner ) {
385- edst -> ptr_inner = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
386- GFP_KERNEL );
387+ edst -> ptr_inner =
388+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_KERNEL );
387389 if (!edst -> ptr_inner )
388390 return - ENOMEM ;
389391 }
@@ -399,17 +401,18 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst,
399401 }
400402 } else {
401403 if (!edst -> ptr_leaf ) {
402- edst -> ptr_leaf = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
403- GFP_KERNEL );
404+ edst -> ptr_leaf =
405+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_KERNEL );
404406 if (!edst -> ptr_leaf )
405407 return - ENOMEM ;
406408 }
407409 i = 0 ;
408410 while (i < SIDTAB_LEAF_ENTRIES && * pos < count ) {
409- rc = services_convert_context (convert -> args ,
410- & esrc -> ptr_leaf -> entries [i ].context ,
411- & edst -> ptr_leaf -> entries [i ].context ,
412- GFP_KERNEL );
411+ rc = services_convert_context (
412+ convert -> args ,
413+ & esrc -> ptr_leaf -> entries [i ].context ,
414+ & edst -> ptr_leaf -> entries [i ].context ,
415+ GFP_KERNEL );
413416 if (rc )
414417 return rc ;
415418 (* pos )++ ;
@@ -489,13 +492,15 @@ void sidtab_cancel_convert(struct sidtab *s)
489492 spin_unlock_irqrestore (& s -> lock , flags );
490493}
491494
492- void sidtab_freeze_begin (struct sidtab * s , unsigned long * flags ) __acquires (& s - > lock )
495+ void sidtab_freeze_begin (struct sidtab * s , unsigned long * flags )
496+ __acquires (& s - > lock )
493497{
494498 spin_lock_irqsave (& s -> lock , * flags );
495499 s -> frozen = true;
496500 s -> convert = NULL ;
497501}
498- void sidtab_freeze_end (struct sidtab * s , unsigned long * flags ) __releases (& s - > lock )
502+ void sidtab_freeze_end (struct sidtab * s , unsigned long * flags )
503+ __releases (& s - > lock )
499504{
500505 spin_unlock_irqrestore (& s -> lock , * flags );
501506}
@@ -600,8 +605,8 @@ void sidtab_sid2str_put(struct sidtab *s, struct sidtab_entry *entry,
600605 kfree_rcu (victim , rcu_member );
601606}
602607
603- int sidtab_sid2str_get (struct sidtab * s , struct sidtab_entry * entry ,
604- char * * out , u32 * out_len )
608+ int sidtab_sid2str_get (struct sidtab * s , struct sidtab_entry * entry , char * * out ,
609+ u32 * out_len )
605610{
606611 struct sidtab_str_cache * cache ;
607612 int rc = 0 ;
0 commit comments