staging: rtlwifi: Fix potential NULL pointer dereference of kzalloc

phydm.internal is allocated using kzalloc which is used multiple
times without a check for NULL pointer. This patch avoids such a
scenario by returning 0, consistent with the failure case.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Aditya Pakki 2019-03-20 10:42:32 -05:00 committed by Greg Kroah-Hartman
parent 22c971db7d
commit 6a8ca24590
1 changed files with 2 additions and 0 deletions

View File

@ -180,6 +180,8 @@ static int rtl_phydm_init_priv(struct rtl_priv *rtlpriv,
rtlpriv->phydm.internal =
kzalloc(sizeof(struct phy_dm_struct), GFP_KERNEL);
if (!rtlpriv->phydm.internal)
return 0;
_rtl_phydm_init_com_info(rtlpriv, ic, params);