Commit 1152a05ee6593bf3036337cd18edd355589ea3a8
tools: Correct error handling in fit_image_process_hash()
We should not be returning -1 as an error code. This can mask a situation where we run out of space adding things to the FIT. By returning the correct error in this case (-ENOSPC) it can be handled by the higher-level code. This may fix the error reported by Tom Van Deun here: https://www.mail-archive.com/u-boot@lists.denx.de/msg217417.html although I am not sure as I cannot actually repeat it. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Van Deun <tom.vandeun@wapice.com> Reviewed-by: Teddy Reed <teddy.reed@gmail.com>
Showing 1 changed file with 8 additions and 6 deletions Side-by-side Diff
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | printf("Can't set hash '%s' property for '%s' node(%s)\n", |
39 | 39 | FIT_VALUE_PROP, fit_get_name(fit, noffset, NULL), |
40 | 40 | fdt_strerror(ret)); |
41 | - return -1; | |
41 | + return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO; | |
42 | 42 | } |
43 | 43 | |
44 | 44 | return 0; |
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | 48 | |
... | ... | @@ -64,25 +64,27 @@ |
64 | 64 | const char *node_name; |
65 | 65 | int value_len; |
66 | 66 | char *algo; |
67 | + int ret; | |
67 | 68 | |
68 | 69 | node_name = fit_get_name(fit, noffset, NULL); |
69 | 70 | |
70 | 71 | if (fit_image_hash_get_algo(fit, noffset, &algo)) { |
71 | 72 | printf("Can't get hash algo property for '%s' hash node in '%s' image node\n", |
72 | 73 | node_name, image_name); |
73 | - return -1; | |
74 | + return -ENOENT; | |
74 | 75 | } |
75 | 76 | |
76 | 77 | if (calculate_hash(data, size, algo, value, &value_len)) { |
77 | 78 | printf("Unsupported hash algorithm (%s) for '%s' hash node in '%s' image node\n", |
78 | 79 | algo, node_name, image_name); |
79 | - return -1; | |
80 | + return -EPROTONOSUPPORT; | |
80 | 81 | } |
81 | 82 | |
82 | - if (fit_set_hash_value(fit, noffset, value, value_len)) { | |
83 | + ret = fit_set_hash_value(fit, noffset, value, value_len); | |
84 | + if (ret) { | |
83 | 85 | printf("Can't set hash value for '%s' hash node in '%s' image node\n", |
84 | 86 | node_name, image_name); |
85 | - return -1; | |
87 | + return ret; | |
86 | 88 | } |
87 | 89 | |
88 | 90 | return 0; |
... | ... | @@ -322,7 +324,7 @@ |
322 | 324 | comment, require_keys); |
323 | 325 | } |
324 | 326 | if (ret) |
325 | - return -1; | |
327 | + return ret; | |
326 | 328 | } |
327 | 329 | |
328 | 330 | return 0; |
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7
-
mentioned in commit c236eb
-
mentioned in commit 2b9ec7