net: rtl88xx: fix to check null adapter 05/251305/1
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 12 Jan 2021 09:19:36 +0000 (18:19 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 12 Jan 2021 09:23:51 +0000 (18:23 +0900)
UBSAN warns about null pointer accessin rtl88xx. Fix to check
null pointer for adapter to remove below warning:

   UBSAN: Undefined behaviour in drivers/net/wireless/rtl8812au/os_dep/osdep_service.c:1187:2
   member access within null pointer of type 'struct _adapter'
   [...]
   [<ffffff9009b8d8b0>] __ubsan_handle_type_mismatch+0x28/0x30
   [<ffffff900330d2e4>] rtw_init_timer+0xbc/0xf0 [88XXau]
   [<ffffff90033150c8>] devobj_init+0x90/0x100 [88XXau]
   [<ffffff900331932c>] rtw_usb_primary_adapter_init+0x64c/0x1558 [88XXau]
   [<ffffff9009f77a1c>] usb_probe_interface+0x16c/0x4c8
   [...]

Change-Id: I258df3b790d7b1be49a89706dca46a895c4461b8
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
drivers/net/wireless/rtl8812au/os_dep/osdep_service.c

index 7c6d120..36d793d 100644 (file)
@@ -1183,6 +1183,9 @@ void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc, void *ctx)
 {
        _adapter *adapter = (_adapter *)padapter;
 
+       if (!adapter)
+               return;
+
 #ifdef PLATFORM_LINUX
        _init_timer(ptimer, adapter->pnetdev, pfunc, ctx);
 #endif