Skip to content

Commit 955c153

Browse files
Connor Kuehlgregkh
authored andcommitted
staging: rtl8188eu: fix null dereference when kzalloc fails
If kzalloc() returns NULL, the error path doesn't stop the flow of control from entering rtw_hal_read_chip_version() which dereferences the null pointer. Fix this by adding a 'goto' to the error path to more gracefully handle the issue and avoid proceeding with initialization steps that we're no longer prepared to handle. Also update the debug message to be more consistent with the other debug messages in this function. Addresses-Coverity: ("Dereference after null check") Signed-off-by: Connor Kuehl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2eed19b commit 955c153

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/staging/rtl8188eu/os_dep/usb_intf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,10 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
348348
}
349349

350350
padapter->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL);
351-
if (!padapter->HalData)
352-
DBG_88E("cant not alloc memory for HAL DATA\n");
351+
if (!padapter->HalData) {
352+
DBG_88E("Failed to allocate memory for HAL data\n");
353+
goto free_adapter;
354+
}
353355

354356
/* step read_chip_version */
355357
rtw_hal_read_chip_version(padapter);

0 commit comments

Comments
 (0)