public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
To: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: linux-acpi@vger.kernel.org, linux-wireless@vger.kernel.org,
	Ivo van Doorn <ivdoorn@gmail.com>
Subject: Re: [RFC] acer-wmi: Add rfkill support for wireless and bluetooth (v2)
Date: Sun, 31 Aug 2008 10:36:31 -0300	[thread overview]
Message-ID: <20080831133631.GA9794@khazad-dum.debian.net> (raw)
In-Reply-To: <200808301654.03329.carlos@strangeworlds.co.uk>

On Sat, 30 Aug 2008, Carlos Corbacho wrote:
> +static void device##_rfkill_update(struct work_struct *ignored) \
> +{ \
> +	u32 state; \
> +	acpi_status status; \
> +	status = get_u32(&state, cap); \
> +	\
> +	if (ACPI_SUCCESS(status)) \
> +		rfkill_force_state(device##_rfkill, state); \
> +	queue_delayed_work(rfkill_workqueue, &device##_rfkill_work, \
> +		round_jiffies_relative(HZ)); \
> +}

You are still doing state = (int);  rfkill_force_state(foo, state);

Please do a rfkill_force_state(foo, state ? RFKILL_STATE_UNBLOCKED :
					RFKILL_STATE_SOFT_BLOCKED);

or whatever is correct for what the values of (state) mean.

> +	err = rfkill_register(wireless_rfkill);
> +	if (err)
> +		return err;

You have to manually dealocate wireless_rfkill on the error path here using
rfkill_free (and maybe set it to NULL to avoid double-free or somesuch), or
you will leak memory.

I heavily suggest re-reading the kernel doc info for every rfkill function
you're using.  They're well described and documented, including caveats such
as the one above.

> +	if (!rfkill_workqueue)
> +		return -ENOMEM;

Needs to dealocate the stuff you alocated, unless the caller will do so.

> +	destroy_workqueue(rfkill_workqueue);
> +	rfkill_unregister(wireless_rfkill);
> +	rfkill_free(wireless_rfkill);

I know it is somewhat surprising, but you must never rfkill_free something
you have called rfkill_unregister on.  You use rfkill_free only to get rid
of memory when rfkill_register fails.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

  reply	other threads:[~2008-08-31 13:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30 11:06 [RFC] acer-wmi: Add rfkill support for wireless and bluetooth Carlos Corbacho
2008-08-30 14:07 ` Henrique de Moraes Holschuh
     [not found]   ` <20080830140730.GB12246-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2008-08-30 15:54     ` [RFC] acer-wmi: Add rfkill support for wireless and bluetooth (v2) Carlos Corbacho
2008-08-31 13:36       ` Henrique de Moraes Holschuh [this message]
2008-09-07 17:13         ` [RFC] acer-wmi: Add rfkill support for wireless and bluetooth (v3) Carlos Corbacho
2008-09-08  3:29           ` Henrique de Moraes Holschuh
2008-09-12 19:44             ` [RFC] acer-wmi: Add rfkill support for wireless and bluetooth (v4) Carlos Corbacho
2008-09-12 20:20               ` Henrique de Moraes Holschuh
     [not found]               ` <200809122044.27418.carlos-8YloKY0SPvpS8uBCpOlSjPXRex20P6io@public.gmane.org>
2008-09-12 20:43                 ` Dmitry Torokhov
     [not found]                   ` <20080912164039.ZZRA012-NG0XCrj25/nJrYCpivWRnl5pS2h4L8biXqFh9Ls21Oc@public.gmane.org>
2008-09-12 22:04                     ` [RFC] acer-wmi: Add rfkill support for wireless and bluetooth (v5) Carlos Corbacho
     [not found]                       ` <200809122304.21000.carlos-8YloKY0SPvpS8uBCpOlSjPXRex20P6io@public.gmane.org>
2008-09-14 12:18                         ` Dmitry Torokhov

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=20080831133631.GA9794@khazad-dum.debian.net \
    --to=hmh@hmh.eng.br \
    --cc=carlos@strangeworlds.co.uk \
    --cc=ivdoorn@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --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