Skip to content

Commit 1e4a463

Browse files
authored
Merge pull request #4508 from Guozhanxin/add_error_check
add error checks of rt_mutex_create()
2 parents eec83be + d49cc64 commit 1e4a463

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

bsp/simulator/drivers/sd_sim.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ static rt_err_t rt_sdcard_control(rt_device_t dev, int cmd, void *args)
133133
return RT_EOK;
134134
}
135135

136-
137136
rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
138137
{
139138
int size;
@@ -144,6 +143,11 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
144143
device = &(sd->parent);
145144

146145
lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO);
146+
if (lock == RT_NULL)
147+
{
148+
LOG_E("Create mutex in rt_hw_sdcard_init failed!");
149+
return -RT_ERROR;
150+
}
147151

148152
/* open sd card file, if not exist, then create it */
149153
sd->file = fopen(SDCARD_SIM, "rb+");

bsp/simulator/drivers/sdl_fb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ static void sdlfb_hw_init(void)
221221
rt_device_register(RT_DEVICE(&_device), "sdl", RT_DEVICE_FLAG_RDWR);
222222

223223
sdllock = rt_mutex_create("fb", RT_IPC_FLAG_FIFO);
224+
if (sdllock == RT_NULL)
225+
{
226+
LOG_E("Create mutex for sdlfb failed!");
227+
}
224228
}
225229

226230
#ifdef _WIN32

bsp/stm32f20x/Drivers/i2c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ void I2C1_INIT()
572572

573573
rt_event_init(&i2c_event, "i2c_event", RT_IPC_FLAG_FIFO );
574574
i2c_mux = rt_mutex_create("i2c_mux", RT_IPC_FLAG_FIFO );
575+
if (i2c_mux == RT_NULL)
576+
{
577+
LOG_E("Create mutex for i2c_mux failed!");
578+
return;
579+
}
575580
i2c1_init_flag = 1;
576581
}
577582
}

0 commit comments

Comments
 (0)