Fixed a hidden stack overflow bug

'memset' should been next step after 'NULL' judge
This commit is contained in:
David Lin 2020-03-08 00:48:32 +08:00 committed by GitHub
parent 9d9432eb93
commit c689c2c67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -186,12 +186,13 @@ int fh_pwm_probe(void *priv_data)
PWM_Enable(pwm_obj, RT_FALSE);
pwm_dev = rt_malloc(sizeof(struct rt_device));
rt_memset(pwm_dev, 0, sizeof(struct rt_device));
if (pwm_dev == RT_NULL)
{
rt_kprintf("ERROR: %s rt_device malloc failed\n", __func__);
}
rt_memset(pwm_dev, 0, sizeof(struct rt_device));
pwm_dev->user_data = &pwm_drv;
pwm_dev->open =fh_pwm_open;