linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [RFC/RFT v2] rfkill: rewrite
Date: Tue, 31 Mar 2009 13:20:20 -0500	[thread overview]
Message-ID: <49D25EE4.6020202@lwfinger.net> (raw)
In-Reply-To: <1238451390.5970.59.camel@johannes.local>

Johannes Berg wrote:
> This patch completely rewrites the rfkill core to address
> the following deficiencies:

-- snip --

> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ wireless-testing/net/rfkill/core.c	2009-03-31 00:04:25.000000000 +0200
> @@ -0,0 +1,752 @@
> +/*

-- snip --

> +int __must_check rfkill_register(struct rfkill *rfkill)
> +{
> +	static unsigned long rfkill_no = 0;
> +	struct device *dev = &rfkill->dev;
> +	int error;
> +
> +	BUG_ON(!rfkill);
> +
> +	mutex_lock(&rfkill_global_mutex);
> +
> +	if (rfkill->registered) {
> +		error = -EALREADY;
> +		goto unlock;
> +	}
> +
> +	dev_set_name(dev, "rfkill%lu", rfkill_no);
> +	rfkill_no++;
> +
> +	if (!(rfkill_states_default_locked & BIT(rfkill->type))) {
> +		/* first of its kind */
> +		BUILD_BUG_ON(NUM_RFKILL_TYPES >
> +			sizeof(rfkill_states_default_locked) * 8);
> +		rfkill_states_default_locked |= BIT(rfkill->type);
> +		rfkill_global_states[rfkill->type].cur =
> +			rfkill_global_states[rfkill->type].def;
> +	}
> +
> +	/* XXX: schedule work to set default state */
> +
> +	list_add_tail(&rfkill->node, &rfkill_list);
> +
> +	error = device_add(dev);
> +	if (error)
> +		goto remove;
> +
> +	error = rfkill_led_trigger_register(rfkill);
> +	if (error)
> +		goto devdel;
> +
> +	rfkill->registered = true;
> +
> +	if (rfkill->ops->poll_hw_block) {
> +		INIT_DELAYED_WORK(&rfkill->poll_work, rfkill_poll);
> +		schedule_delayed_work(&rfkill->poll_work,
> +			round_jiffies_relative(POLL_INTERVAL));
> +	}
> +
> +	INIT_WORK(&rfkill->uevent_work, rfkill_uevent_work);
> +
> +	return 0;

The locking looks funny here. The normal return leaves the rfkill_global_mutex
locked. Did you mean "goto unlock" instead of "return 0"?

> +
> + devdel:
> +	device_del(&rfkill->dev);
> + remove:
> +	list_del_init(&rfkill->node);
> + unlock:
> + 	mutex_unlock(&rfkill_global_mutex);
> +	return error;
> +}

I was alerted to this problem when I was unable to shut down or reboot normally.
Those problems are fixed with the patch

Index: wireless-testing/net/rfkill/core.c
===================================================================
--- wireless-testing.orig/net/rfkill/core.c
+++ wireless-testing/net/rfkill/core.c
@@ -676,7 +676,7 @@ int __must_check rfkill_register(struct

 	INIT_WORK(&rfkill->uevent_work, rfkill_uevent_work);

-	return 0;
+	goto unlock;

  devdel:
        device_del(&rfkill->dev);


Larry

  parent reply	other threads:[~2009-03-31 18:21 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-29 17:53 [RFC] rfkill: rewrite Johannes Berg
2009-03-29 18:16 ` Ivo van Doorn
2009-03-30 13:27   ` Henrique de Moraes Holschuh
2009-03-30  9:06 ` Johannes Berg
2009-03-30  9:54   ` Michael Buesch
2009-03-30  9:57     ` Johannes Berg
2009-03-30 10:39       ` Johannes Berg
2009-03-30  9:40 ` Johannes Berg
2009-03-30 10:04   ` Matthew Garrett
2009-03-30 13:29   ` Henrique de Moraes Holschuh
2009-03-30 14:08     ` Johannes Berg
2009-03-30 17:34       ` Henrique de Moraes Holschuh
2009-03-30 17:41         ` Johannes Berg
2009-03-30 20:48           ` Henrique de Moraes Holschuh
2009-03-30 20:52             ` Johannes Berg
2009-03-30 21:02               ` Henrique de Moraes Holschuh
2009-03-30 21:20                 ` Johannes Berg
2009-03-30 17:39   ` Inaky Perez-Gonzalez
2009-03-30 17:45     ` Johannes Berg
2009-03-30 17:54       ` Ivo van Doorn
2009-03-30 18:00         ` Johannes Berg
2009-03-30 20:36           ` Inaky Perez-Gonzalez
2009-03-30 20:43             ` Johannes Berg
2009-03-30 20:52       ` Henrique de Moraes Holschuh
2009-03-30 19:01   ` Johannes Berg
2009-03-30 22:07   ` Johannes Berg
2009-03-30 22:08   ` Johannes Berg
2009-03-30 21:15 ` Henrique de Moraes Holschuh
2009-03-30 21:26   ` Johannes Berg
2009-03-30 21:26   ` Johannes Berg
2009-04-05 14:59   ` Henrique de Moraes Holschuh
2009-04-07 10:36     ` Johannes Berg
2009-04-08 18:06       ` Henrique de Moraes Holschuh
2009-04-14 21:03         ` Johannes Berg
2009-03-30 22:16 ` [RFC/RFT v2] " Johannes Berg
2009-03-30 23:20   ` Larry Finger
2009-03-31  8:02     ` Johannes Berg
2009-03-31  8:11       ` Johannes Berg
2009-03-31 12:16   ` Johannes Berg
2009-03-31 18:20   ` Larry Finger [this message]
2009-03-31 18:32     ` Johannes Berg
2009-03-31 19:11 ` [RFC v3] " Johannes Berg
2009-04-14 21:48 ` [RFC v5] " Johannes Berg
2009-04-14 23:08   ` [RFC v6] " Johannes Berg
2009-04-15  4:34     ` Larry Finger
2009-04-30  3:19     ` Henrique de Moraes Holschuh
2009-04-30  8:53       ` Johannes Berg
2009-04-30 14:11         ` Henrique de Moraes Holschuh
2009-04-30 14:18           ` Johannes Berg
2009-04-30 15:06       ` Johannes Berg
2009-04-30 15:53         ` Henrique de Moraes Holschuh
2009-04-30 16:09           ` Johannes Berg
2009-04-30 15:14       ` [RFC v8] " Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49D25EE4.6020202@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).