summaryrefslogtreecommitdiffstats
path: root/c/src/lib
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2017-08-22 12:28:10 +0200
committerChris Johns <chrisj@rtems.org>2020-10-01 11:35:03 +1000
commita100457c7d59fa2111429efc6b7b1b70f9f6984f (patch)
treee7d3f31a3656f5db75f435a7553f843df8459dc3 /c/src/lib
parentlibmisc/shell: Updating joel script handling fixes from RTEMS 5 (diff)
downloadrtems-a100457c7d59fa2111429efc6b7b1b70f9f6984f.tar.bz2
leon,gr1553b: improve init check
Check in init3 not needed since same data is already checked in init2 stage. Adds an extra check that the APB register space is available before accessing it. Closes #2331
Diffstat (limited to 'c/src/lib')
-rw-r--r--c/src/lib/libbsp/sparc/shared/1553/gr1553b.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/1553/gr1553b.c b/c/src/lib/libbsp/sparc/shared/1553/gr1553b.c
index 2e778606ac..c05d53a4f9 100644
--- a/c/src/lib/libbsp/sparc/shared/1553/gr1553b.c
+++ b/c/src/lib/libbsp/sparc/shared/1553/gr1553b.c
@@ -191,6 +191,8 @@ static int gr1553_init2(struct drvmgr_dev *dev)
return DRVMGR_FAIL;
}
pnpinfo = &ambadev->info;
+ if ( pnpinfo->apb_slv == NULL )
+ return DRVMGR_EIO;
regs = (struct gr1553b_regs *)pnpinfo->apb_slv->start;
/* Stop IRQ */
@@ -227,9 +229,6 @@ static int gr1553_init3(struct drvmgr_dev *dev)
/* Get device information from AMBA PnP information */
ambadev = (struct amba_dev_info *)dev->businfo;
- if ( ambadev == NULL ) {
- return DRVMGR_FAIL;
- }
pnpinfo = &ambadev->info;
regs = (struct gr1553b_regs *)pnpinfo->apb_slv->start;
@@ -257,6 +256,12 @@ static int gr1553_init3(struct drvmgr_dev *dev)
gr1553_list_add(&gr1553_rt_root, feat);
}
+ if ( priv->features == 0 ) {
+ /* no features in HW should never happen.. an I/O error? */
+ free(priv);
+ return DRVMGR_EIO;
+ }
+
return DRVMGR_OK;
}