diff options
| author | Bernard Xiong <[email protected]> | 2021-04-03 23:24:34 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-04-03 23:24:34 +0800 |
| commit | 1e4a463f363dcde37f14d0ae2772360f4ff87a5e (patch) | |
| tree | 026f2e63fc76cf208676d3c28c21e2a65fe46de6 /bsp | |
| parent | eec83be864a4659026c369d85cf77454547301be (diff) | |
| parent | d49cc6452406d70ce7a2e2acce786fbe697673b9 (diff) | |
Merge pull request #4508 from Guozhanxin/add_error_check
add error checks of rt_mutex_create()
Diffstat (limited to 'bsp')
| -rwxr-xr-x | bsp/simulator/drivers/sd_sim.c | 6 | ||||
| -rwxr-xr-x | bsp/simulator/drivers/sdl_fb.c | 4 | ||||
| -rw-r--r-- | bsp/stm32f20x/Drivers/i2c.c | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c index 41c495403a..adc489be20 100755 --- a/bsp/simulator/drivers/sd_sim.c +++ b/bsp/simulator/drivers/sd_sim.c @@ -133,7 +133,6 @@ static rt_err_t rt_sdcard_control(rt_device_t dev, int cmd, void *args) return RT_EOK; } - rt_err_t rt_hw_sdcard_init(const char *spi_device_name) { int size; @@ -144,6 +143,11 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name) device = &(sd->parent); lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO); + if (lock == RT_NULL) + { + LOG_E("Create mutex in rt_hw_sdcard_init failed!"); + return -RT_ERROR; + } /* open sd card file, if not exist, then create it */ sd->file = fopen(SDCARD_SIM, "rb+"); diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c index 986c3139de..7b25da9c3c 100755 --- a/bsp/simulator/drivers/sdl_fb.c +++ b/bsp/simulator/drivers/sdl_fb.c @@ -221,6 +221,10 @@ static void sdlfb_hw_init(void) rt_device_register(RT_DEVICE(&_device), "sdl", RT_DEVICE_FLAG_RDWR); sdllock = rt_mutex_create("fb", RT_IPC_FLAG_FIFO); + if (sdllock == RT_NULL) + { + LOG_E("Create mutex for sdlfb failed!"); + } } #ifdef _WIN32 diff --git a/bsp/stm32f20x/Drivers/i2c.c b/bsp/stm32f20x/Drivers/i2c.c index 9b2f4ed866..5fb5854d2e 100644 --- a/bsp/stm32f20x/Drivers/i2c.c +++ b/bsp/stm32f20x/Drivers/i2c.c @@ -572,6 +572,11 @@ void I2C1_INIT() rt_event_init(&i2c_event, "i2c_event", RT_IPC_FLAG_FIFO ); i2c_mux = rt_mutex_create("i2c_mux", RT_IPC_FLAG_FIFO ); + if (i2c_mux == RT_NULL) + { + LOG_E("Create mutex for i2c_mux failed!"); + return; + } i2c1_init_flag = 1; } } |
