linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ivo van Doorn <ivdoorn@gmail.com>
To: Michael Buesch <mb@bu3sch.de>
Cc: John Linville <linville@tuxdriver.com>, linux-wireless@vger.kernel.org
Subject: Re: [PATCH] rfkill: Use mutex_lock() at register and add sanity check
Date: Sun, 28 Oct 2007 16:03:48 +0100	[thread overview]
Message-ID: <200710281603.48603.IvDoorn@gmail.com> (raw)
In-Reply-To: <200710281516.51356.mb@bu3sch.de>

On Sunday 28 October 2007, Michael Buesch wrote:
> Replace mutex_lock_interruptible() by mutex_lock() in rfkill_register(),
> as interruptible doesn't make sense there.
> 
> Add a sanity check for rfkill->type, as that's used for an unchecked dereference
> in an array and might cause hard to debug crashes if the driver sets this
> to an invalid value.
> 
> Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>

> Index: wireless-2.6/net/rfkill/rfkill.c
> ===================================================================
> --- wireless-2.6.orig/net/rfkill/rfkill.c	2007-10-28 14:27:30.000000000 +0100
> +++ wireless-2.6/net/rfkill/rfkill.c	2007-10-28 15:07:11.000000000 +0100
> @@ -276,21 +276,17 @@ static struct class rfkill_class = {
>  
>  static int rfkill_add_switch(struct rfkill *rfkill)
>  {
> -	int retval;
> -
> -	retval = mutex_lock_interruptible(&rfkill_mutex);
> -	if (retval)
> -		return retval;
> +	int error;
>  
> -	retval = rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type]);
> -	if (retval)
> -		goto out;
> +	mutex_lock(&rfkill_mutex);
>  
> -	list_add_tail(&rfkill->node, &rfkill_list);
> +	error = rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type]);
> +	if (!error)
> +		list_add_tail(&rfkill->node, &rfkill_list);
>  
> - out:
>  	mutex_unlock(&rfkill_mutex);
> -	return retval;
> +
> +	return error;
>  }
>  
>  static void rfkill_remove_switch(struct rfkill *rfkill)
> @@ -387,6 +383,8 @@ int rfkill_register(struct rfkill *rfkil
>  
>  	if (!rfkill->toggle_radio)
>  		return -EINVAL;
> +	if (rfkill->type >= RFKILL_TYPE_MAX)
> +		return -EINVAL;
>  
>  	snprintf(dev->bus_id, sizeof(dev->bus_id),
>  		 "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
> 



      reply	other threads:[~2007-10-28 14:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-28 14:16 [PATCH] rfkill: Use mutex_lock() at register and add sanity check Michael Buesch
2007-10-28 15:03 ` Ivo van Doorn [this message]

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=200710281603.48603.IvDoorn@gmail.com \
    --to=ivdoorn@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mb@bu3sch.de \
    /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).