[Skiboot] [PATCH] external/pflash: Fix non-zero return code for successful read when size%256 != 0

Cyril Bur cyrilbur at gmail.com
Fri Dec 1 14:34:38 AEDT 2017


On Fri, 2017-12-01 at 13:41 +1100, Suraj Jitindar Singh wrote:

> When performing a read the return value from pflash is non-zero, even for

> a successful read, when the size being read is not a multiple of 256.

> This is because do_read_file returns the value from the write system

> call which is then returned by pflash. When the size is a multiple of

> 256 we get lucky in that this wraps around back to zero. However for any

> other value the return code is size % 256. This means even when the

> operation is successful the return code will seem to reflect an error.

>

> Fix this by returning zero if the entire size was read correctly,

> otherwise return the corresponding error code.

>

> Fixes: e1cf130d ("external/pflash: Remove use of exit() and fix memory leaks")

>

> Reported-by: Pridhiviraj Paidipeddi <ppaidipe at linux.vnet.ibm.com>

> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh at gmail.com>


Reviewed-by: Cyril Bur <cyrilbur at gmail.com>


> ---

>  external/pflash/pflash.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c

> index 381df24f..a5e7bc35 100644

> --- a/external/pflash/pflash.c

> +++ b/external/pflash/pflash.c

> @@ -511,7 +511,7 @@ static int do_read_file(struct blocklevel_device *bl, const char *file,

>  	}

>  	progress_end();

>  	close(fd);

> -	return rc;

> +	return size ? rc : 0;

>  }

>

>  static int enable_4B_addresses(struct blocklevel_device *bl)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/skiboot/attachments/20171201/783f4e8c/attachment.html>


More information about the Skiboot mailing list