Print this page
3743 zfs needs a refcount audit
Submitted by:   Will Andrews <willa@spectralogic.com>
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>


 166         zap_cursor_t zc;
 167         zap_attribute_t za;
 168         zbookmark_t zb;
 169 
 170         if (obj == 0)
 171                 return (0);
 172 
 173         for (zap_cursor_init(&zc, spa->spa_meta_objset, obj);
 174             zap_cursor_retrieve(&zc, &za) == 0;
 175             zap_cursor_advance(&zc)) {
 176 
 177                 if (*count == 0) {
 178                         zap_cursor_fini(&zc);
 179                         return (SET_ERROR(ENOMEM));
 180                 }
 181 
 182                 name_to_bookmark(za.za_name, &zb);
 183 
 184                 if (copyout(&zb, (char *)addr +
 185                     (*count - 1) * sizeof (zbookmark_t),
 186                     sizeof (zbookmark_t)) != 0)

 187                         return (SET_ERROR(EFAULT));

 188 
 189                 *count -= 1;
 190         }
 191 
 192         zap_cursor_fini(&zc);
 193 
 194         return (0);
 195 }
 196 
 197 static int
 198 process_error_list(avl_tree_t *list, void *addr, size_t *count)
 199 {
 200         spa_error_entry_t *se;
 201 
 202         for (se = avl_first(list); se != NULL; se = AVL_NEXT(list, se)) {
 203 
 204                 if (*count == 0)
 205                         return (SET_ERROR(ENOMEM));
 206 
 207                 if (copyout(&se->se_bookmark, (char *)addr +




 166         zap_cursor_t zc;
 167         zap_attribute_t za;
 168         zbookmark_t zb;
 169 
 170         if (obj == 0)
 171                 return (0);
 172 
 173         for (zap_cursor_init(&zc, spa->spa_meta_objset, obj);
 174             zap_cursor_retrieve(&zc, &za) == 0;
 175             zap_cursor_advance(&zc)) {
 176 
 177                 if (*count == 0) {
 178                         zap_cursor_fini(&zc);
 179                         return (SET_ERROR(ENOMEM));
 180                 }
 181 
 182                 name_to_bookmark(za.za_name, &zb);
 183 
 184                 if (copyout(&zb, (char *)addr +
 185                     (*count - 1) * sizeof (zbookmark_t),
 186                     sizeof (zbookmark_t)) != 0) {
 187                         zap_cursor_fini(&zc);
 188                         return (SET_ERROR(EFAULT));
 189                 }
 190 
 191                 *count -= 1;
 192         }
 193 
 194         zap_cursor_fini(&zc);
 195 
 196         return (0);
 197 }
 198 
 199 static int
 200 process_error_list(avl_tree_t *list, void *addr, size_t *count)
 201 {
 202         spa_error_entry_t *se;
 203 
 204         for (se = avl_first(list); se != NULL; se = AVL_NEXT(list, se)) {
 205 
 206                 if (*count == 0)
 207                         return (SET_ERROR(ENOMEM));
 208 
 209                 if (copyout(&se->se_bookmark, (char *)addr +