* [PATCH v2] staging: rtl8188eu: fix possible null dereference
@ 2019-09-26 15:03 Connor Kuehl
2019-09-26 17:04 ` Larry Finger
0 siblings, 1 reply; 2+ messages in thread
From: Connor Kuehl @ 2019-09-26 15:03 UTC (permalink / raw)
To: Larry.Finger, gregkh, straube.linux, devel; +Cc: linux-kernel, kernel-janitors
Inside a nested 'else' block at the beginning of this function is a
call that assigns 'psta' to the return value of 'rtw_get_stainfo()'.
If 'rtw_get_stainfo()' returns NULL and the flow of control reaches
the 'else if' where 'psta' is dereferenced, then we will dereference
a NULL pointer.
Fix this by checking if 'psta' is not NULL before reading its
'psta->qos_option' data member.
Addresses-Coverity: ("Dereference null return value")
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
---
v1 -> v2:
- Add the same null check to line 779
drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 952f2ab51347..c37591657bac 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -776,7 +776,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN);
memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
- if (psta->qos_option)
+ if (psta && psta->qos_option)
qos_option = true;
} else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
@@ -784,7 +784,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN);
- if (psta->qos_option)
+ if (psta && psta->qos_option)
qos_option = true;
} else {
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv)));
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] staging: rtl8188eu: fix possible null dereference
2019-09-26 15:03 [PATCH v2] staging: rtl8188eu: fix possible null dereference Connor Kuehl
@ 2019-09-26 17:04 ` Larry Finger
0 siblings, 0 replies; 2+ messages in thread
From: Larry Finger @ 2019-09-26 17:04 UTC (permalink / raw)
To: Connor Kuehl, gregkh, straube.linux, devel; +Cc: linux-kernel, kernel-janitors
On 9/26/19 10:03 AM, Connor Kuehl wrote:
> Inside a nested 'else' block at the beginning of this function is a
> call that assigns 'psta' to the return value of 'rtw_get_stainfo()'.
> If 'rtw_get_stainfo()' returns NULL and the flow of control reaches
> the 'else if' where 'psta' is dereferenced, then we will dereference
> a NULL pointer.
>
> Fix this by checking if 'psta' is not NULL before reading its
> 'psta->qos_option' data member.
>
> Addresses-Coverity: ("Dereference null return value")
>
> Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
> ---
> v1 -> v2:
> - Add the same null check to line 779
>
> drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index 952f2ab51347..c37591657bac 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -776,7 +776,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
> memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN);
> memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
>
> - if (psta->qos_option)
> + if (psta && psta->qos_option)
> qos_option = true;
> } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
> check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
> @@ -784,7 +784,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
> memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
> memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN);
>
> - if (psta->qos_option)
> + if (psta && psta->qos_option)
> qos_option = true;
> } else {
> RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv)));
>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Thanks,
Larry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-26 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-26 15:03 [PATCH v2] staging: rtl8188eu: fix possible null dereference Connor Kuehl
2019-09-26 17:04 ` Larry Finger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).