From: Matt Fleming <matt@console-pimps.org>
To: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: Tom Gundersen <teg-B22kvLQNl6c@public.gmane.org>,
linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Seiji Aguchi <seiji.aguchi-7rDLJAbr9SE@public.gmane.org>
Subject: Re: [patch] efi: locking fix in efivar_entry_set_safe()
Date: Tue, 30 Apr 2013 11:33:27 +0000 [thread overview]
Message-ID: <517FAC07.8000405@console-pimps.org> (raw)
In-Reply-To: <20130430074312.GD7237-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
On 30/04/13 08:43, Dan Carpenter wrote:
> The intent is that if we aren't allowed to block because we're in an
> NMI or an emergency then we only take the lock if it is uncontended.
>
> Part of the problem is the test is reversed so we return -EBUSY if we
> acquire the lock.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Static checker stuff. I haven't tested this.
This looks correct to me. Thanks!
> diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> index 1d80c1c..f34d8fe 100644
> --- a/drivers/firmware/efi/vars.c
> +++ b/drivers/firmware/efi/vars.c
> @@ -622,10 +622,12 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
> if (!ops->query_variable_store)
> return -ENOSYS;
>
> - if (!block && spin_trylock_irqsave(&__efivars->lock, flags))
> - return -EBUSY;
> - else
> + if (!block) {
> + if (!spin_trylock_irqsave(&__efivars->lock, flags))
> + return -EBUSY;
> + } else {
> spin_lock_irqsave(&__efivars->lock, flags);
> + }
>
> status = check_var_size(attributes, size + ucs2_strsize(name, 1024));
> if (status != EFI_SUCCESS) {
--
Matt Fleming, Intel Open Source Technology Center
WARNING: multiple messages have this Message-ID (diff)
From: Matt Fleming <matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
To: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: Tom Gundersen <teg-B22kvLQNl6c@public.gmane.org>,
linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Seiji Aguchi <seiji.aguchi-7rDLJAbr9SE@public.gmane.org>
Subject: Re: [patch] efi: locking fix in efivar_entry_set_safe()
Date: Tue, 30 Apr 2013 12:33:27 +0100 [thread overview]
Message-ID: <517FAC07.8000405@console-pimps.org> (raw)
In-Reply-To: <20130430074312.GD7237-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
On 30/04/13 08:43, Dan Carpenter wrote:
> The intent is that if we aren't allowed to block because we're in an
> NMI or an emergency then we only take the lock if it is uncontended.
>
> Part of the problem is the test is reversed so we return -EBUSY if we
> acquire the lock.
>
> Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> ---
> Static checker stuff. I haven't tested this.
This looks correct to me. Thanks!
> diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> index 1d80c1c..f34d8fe 100644
> --- a/drivers/firmware/efi/vars.c
> +++ b/drivers/firmware/efi/vars.c
> @@ -622,10 +622,12 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
> if (!ops->query_variable_store)
> return -ENOSYS;
>
> - if (!block && spin_trylock_irqsave(&__efivars->lock, flags))
> - return -EBUSY;
> - else
> + if (!block) {
> + if (!spin_trylock_irqsave(&__efivars->lock, flags))
> + return -EBUSY;
> + } else {
> spin_lock_irqsave(&__efivars->lock, flags);
> + }
>
> status = check_var_size(attributes, size + ucs2_strsize(name, 1024));
> if (status != EFI_SUCCESS) {
--
Matt Fleming, Intel Open Source Technology Center
next prev parent reply other threads:[~2013-04-30 11:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-30 7:43 [patch] efi: locking fix in efivar_entry_set_safe() Dan Carpenter
2013-04-30 7:43 ` Dan Carpenter
[not found] ` <20130430074312.GD7237-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2013-04-30 11:33 ` Matt Fleming [this message]
2013-04-30 11:33 ` Matt Fleming
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=517FAC07.8000405@console-pimps.org \
--to=matt@console-pimps.org \
--cc=dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=seiji.aguchi-7rDLJAbr9SE@public.gmane.org \
--cc=teg-B22kvLQNl6c@public.gmane.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.