]> git.baikalelectronics.ru Git - uboot.git/commit
mtdparts: Fix various issues reported by Coverity
authorTom Rini <trini@konsulko.com>
Tue, 15 Aug 2017 00:42:27 +0000 (20:42 -0400)
committerTom Rini <trini@konsulko.com>
Sun, 20 Aug 2017 13:54:29 +0000 (09:54 -0400)
commit21d4fb45fe1ebd8dd4f9d430d9ebb9ed95901d07
treea81780b3c33b5851af430e57ea4f5542851c3cbe
parent79616330d07e02a96c349ba9cf76d1a5ed18fc1f
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 <LW@KARO-electronics.de>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Reported-by: Coverity (CID: 166334, 166333, 166332, 166329, 166328)
Signed-off-by: Tom Rini <trini@konsulko.com>
cmd/mtdparts.c