All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux@audioscience.com
Cc: Eliot Blennerhassett <eblennerhassett@audioscience.com>,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH] ALSA: asihpi - Clarify adapter index validity check.
Date: Thu, 28 Jul 2011 07:43:16 +0200	[thread overview]
Message-ID: <s5h62mn6juz.wl%tiwai@suse.de> (raw)
In-Reply-To: <1311803417-10328-1-git-send-email-linux@audioscience.com>

At Thu, 28 Jul 2011 09:50:17 +1200,
linux@audioscience.com wrote:
> 
> From: Eliot Blennerhassett <eblennerhassett@audioscience.com>
> 
> Avoids assigning possibly invalid address to pa, even if it
> is never dereferenced.
> 
> Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
> ---
>  sound/pci/asihpi/hpioctl.c |   19 ++++++++++++-------
>  1 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
> index 9683f84..a32502e 100644
> --- a/sound/pci/asihpi/hpioctl.c
> +++ b/sound/pci/asihpi/hpioctl.c
> @@ -177,16 +177,21 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  	} else {
>  		u16 __user *ptr = NULL;
>  		u32 size = 0;
> -
> +		u32 adapter_present;
>  		/* -1=no data 0=read from user mem, 1=write to user mem */
>  		int wrflag = -1;
> -		u32 adapter = hm->h.adapter_index;
> -		struct hpi_adapter *pa = &adapters[adapter];
> +		struct hpi_adapter *pa;
> +
> +		if (hm->h.adapter_index < HPI_MAX_ADAPTERS) {
> +			pa = &adapters[hm->h.adapter_index];
> +			adapter_present = pa->type;
> +		} else {
> +			adapter_present = 0;
> +		}
>  
> -		if ((adapter >= HPI_MAX_ADAPTERS) || (!pa->type)) {
> -			hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER,
> -				HPI_ADAPTER_OPEN,
> -				HPI_ERROR_BAD_ADAPTER_NUMBER);
> +		if (!adapter_present) {
> +			hpi_init_response(&hr->r0, hm->h.object,
> +				hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER);

Here you are initializing to different values (from HPI_OBJ_ADAPTER to
hm->h.object, etc).  Is it intentional?


thanks,

Takashi

  reply	other threads:[~2011-07-28  5:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 21:50 [PATCH] ALSA: asihpi - Clarify adapter index validity check linux
2011-07-28  5:43 ` Takashi Iwai [this message]
2011-07-28 22:14   ` Eliot Blennerhassett
2011-07-29  5:30     ` Takashi Iwai
2011-08-01 21:44       ` linux

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=s5h62mn6juz.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=eblennerhassett@audioscience.com \
    --cc=linux@audioscience.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.