[HUST CSE][vbus] fix the NULL pointer error

This commit is contained in:
LostCivilization 2023-05-01 12:45:55 +08:00 committed by GitHub
parent 9a432c7413
commit ca023c1b41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -231,13 +231,14 @@ void rt_vbus_chnx_register_disconn(rt_device_t dev,
rt_vbus_event_listener indi,
void *ctx)
{
struct rt_vbus_dev *vdev = dev->user_data;
if (dev && dev->user_data)
{
struct rt_vbus_dev *vdev = dev->user_data;
RT_ASSERT(vdev->chnr != 0);
RT_ASSERT(vdev->chnr != 0);
if (vdev)
rt_vbus_register_listener(vdev->chnr, RT_VBUS_EVENT_ID_DISCONN,
indi, ctx);
}
}
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))