LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com>
To: Zahari Doychev <zahari.doychev@linux.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers: base: fw: fix ret value when loading fw
Date: Tue, 10 Mar 2015 15:32:43 +0800	[thread overview]
Message-ID: <CACVXFVNPxeHkpfq7TP5H53Fs_0LMiYUJ7xEP6bZ287R8rbq7GA@mail.gmail.com> (raw)
In-Reply-To: <1425916192-31600-2-git-send-email-zahari.doychev@linux.com>

On Mon, Mar 9, 2015 at 11:49 PM, Zahari Doychev
<zahari.doychev@linux.com> wrote:
> When using the user mode helper to load firmwares the function _request_firmware
> gets a positive return value from fw_load_from_user_helper and because of this
> the firmware buffer is not assigned. This happens only when the return value
> is zero. This patch fixes this problem in _request_firmware_load. When the
> completion is ready the return value is set to zero.
>
> Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>

Acked-by: Ming Lei <ming.lei@canonical.com>

> ---
>  drivers/base/firmware_class.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index 6c5c9ed..9642e5f 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -920,6 +920,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
>         else if (!buf->data)
>                 retval = -ENOMEM;
>
> +       /* wait for completion was successful so return ok */
> +       if (retval > 0)
> +               retval = 0;

Suggest to move the check backward and handle return value
from wait_for_completion_interruptible_timeout() in one place, like below:

           if (retval == -ERESTARTSYS || !retval) {
               ...
           } else if (retval > 0) {
               retval = 0;
           }

> +
>         device_remove_file(f_dev, &dev_attr_loading);
>  err_del_bin_attr:
>         device_remove_bin_file(f_dev, &firmware_attr_data);
> --
> 2.3.0
>

  reply	other threads:[~2015-03-10  7:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 15:49 [PATCH] fix loading of firmware with user mode helper Zahari Doychev
2015-03-09 15:49 ` [PATCH] drivers: base: fw: fix ret value when loading fw Zahari Doychev
2015-03-10  7:32   ` Ming Lei [this message]
2015-03-10  9:45     ` [PATCH v2] " Zahari Doychev
2015-03-18  7:41       ` Zahari Doychev

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=CACVXFVNPxeHkpfq7TP5H53Fs_0LMiYUJ7xEP6bZ287R8rbq7GA@mail.gmail.com \
    --to=ming.lei@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zahari.doychev@linux.com \
    --subject='Re: [PATCH] drivers: base: fw: fix ret value when loading fw' \
    /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

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).