linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211_hwsim: add error check to call to rhashtable_init
@ 2018-05-29  9:14 Colin King
  2018-05-29  9:17 ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Colin King @ 2018-05-29  9:14 UTC (permalink / raw)
  To: Johannes Berg, Kalle Valo, David S . Miller, linux-wireless, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The call to rhashtable_init is missing an error return check, it is
possible for this to fail various different ways, so fix this by adding
an error check.

Detected by: CoverityScan, CID#1469446 ("Unchecked return value")

Fixes: c6509cc3b3e8 ("mac80211_hwsim: add hashtable with mac address keys for faster lookup")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/wireless/mac80211_hwsim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 89fc22520d40..f4b4f5690b16 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3573,7 +3573,9 @@ static int __init init_mac80211_hwsim(void)
 	hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0);
 	if (!hwsim_wq)
 		return -ENOMEM;
-	rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
+	err = rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
+	if (err)
+		return err;
 
 	err = register_pernet_device(&hwsim_net_ops);
 	if (err)
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mac80211_hwsim: add error check to call to rhashtable_init
  2018-05-29  9:14 [PATCH] mac80211_hwsim: add error check to call to rhashtable_init Colin King
@ 2018-05-29  9:17 ` Johannes Berg
  2018-05-29  9:23   ` Colin Ian King
  2018-05-29 10:00   ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Johannes Berg @ 2018-05-29  9:17 UTC (permalink / raw)
  To: Colin King, Kalle Valo, David S . Miller, linux-wireless, netdev
  Cc: kernel-janitors, linux-kernel

On Tue, 2018-05-29 at 10:14 +0100, Colin King wrote:
> 
> @@ -3573,7 +3573,9 @@ static int __init init_mac80211_hwsim(void)
>  	hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0);
>  	if (!hwsim_wq)
>  		return -ENOMEM;
> -	rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
> +	err = rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
> +	if (err)
> +		return err;

That's missing a workqueue free, but I can fix that while applying if
you prefer.

johannes

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mac80211_hwsim: add error check to call to rhashtable_init
  2018-05-29  9:17 ` Johannes Berg
@ 2018-05-29  9:23   ` Colin Ian King
  2018-05-29 10:00   ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Colin Ian King @ 2018-05-29  9:23 UTC (permalink / raw)
  To: Johannes Berg, Kalle Valo, David S . Miller, linux-wireless, netdev
  Cc: kernel-janitors, linux-kernel

On 29/05/18 10:17, Johannes Berg wrote:
> On Tue, 2018-05-29 at 10:14 +0100, Colin King wrote:
>>
>> @@ -3573,7 +3573,9 @@ static int __init init_mac80211_hwsim(void)
>>  	hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0);
>>  	if (!hwsim_wq)
>>  		return -ENOMEM;
>> -	rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
>> +	err = rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
>> +	if (err)
>> +		return err;
> 
> That's missing a workqueue free, but I can fix that while applying if
> you prefer.

Please do. Thanks
> 
> johannes
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mac80211_hwsim: add error check to call to rhashtable_init
  2018-05-29  9:17 ` Johannes Berg
  2018-05-29  9:23   ` Colin Ian King
@ 2018-05-29 10:00   ` Dan Carpenter
  2018-05-29 10:01     ` Johannes Berg
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2018-05-29 10:00 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Colin King, Kalle Valo, David S . Miller, linux-wireless, netdev,
	kernel-janitors, linux-kernel

On Tue, May 29, 2018 at 11:17:08AM +0200, Johannes Berg wrote:
> On Tue, 2018-05-29 at 10:14 +0100, Colin King wrote:
> > 
> > @@ -3573,7 +3573,9 @@ static int __init init_mac80211_hwsim(void)
> >  	hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0);
> >  	if (!hwsim_wq)
> >  		return -ENOMEM;
> > -	rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
> > +	err = rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
> > +	if (err)
> > +		return err;
> 
> That's missing a workqueue free, but I can fix that while applying if
> you prefer.
> 

And we don't free the hashtable on error either.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mac80211_hwsim: add error check to call to rhashtable_init
  2018-05-29 10:00   ` Dan Carpenter
@ 2018-05-29 10:01     ` Johannes Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2018-05-29 10:01 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Colin King, Kalle Valo, David S . Miller, linux-wireless, netdev,
	kernel-janitors, linux-kernel

On Tue, 2018-05-29 at 13:00 +0300, Dan Carpenter wrote:
> On Tue, May 29, 2018 at 11:17:08AM +0200, Johannes Berg wrote:
> > On Tue, 2018-05-29 at 10:14 +0100, Colin King wrote:
> > > 
> > > @@ -3573,7 +3573,9 @@ static int __init init_mac80211_hwsim(void)
> > >  	hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0);
> > >  	if (!hwsim_wq)
> > >  		return -ENOMEM;
> > > -	rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
> > > +	err = rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
> > > +	if (err)
> > > +		return err;
> > 
> > That's missing a workqueue free, but I can fix that while applying if
> > you prefer.
> > 
> 
> And we don't free the hashtable on error either.

Heh. Ok, I guess I'll make a whole new commit to fix up all the things
here.

johannes

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-29 10:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29  9:14 [PATCH] mac80211_hwsim: add error check to call to rhashtable_init Colin King
2018-05-29  9:17 ` Johannes Berg
2018-05-29  9:23   ` Colin Ian King
2018-05-29 10:00   ` Dan Carpenter
2018-05-29 10:01     ` Johannes Berg

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).