diff options
| author | LostCivilization <[email protected]> | 2023-05-01 12:45:55 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-01 00:45:55 -0400 |
| commit | ca023c1b41e1f413b799e045524f02f572cc182a (patch) | |
| tree | 266ad3f5aed0fa912846317b0dc693a2cc241656 | |
| parent | 9a432c7413501a1158df9b7e2ce5a664cdff066a (diff) | |
[HUST CSE][vbus] fix the NULL pointer error
| -rw-r--r-- | components/vbus/vbus_chnx.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/components/vbus/vbus_chnx.c b/components/vbus/vbus_chnx.c index d9bb3e4d46..12b6af340e 100644 --- a/components/vbus/vbus_chnx.c +++ b/components/vbus/vbus_chnx.c @@ -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; - - RT_ASSERT(vdev->chnr != 0); + if (dev && dev->user_data) + { + struct rt_vbus_dev *vdev = dev->user_data; + 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])) |
