tree-checker.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. /*
  2. * Copyright (C) Qu Wenruo 2017. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License v2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public
  14. * License along with this program.
  15. */
  16. /*
  17. * The module is used to catch unexpected/corrupted tree block data.
  18. * Such behavior can be caused either by a fuzzed image or bugs.
  19. *
  20. * The objective is to do leaf/node validation checks when tree block is read
  21. * from disk, and check *every* possible member, so other code won't
  22. * need to checking them again.
  23. *
  24. * Due to the potential and unwanted damage, every checker needs to be
  25. * carefully reviewed otherwise so it does not prevent mount of valid images.
  26. */
  27. #include "ctree.h"
  28. #include "tree-checker.h"
  29. #include "disk-io.h"
  30. #include "compression.h"
  31. #include "hash.h"
  32. /*
  33. * Error message should follow the following format:
  34. * corrupt <type>: <identifier>, <reason>[, <bad_value>]
  35. *
  36. * @type: leaf or node
  37. * @identifier: the necessary info to locate the leaf/node.
  38. * It's recommened to decode key.objecitd/offset if it's
  39. * meaningful.
  40. * @reason: describe the error
  41. * @bad_value: optional, it's recommened to output bad value and its
  42. * expected value (range).
  43. *
  44. * Since comma is used to separate the components, only space is allowed
  45. * inside each component.
  46. */
  47. /*
  48. * Append generic "corrupt leaf/node root=%llu block=%llu slot=%d: " to @fmt.
  49. * Allows callers to customize the output.
  50. */
  51. __printf(4, 5)
  52. static void generic_err(const struct btrfs_fs_info *fs_info,
  53. const struct extent_buffer *eb, int slot,
  54. const char *fmt, ...)
  55. {
  56. struct va_format vaf;
  57. va_list args;
  58. va_start(args, fmt);
  59. vaf.fmt = fmt;
  60. vaf.va = &args;
  61. btrfs_crit(fs_info,
  62. "corrupt %s: root=%llu block=%llu slot=%d, %pV",
  63. btrfs_header_level(eb) == 0 ? "leaf" : "node",
  64. btrfs_header_owner(eb), btrfs_header_bytenr(eb), slot, &vaf);
  65. va_end(args);
  66. }
  67. /*
  68. * Customized reporter for extent data item, since its key objectid and
  69. * offset has its own meaning.
  70. */
  71. __printf(4, 5)
  72. static void file_extent_err(const struct btrfs_fs_info *fs_info,
  73. const struct extent_buffer *eb, int slot,
  74. const char *fmt, ...)
  75. {
  76. struct btrfs_key key;
  77. struct va_format vaf;
  78. va_list args;
  79. btrfs_item_key_to_cpu(eb, &key, slot);
  80. va_start(args, fmt);
  81. vaf.fmt = fmt;
  82. vaf.va = &args;
  83. btrfs_crit(fs_info,
  84. "corrupt %s: root=%llu block=%llu slot=%d ino=%llu file_offset=%llu, %pV",
  85. btrfs_header_level(eb) == 0 ? "leaf" : "node",
  86. btrfs_header_owner(eb), btrfs_header_bytenr(eb), slot,
  87. key.objectid, key.offset, &vaf);
  88. va_end(args);
  89. }
  90. /*
  91. * Return 0 if the btrfs_file_extent_##name is aligned to @alignment
  92. * Else return 1
  93. */
  94. #define CHECK_FE_ALIGNED(fs_info, leaf, slot, fi, name, alignment) \
  95. ({ \
  96. if (!IS_ALIGNED(btrfs_file_extent_##name((leaf), (fi)), (alignment))) \
  97. file_extent_err((fs_info), (leaf), (slot), \
  98. "invalid %s for file extent, have %llu, should be aligned to %u", \
  99. (#name), btrfs_file_extent_##name((leaf), (fi)), \
  100. (alignment)); \
  101. (!IS_ALIGNED(btrfs_file_extent_##name((leaf), (fi)), (alignment))); \
  102. })
  103. static int check_extent_data_item(struct btrfs_fs_info *fs_info,
  104. struct extent_buffer *leaf,
  105. struct btrfs_key *key, int slot)
  106. {
  107. struct btrfs_file_extent_item *fi;
  108. u32 sectorsize = fs_info->sectorsize;
  109. u32 item_size = btrfs_item_size_nr(leaf, slot);
  110. if (!IS_ALIGNED(key->offset, sectorsize)) {
  111. file_extent_err(fs_info, leaf, slot,
  112. "unaligned file_offset for file extent, have %llu should be aligned to %u",
  113. key->offset, sectorsize);
  114. return -EUCLEAN;
  115. }
  116. fi = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item);
  117. if (btrfs_file_extent_type(leaf, fi) > BTRFS_FILE_EXTENT_TYPES) {
  118. file_extent_err(fs_info, leaf, slot,
  119. "invalid type for file extent, have %u expect range [0, %u]",
  120. btrfs_file_extent_type(leaf, fi),
  121. BTRFS_FILE_EXTENT_TYPES);
  122. return -EUCLEAN;
  123. }
  124. /*
  125. * Support for new compression/encrption must introduce incompat flag,
  126. * and must be caught in open_ctree().
  127. */
  128. if (btrfs_file_extent_compression(leaf, fi) > BTRFS_COMPRESS_TYPES) {
  129. file_extent_err(fs_info, leaf, slot,
  130. "invalid compression for file extent, have %u expect range [0, %u]",
  131. btrfs_file_extent_compression(leaf, fi),
  132. BTRFS_COMPRESS_TYPES);
  133. return -EUCLEAN;
  134. }
  135. if (btrfs_file_extent_encryption(leaf, fi)) {
  136. file_extent_err(fs_info, leaf, slot,
  137. "invalid encryption for file extent, have %u expect 0",
  138. btrfs_file_extent_encryption(leaf, fi));
  139. return -EUCLEAN;
  140. }
  141. if (btrfs_file_extent_type(leaf, fi) == BTRFS_FILE_EXTENT_INLINE) {
  142. /* Inline extent must have 0 as key offset */
  143. if (key->offset) {
  144. file_extent_err(fs_info, leaf, slot,
  145. "invalid file_offset for inline file extent, have %llu expect 0",
  146. key->offset);
  147. return -EUCLEAN;
  148. }
  149. /* Compressed inline extent has no on-disk size, skip it */
  150. if (btrfs_file_extent_compression(leaf, fi) !=
  151. BTRFS_COMPRESS_NONE)
  152. return 0;
  153. /* Uncompressed inline extent size must match item size */
  154. if (item_size != BTRFS_FILE_EXTENT_INLINE_DATA_START +
  155. btrfs_file_extent_ram_bytes(leaf, fi)) {
  156. file_extent_err(fs_info, leaf, slot,
  157. "invalid ram_bytes for uncompressed inline extent, have %u expect %llu",
  158. item_size, BTRFS_FILE_EXTENT_INLINE_DATA_START +
  159. btrfs_file_extent_ram_bytes(leaf, fi));
  160. return -EUCLEAN;
  161. }
  162. return 0;
  163. }
  164. /* Regular or preallocated extent has fixed item size */
  165. if (item_size != sizeof(*fi)) {
  166. file_extent_err(fs_info, leaf, slot,
  167. "invalid item size for reg/prealloc file extent, have %u expect %zu",
  168. item_size, sizeof(*fi));
  169. return -EUCLEAN;
  170. }
  171. if (CHECK_FE_ALIGNED(fs_info, leaf, slot, fi, ram_bytes, sectorsize) ||
  172. CHECK_FE_ALIGNED(fs_info, leaf, slot, fi, disk_bytenr, sectorsize) ||
  173. CHECK_FE_ALIGNED(fs_info, leaf, slot, fi, disk_num_bytes, sectorsize) ||
  174. CHECK_FE_ALIGNED(fs_info, leaf, slot, fi, offset, sectorsize) ||
  175. CHECK_FE_ALIGNED(fs_info, leaf, slot, fi, num_bytes, sectorsize))
  176. return -EUCLEAN;
  177. return 0;
  178. }
  179. static int check_csum_item(struct btrfs_fs_info *fs_info,
  180. struct extent_buffer *leaf, struct btrfs_key *key,
  181. int slot)
  182. {
  183. u32 sectorsize = fs_info->sectorsize;
  184. u32 csumsize = btrfs_super_csum_size(fs_info->super_copy);
  185. if (key->objectid != BTRFS_EXTENT_CSUM_OBJECTID) {
  186. generic_err(fs_info, leaf, slot,
  187. "invalid key objectid for csum item, have %llu expect %llu",
  188. key->objectid, BTRFS_EXTENT_CSUM_OBJECTID);
  189. return -EUCLEAN;
  190. }
  191. if (!IS_ALIGNED(key->offset, sectorsize)) {
  192. generic_err(fs_info, leaf, slot,
  193. "unaligned key offset for csum item, have %llu should be aligned to %u",
  194. key->offset, sectorsize);
  195. return -EUCLEAN;
  196. }
  197. if (!IS_ALIGNED(btrfs_item_size_nr(leaf, slot), csumsize)) {
  198. generic_err(fs_info, leaf, slot,
  199. "unaligned item size for csum item, have %u should be aligned to %u",
  200. btrfs_item_size_nr(leaf, slot), csumsize);
  201. return -EUCLEAN;
  202. }
  203. return 0;
  204. }
  205. /*
  206. * Customized reported for dir_item, only important new info is key->objectid,
  207. * which represents inode number
  208. */
  209. __printf(4, 5)
  210. static void dir_item_err(const struct btrfs_fs_info *fs_info,
  211. const struct extent_buffer *eb, int slot,
  212. const char *fmt, ...)
  213. {
  214. struct btrfs_key key;
  215. struct va_format vaf;
  216. va_list args;
  217. btrfs_item_key_to_cpu(eb, &key, slot);
  218. va_start(args, fmt);
  219. vaf.fmt = fmt;
  220. vaf.va = &args;
  221. btrfs_crit(fs_info,
  222. "corrupt %s: root=%llu block=%llu slot=%d ino=%llu, %pV",
  223. btrfs_header_level(eb) == 0 ? "leaf" : "node",
  224. btrfs_header_owner(eb), btrfs_header_bytenr(eb), slot,
  225. key.objectid, &vaf);
  226. va_end(args);
  227. }
  228. static int check_dir_item(struct btrfs_fs_info *fs_info,
  229. struct extent_buffer *leaf,
  230. struct btrfs_key *key, int slot)
  231. {
  232. struct btrfs_dir_item *di;
  233. u32 item_size = btrfs_item_size_nr(leaf, slot);
  234. u32 cur = 0;
  235. di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item);
  236. while (cur < item_size) {
  237. u32 name_len;
  238. u32 data_len;
  239. u32 max_name_len;
  240. u32 total_size;
  241. u32 name_hash;
  242. u8 dir_type;
  243. /* header itself should not cross item boundary */
  244. if (cur + sizeof(*di) > item_size) {
  245. dir_item_err(fs_info, leaf, slot,
  246. "dir item header crosses item boundary, have %zu boundary %u",
  247. cur + sizeof(*di), item_size);
  248. return -EUCLEAN;
  249. }
  250. /* dir type check */
  251. dir_type = btrfs_dir_type(leaf, di);
  252. if (dir_type >= BTRFS_FT_MAX) {
  253. dir_item_err(fs_info, leaf, slot,
  254. "invalid dir item type, have %u expect [0, %u)",
  255. dir_type, BTRFS_FT_MAX);
  256. return -EUCLEAN;
  257. }
  258. if (key->type == BTRFS_XATTR_ITEM_KEY &&
  259. dir_type != BTRFS_FT_XATTR) {
  260. dir_item_err(fs_info, leaf, slot,
  261. "invalid dir item type for XATTR key, have %u expect %u",
  262. dir_type, BTRFS_FT_XATTR);
  263. return -EUCLEAN;
  264. }
  265. if (dir_type == BTRFS_FT_XATTR &&
  266. key->type != BTRFS_XATTR_ITEM_KEY) {
  267. dir_item_err(fs_info, leaf, slot,
  268. "xattr dir type found for non-XATTR key");
  269. return -EUCLEAN;
  270. }
  271. if (dir_type == BTRFS_FT_XATTR)
  272. max_name_len = XATTR_NAME_MAX;
  273. else
  274. max_name_len = BTRFS_NAME_LEN;
  275. /* Name/data length check */
  276. name_len = btrfs_dir_name_len(leaf, di);
  277. data_len = btrfs_dir_data_len(leaf, di);
  278. if (name_len > max_name_len) {
  279. dir_item_err(fs_info, leaf, slot,
  280. "dir item name len too long, have %u max %u",
  281. name_len, max_name_len);
  282. return -EUCLEAN;
  283. }
  284. if (name_len + data_len > BTRFS_MAX_XATTR_SIZE(fs_info)) {
  285. dir_item_err(fs_info, leaf, slot,
  286. "dir item name and data len too long, have %u max %u",
  287. name_len + data_len,
  288. BTRFS_MAX_XATTR_SIZE(fs_info));
  289. return -EUCLEAN;
  290. }
  291. if (data_len && dir_type != BTRFS_FT_XATTR) {
  292. dir_item_err(fs_info, leaf, slot,
  293. "dir item with invalid data len, have %u expect 0",
  294. data_len);
  295. return -EUCLEAN;
  296. }
  297. total_size = sizeof(*di) + name_len + data_len;
  298. /* header and name/data should not cross item boundary */
  299. if (cur + total_size > item_size) {
  300. dir_item_err(fs_info, leaf, slot,
  301. "dir item data crosses item boundary, have %u boundary %u",
  302. cur + total_size, item_size);
  303. return -EUCLEAN;
  304. }
  305. /*
  306. * Special check for XATTR/DIR_ITEM, as key->offset is name
  307. * hash, should match its name
  308. */
  309. if (key->type == BTRFS_DIR_ITEM_KEY ||
  310. key->type == BTRFS_XATTR_ITEM_KEY) {
  311. char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)];
  312. read_extent_buffer(leaf, namebuf,
  313. (unsigned long)(di + 1), name_len);
  314. name_hash = btrfs_name_hash(namebuf, name_len);
  315. if (key->offset != name_hash) {
  316. dir_item_err(fs_info, leaf, slot,
  317. "name hash mismatch with key, have 0x%016x expect 0x%016llx",
  318. name_hash, key->offset);
  319. return -EUCLEAN;
  320. }
  321. }
  322. cur += total_size;
  323. di = (struct btrfs_dir_item *)((void *)di + total_size);
  324. }
  325. return 0;
  326. }
  327. /*
  328. * Common point to switch the item-specific validation.
  329. */
  330. static int check_leaf_item(struct btrfs_fs_info *fs_info,
  331. struct extent_buffer *leaf,
  332. struct btrfs_key *key, int slot)
  333. {
  334. int ret = 0;
  335. switch (key->type) {
  336. case BTRFS_EXTENT_DATA_KEY:
  337. ret = check_extent_data_item(fs_info, leaf, key, slot);
  338. break;
  339. case BTRFS_EXTENT_CSUM_KEY:
  340. ret = check_csum_item(fs_info, leaf, key, slot);
  341. break;
  342. case BTRFS_DIR_ITEM_KEY:
  343. case BTRFS_DIR_INDEX_KEY:
  344. case BTRFS_XATTR_ITEM_KEY:
  345. ret = check_dir_item(fs_info, leaf, key, slot);
  346. break;
  347. }
  348. return ret;
  349. }
  350. static int check_leaf(struct btrfs_fs_info *fs_info, struct extent_buffer *leaf,
  351. bool check_item_data)
  352. {
  353. /* No valid key type is 0, so all key should be larger than this key */
  354. struct btrfs_key prev_key = {0, 0, 0};
  355. struct btrfs_key key;
  356. u32 nritems = btrfs_header_nritems(leaf);
  357. int slot;
  358. /*
  359. * Extent buffers from a relocation tree have a owner field that
  360. * corresponds to the subvolume tree they are based on. So just from an
  361. * extent buffer alone we can not find out what is the id of the
  362. * corresponding subvolume tree, so we can not figure out if the extent
  363. * buffer corresponds to the root of the relocation tree or not. So
  364. * skip this check for relocation trees.
  365. */
  366. if (nritems == 0 && !btrfs_header_flag(leaf, BTRFS_HEADER_FLAG_RELOC)) {
  367. struct btrfs_root *check_root;
  368. key.objectid = btrfs_header_owner(leaf);
  369. key.type = BTRFS_ROOT_ITEM_KEY;
  370. key.offset = (u64)-1;
  371. check_root = btrfs_get_fs_root(fs_info, &key, false);
  372. /*
  373. * The only reason we also check NULL here is that during
  374. * open_ctree() some roots has not yet been set up.
  375. */
  376. if (!IS_ERR_OR_NULL(check_root)) {
  377. struct extent_buffer *eb;
  378. eb = btrfs_root_node(check_root);
  379. /* if leaf is the root, then it's fine */
  380. if (leaf != eb) {
  381. generic_err(fs_info, leaf, 0,
  382. "invalid nritems, have %u should not be 0 for non-root leaf",
  383. nritems);
  384. free_extent_buffer(eb);
  385. return -EUCLEAN;
  386. }
  387. free_extent_buffer(eb);
  388. }
  389. return 0;
  390. }
  391. if (nritems == 0)
  392. return 0;
  393. /*
  394. * Check the following things to make sure this is a good leaf, and
  395. * leaf users won't need to bother with similar sanity checks:
  396. *
  397. * 1) key ordering
  398. * 2) item offset and size
  399. * No overlap, no hole, all inside the leaf.
  400. * 3) item content
  401. * If possible, do comprehensive sanity check.
  402. * NOTE: All checks must only rely on the item data itself.
  403. */
  404. for (slot = 0; slot < nritems; slot++) {
  405. u32 item_end_expected;
  406. int ret;
  407. btrfs_item_key_to_cpu(leaf, &key, slot);
  408. /* Make sure the keys are in the right order */
  409. if (btrfs_comp_cpu_keys(&prev_key, &key) >= 0) {
  410. generic_err(fs_info, leaf, slot,
  411. "bad key order, prev (%llu %u %llu) current (%llu %u %llu)",
  412. prev_key.objectid, prev_key.type,
  413. prev_key.offset, key.objectid, key.type,
  414. key.offset);
  415. return -EUCLEAN;
  416. }
  417. /*
  418. * Make sure the offset and ends are right, remember that the
  419. * item data starts at the end of the leaf and grows towards the
  420. * front.
  421. */
  422. if (slot == 0)
  423. item_end_expected = BTRFS_LEAF_DATA_SIZE(fs_info);
  424. else
  425. item_end_expected = btrfs_item_offset_nr(leaf,
  426. slot - 1);
  427. if (btrfs_item_end_nr(leaf, slot) != item_end_expected) {
  428. generic_err(fs_info, leaf, slot,
  429. "unexpected item end, have %u expect %u",
  430. btrfs_item_end_nr(leaf, slot),
  431. item_end_expected);
  432. return -EUCLEAN;
  433. }
  434. /*
  435. * Check to make sure that we don't point outside of the leaf,
  436. * just in case all the items are consistent to each other, but
  437. * all point outside of the leaf.
  438. */
  439. if (btrfs_item_end_nr(leaf, slot) >
  440. BTRFS_LEAF_DATA_SIZE(fs_info)) {
  441. generic_err(fs_info, leaf, slot,
  442. "slot end outside of leaf, have %u expect range [0, %u]",
  443. btrfs_item_end_nr(leaf, slot),
  444. BTRFS_LEAF_DATA_SIZE(fs_info));
  445. return -EUCLEAN;
  446. }
  447. /* Also check if the item pointer overlaps with btrfs item. */
  448. if (btrfs_item_nr_offset(slot) + sizeof(struct btrfs_item) >
  449. btrfs_item_ptr_offset(leaf, slot)) {
  450. generic_err(fs_info, leaf, slot,
  451. "slot overlaps with its data, item end %lu data start %lu",
  452. btrfs_item_nr_offset(slot) +
  453. sizeof(struct btrfs_item),
  454. btrfs_item_ptr_offset(leaf, slot));
  455. return -EUCLEAN;
  456. }
  457. if (check_item_data) {
  458. /*
  459. * Check if the item size and content meet other
  460. * criteria
  461. */
  462. ret = check_leaf_item(fs_info, leaf, &key, slot);
  463. if (ret < 0)
  464. return ret;
  465. }
  466. prev_key.objectid = key.objectid;
  467. prev_key.type = key.type;
  468. prev_key.offset = key.offset;
  469. }
  470. return 0;
  471. }
  472. int btrfs_check_leaf_full(struct btrfs_fs_info *fs_info,
  473. struct extent_buffer *leaf)
  474. {
  475. return check_leaf(fs_info, leaf, true);
  476. }
  477. int btrfs_check_leaf_relaxed(struct btrfs_fs_info *fs_info,
  478. struct extent_buffer *leaf)
  479. {
  480. return check_leaf(fs_info, leaf, false);
  481. }
  482. int btrfs_check_node(struct btrfs_fs_info *fs_info, struct extent_buffer *node)
  483. {
  484. unsigned long nr = btrfs_header_nritems(node);
  485. struct btrfs_key key, next_key;
  486. int slot;
  487. u64 bytenr;
  488. int ret = 0;
  489. if (nr == 0 || nr > BTRFS_NODEPTRS_PER_BLOCK(fs_info)) {
  490. btrfs_crit(fs_info,
  491. "corrupt node: root=%llu block=%llu, nritems too %s, have %lu expect range [1,%u]",
  492. btrfs_header_owner(node), node->start,
  493. nr == 0 ? "small" : "large", nr,
  494. BTRFS_NODEPTRS_PER_BLOCK(fs_info));
  495. return -EUCLEAN;
  496. }
  497. for (slot = 0; slot < nr - 1; slot++) {
  498. bytenr = btrfs_node_blockptr(node, slot);
  499. btrfs_node_key_to_cpu(node, &key, slot);
  500. btrfs_node_key_to_cpu(node, &next_key, slot + 1);
  501. if (!bytenr) {
  502. generic_err(fs_info, node, slot,
  503. "invalid NULL node pointer");
  504. ret = -EUCLEAN;
  505. goto out;
  506. }
  507. if (!IS_ALIGNED(bytenr, fs_info->sectorsize)) {
  508. generic_err(fs_info, node, slot,
  509. "unaligned pointer, have %llu should be aligned to %u",
  510. bytenr, fs_info->sectorsize);
  511. ret = -EUCLEAN;
  512. goto out;
  513. }
  514. if (btrfs_comp_cpu_keys(&key, &next_key) >= 0) {
  515. generic_err(fs_info, node, slot,
  516. "bad key order, current (%llu %u %llu) next (%llu %u %llu)",
  517. key.objectid, key.type, key.offset,
  518. next_key.objectid, next_key.type,
  519. next_key.offset);
  520. ret = -EUCLEAN;
  521. goto out;
  522. }
  523. }
  524. out:
  525. return ret;
  526. }