staging: r8188eu: add check for kzalloc
[ Upstream commit f94b47c6bde624d6c07f43054087607c52054a95 ]
As kzalloc() may return null pointer, it should be better to
check the return value and return error if fails in order
to avoid dereference of null pointer.
Moreover, the return value of rtw_alloc_hwxmits() should also
be dealt with.
Fixes: 15865124fe ("staging: r8188eu: introduce new core dir for RTL8188eu driver")
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220518075957.514603-1-jiasheng@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e192888721
commit
029983ea88
@@ -179,7 +179,12 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
|
||||
|
||||
pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;
|
||||
|
||||
rtw_alloc_hwxmits(padapter);
|
||||
res = rtw_alloc_hwxmits(padapter);
|
||||
if (res) {
|
||||
res = _FAIL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
@@ -1516,7 +1521,7 @@ exit:
|
||||
return res;
|
||||
}
|
||||
|
||||
void rtw_alloc_hwxmits(struct adapter *padapter)
|
||||
int rtw_alloc_hwxmits(struct adapter *padapter)
|
||||
{
|
||||
struct hw_xmit *hwxmits;
|
||||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
@@ -1524,6 +1529,8 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
|
||||
pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;
|
||||
|
||||
pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL);
|
||||
if (!pxmitpriv->hwxmits)
|
||||
return -ENOMEM;
|
||||
|
||||
hwxmits = pxmitpriv->hwxmits;
|
||||
|
||||
@@ -1540,6 +1547,8 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
|
||||
hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
|
||||
} else {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtw_free_hwxmits(struct adapter *padapter)
|
||||
|
||||
@@ -345,7 +345,7 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter,
|
||||
void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry);
|
||||
s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
|
||||
void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv);
|
||||
void rtw_alloc_hwxmits(struct adapter *padapter);
|
||||
int rtw_alloc_hwxmits(struct adapter *padapter);
|
||||
void rtw_free_hwxmits(struct adapter *padapter);
|
||||
s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user