Commit 54f1792
committed
mtdparts: Fix various issues reported by Coverity
Now that sandbox is building cmd/mtdparts.c Coverity has looked at the
code and found a number of issues. In index_partitions() it is possible
that part will be NULL, so re-work the checks and debug statements to
take this into account. We have a number of string buffers that we
print to in the exact size of, and use string functions on, so we need
to ensure they are large enough to be NULL terminated. In
device_parse() it is not possible for num_partitions to be 0 (we would
have hit a different error first) so remove logically dead code.
Finally, in parse_mtdparts() if we have an error we need to free the
memory allocated to dev.
Cc: Lothar Waßmann <[email protected]>
Cc: Maxime Ripard <[email protected]>
Reported-by: Coverity (CID: 166334, 166333, 166332, 166329, 166328)
Signed-off-by: Tom Rini <[email protected]>1 parent 78eda89 commit 54f1792
1 file changed
+18
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | | - | |
138 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
249 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
250 | 256 | | |
251 | | - | |
| 257 | + | |
| 258 | + | |
252 | 259 | | |
253 | 260 | | |
254 | 261 | | |
| |||
912 | 919 | | |
913 | 920 | | |
914 | 921 | | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | 922 | | |
922 | 923 | | |
923 | 924 | | |
| |||
1593 | 1594 | | |
1594 | 1595 | | |
1595 | 1596 | | |
1596 | | - | |
| 1597 | + | |
| 1598 | + | |
1597 | 1599 | | |
| 1600 | + | |
1598 | 1601 | | |
1599 | 1602 | | |
1600 | 1603 | | |
| |||
1730 | 1733 | | |
1731 | 1734 | | |
1732 | 1735 | | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
1736 | 1739 | | |
1737 | 1740 | | |
1738 | 1741 | | |
| |||
0 commit comments