* [PATCH] ath6kl: Fix a possible null-pointer dereference in ath6kl_htc_mbox_create()
@ 2019-07-29 3:03 Jia-Ju Bai
2019-09-04 6:21 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2019-07-29 3:03 UTC (permalink / raw)
To: kvalo, davem; +Cc: linux-wireless, netdev, linux-kernel, Jia-Ju Bai
In ath6kl_htc_mbox_create(), when kzalloc() on line 2855 fails,
target->dev is assigned to NULL, and ath6kl_htc_mbox_cleanup(target) is
called on line 2885.
In ath6kl_htc_mbox_cleanup(), target->dev is used on line 2895:
ath6kl_hif_cleanup_scatter(target->dev->ar);
Thus, a null-pointer dereference may occur.
To fix this bug, kfree(target) is called and NULL is returned when
kzalloc() on line 2855 fails.
This bug is found by a static analysis tool STCheck written by us.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/net/wireless/ath/ath6kl/htc_mbox.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath6kl/htc_mbox.c b/drivers/net/wireless/ath/ath6kl/htc_mbox.c
index 65c31da43c47..998947ef63b6 100644
--- a/drivers/net/wireless/ath/ath6kl/htc_mbox.c
+++ b/drivers/net/wireless/ath/ath6kl/htc_mbox.c
@@ -2855,8 +2855,8 @@ static void *ath6kl_htc_mbox_create(struct ath6kl *ar)
target->dev = kzalloc(sizeof(*target->dev), GFP_KERNEL);
if (!target->dev) {
ath6kl_err("unable to allocate memory\n");
- status = -ENOMEM;
- goto err_htc_cleanup;
+ kfree(target);
+ return NULL;
}
spin_lock_init(&target->htc_lock);
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ath6kl: Fix a possible null-pointer dereference in ath6kl_htc_mbox_create()
2019-07-29 3:03 [PATCH] ath6kl: Fix a possible null-pointer dereference in ath6kl_htc_mbox_create() Jia-Ju Bai
@ 2019-09-04 6:21 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2019-09-04 6:21 UTC (permalink / raw)
To: Jia-Ju Bai; +Cc: davem, linux-wireless, netdev, linux-kernel, Jia-Ju Bai
Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
> In ath6kl_htc_mbox_create(), when kzalloc() on line 2855 fails,
> target->dev is assigned to NULL, and ath6kl_htc_mbox_cleanup(target) is
> called on line 2885.
>
> In ath6kl_htc_mbox_cleanup(), target->dev is used on line 2895:
> ath6kl_hif_cleanup_scatter(target->dev->ar);
>
> Thus, a null-pointer dereference may occur.
>
> To fix this bug, kfree(target) is called and NULL is returned when
> kzalloc() on line 2855 fails.
>
> This bug is found by a static analysis tool STCheck written by us.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Patch applied to ath-next branch of ath.git, thanks.
0e7bf23e4967 ath6kl: Fix a possible null-pointer dereference in ath6kl_htc_mbox_create()
--
https://patchwork.kernel.org/patch/11063157/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-04 6:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 3:03 [PATCH] ath6kl: Fix a possible null-pointer dereference in ath6kl_htc_mbox_create() Jia-Ju Bai
2019-09-04 6:21 ` Kalle Valo
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).