summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Ji <ji.luo@nxp.com>2018-06-28 18:51:20 +0800
committerLuo Ji <ji.luo@nxp.com>2018-07-06 13:46:11 +0800
commit6ad4db3c3832b3560d621e32851c35e45b15a05f (patch)
treebdec88722aee902f0602dbca4590939b9a4a2c0a
parentdc53b0d89b044e387779d4751dd4c7d3bfe0d0a9 (diff)
[iot] [coverity] Fix null dereferenced issues
Fix the null dereferenced issues from converity scan results. issue id: 3618300:Dereference after null check 3618364:Dereference after null check 3618463:Dereference after null check 3618470:Explicit null dereferenced 3618520:Dereference after null check Test: issue fixed by converity scan. Change-Id: I577ed094a1f9b493de61b84827c0e1157a4fbd2f Signed-off-by: Luo Ji <ji.luo@nxp.com>
-rwxr-xr-xlib/avb/fsl/fsl_bootctl.c7
-rw-r--r--lib/avb/fsl/utils.c4
-rw-r--r--net/net.c7
3 files changed, 13 insertions, 5 deletions
diff --git a/lib/avb/fsl/fsl_bootctl.c b/lib/avb/fsl/fsl_bootctl.c
index 737be06250..9a57557e76 100755
--- a/lib/avb/fsl/fsl_bootctl.c
+++ b/lib/avb/fsl/fsl_bootctl.c
@@ -95,7 +95,8 @@ int get_slotvar_avb(AvbABOps *ab_ops, char *cmd, char *buffer, size_t size) {
AvbABSlotData *slot_data;
int slot;
- assert(ab_ops != NULL && cmd != NULL && buffer != NULL);
+ if ((ab_ops == NULL) || (cmd == NULL) || (buffer == NULL))
+ return -1;
char *str = cmd;
if (!strcmp_l1("has-slot:", cmd)) {
@@ -182,7 +183,9 @@ char *select_slot(AvbABOps *ab_ops) {
AvbABData ab_data;
int curr;
- assert(ab_ops != NULL);
+ if (ab_ops == NULL) {
+ return NULL;
+ }
/* load ab meta */
if (ab_ops->read_ab_metadata == NULL ||
diff --git a/lib/avb/fsl/utils.c b/lib/avb/fsl/utils.c
index 458ccea1a1..6416fa971e 100644
--- a/lib/avb/fsl/utils.c
+++ b/lib/avb/fsl/utils.c
@@ -14,7 +14,9 @@
int get_margin_pos(uint64_t part_start, uint64_t part_end, unsigned long blksz,
margin_pos_t *margin, int64_t offset, size_t num_bytes, bool allow_partial) {
long off;
- assert(margin != NULL);
+ if (margin == NULL)
+ return -1;
+
if (blksz == 0 || part_start > part_end)
return -1;
diff --git a/net/net.c b/net/net.c
index 6e678770fa..1123850402 100644
--- a/net/net.c
+++ b/net/net.c
@@ -215,8 +215,11 @@ static int on_bootfile(const char *name, const char *value, enum env_op op,
switch (op) {
case env_op_create:
case env_op_overwrite:
- copy_filename(net_boot_file_name, value,
- sizeof(net_boot_file_name));
+ if (value == NULL)
+ return -1;
+ else
+ copy_filename(net_boot_file_name, value,
+ sizeof(net_boot_file_name));
break;
default:
break;