All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: Sengul Thomas <thomas.sengul@gmail.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>,
	Xen Devel <xen-devel@lists.xen.org>
Subject: Re: arm: Minor bug report & Fix in gic_route_irq_to_guest
Date: Wed, 24 Apr 2013 14:22:33 +0100	[thread overview]
Message-ID: <5177DC99.8090503@citrix.com> (raw)
In-Reply-To: <CAJWjLtrtUQuM9+BOf4=ScG3Si1hDQguLxiDtKKXv805EQ0Krmw@mail.gmail.com>

On 04/24/2013 03:24 AM, Sengul Thomas wrote:

> Hello,
> 
> I found that when calling gic_route_irq_to_guest in construct_dom0 function,
> it uses local variable "name" for passing devname argument.
> And, gic_route_irq_to_guest just copies the pointer of this devname
> and afterward,
> reading this devname gives data abort.
> 
> Here goes a simple fix: just copying the data, not the pointer

Thanks for this report. I prefer to remove all uses of local variable
"name", because I intend to remove this code soon.

I have pushed the commit in the arndale branch with another minor change.

Cheers,

Julien

> Signed-off-by: Thomas Sengul <thomas.sengul@gmail.com>
> ---
>  xen/arch/arm/gic.c |   13 ++++++++++++-
>  xen/arch/arm/irq.c |   14 +++++++++++++-
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 63caeb8..012aae9 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -468,7 +468,10 @@ void __init release_irq(unsigned int irq)
>      do { smp_mb(); } while ( desc->status & IRQ_INPROGRESS );
> 
>      if (action && action->free_on_release)
> +    {
> +        xfree((void *)action->name);
>          xfree(action);
> +    }
>  }
> 
>  static int __setup_irq(struct irq_desc *desc, unsigned int irq,
> @@ -617,13 +620,20 @@ int gic_route_irq_to_guest(struct domain *d,
> unsigned int irq,
>      struct irq_desc *desc = irq_to_desc(irq);
>      unsigned long flags;
>      int retval;
> +    char *name;
> 
>      action = xmalloc(struct irqaction);
>      if (!action)
>          return -ENOMEM;
> 
>      action->dev_id = d;
> -    action->name = devname;
> +
> +#define MIN_ACTION_NAME_LEN 16
> +    name = xmalloc_array(char, MIN_ACTION_NAME_LEN);
> +    if (!name)
> +        return -ENOMEM;
> +    strlcpy(name, devname, strnlen(devname, MIN_ACTION_NAME_LEN));
> +    action->name = name;
> 
>      spin_lock_irqsave(&desc->lock, flags);
>      spin_lock(&gic.lock);
> @@ -635,6 +645,7 @@ int gic_route_irq_to_guest(struct domain *d,
> unsigned int irq,
> 
>      retval = __setup_irq(desc, irq, action);
>      if (retval) {
> +        xfree((void *)action->name);
>          xfree(action);
>          goto out;
>      }
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 8c96a0a..e6c24f9 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -99,6 +99,7 @@ int __init request_irq(unsigned int irq,
>  {
>      struct irqaction *action;
>      int retval;
> +    char *name;
> 
>      /*
>       * Sanity-check: shared interrupts must pass in a real dev-ID,
> @@ -116,13 +117,24 @@ int __init request_irq(unsigned int irq,
>          return -ENOMEM;
> 
>      action->handler = handler;
> -    action->name = devname;
> +
> +#define MIN_ACTION_NAME_LEN 16
> +    name = xmalloc_array(char, MIN_ACTION_NAME_LEN);
> +    if (!name)
> +        return -ENOMEM;
> +    strlcpy(name, devname, strnlen(devname, MIN_ACTION_NAME_LEN));
> +    action->name = name;
> +
>      action->dev_id = dev_id;
>      action->free_on_release = 1;
> 
>      retval = setup_irq(irq, action);
>      if (retval)
> +    {
> +        xfree((void *)action->name);
>          xfree(action);
> +    }
> +
> 
>      return retval;
>  }
> 
> 
> Sincerely,
> Thomas
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

      parent reply	other threads:[~2013-04-24 13:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24  2:24 arm: Minor bug report & Fix in gic_route_irq_to_guest Sengul Thomas
2013-04-24  8:24 ` Ian Campbell
2013-04-24  8:36   ` Sengul Thomas
2013-04-24 13:22 ` Julien Grall [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=5177DC99.8090503@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=thomas.sengul@gmail.com \
    --cc=xen-devel@lists.xen.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 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.