lkml.org 
[lkml]   [2012]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] firmware: Don't attempt to allocate zero bytes with vmalloc()
From
On Sat, Oct 6, 2012 at 1:05 AM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> vmalloc() will fail (very loudly) if we try to allocate zero bytes to
> read a zero byte file. Instead report that we successfully read in all
> zero bytes.
>
> It's not immediately obvious to me that this is better than returning an
> error but it seems better to punt the decision about that to the caller
> on the off chance that it's sensible.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/base/firmware_class.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index 8154145..a14eb92 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -62,6 +62,11 @@ static bool fw_read_file_contents(struct file *file, struct firmware *fw)
> char *buf;
>
> size = fw_file_size(file);
> + if (size == 0) {
> + fw->data = NULL;
> + fw->size = 0;
> + return true;
> + }

Considered that zero-length firmware image doesn't make sense for drivers
(callers), maybe it is a insane firmware image, so how about treating it as a
failure?

Thanks,
--
Ming Lei


\
 
 \ /
  Last update: 2012-10-09 01:41    [W:0.082 / U:0.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site