public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Geoff Levand <geoff@infradead.org>
Cc: kexec@lists.infradead.org
Subject: Re: [PATCH 2/2] kexec: Handle read errors in fs2dt setup
Date: Fri, 4 Oct 2013 09:02:44 +0900	[thread overview]
Message-ID: <20131004000244.GG29457@verge.net.au> (raw)
In-Reply-To: <08231e47adbe1031fb2e919cce3c7f75b3edfa55.1380830946.git.geoff@infradead.org>

On Thu, Oct 03, 2013 at 08:19:34PM +0000, Geoff Levand wrote:
> The putnode() routine in fs2dt.c was not checking for errors
> returned from calls to read().  Add checks for these errors
> and abort the setup of printing from purgatory if the checks
> fail.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
>  kexec/fs2dt.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Thanks, applied.

> 
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 98d6cb4..242a15e 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -639,6 +639,11 @@ static void putnode(void)
>  		}
>  		result = read(fd, buff, statbuf.st_size);
>  		close(fd);
> +		if (result <= 0) {
> +			printf("Unable to read %s, printing from purgatory is diabled\n",
> +														filename);
> +			goto no_debug;
> +		}
>  		strncpy(filename, "/proc/device-tree/", MAXPATH);
>  		strncat(filename, buff, MAXPATH);
>  		strncat(filename, "/compatible", MAXPATH);
> @@ -661,7 +666,8 @@ static void putnode(void)
>  			goto no_debug;
>  		}
>  		result = read(fd, buff, statbuf.st_size);
> -		if (!strcmp(buff, "hvterm1") || !strcmp(buff, "hvterm-protocol"))
> +		if (result && (!strcmp(buff, "hvterm1")
> +			|| !strcmp(buff, "hvterm-protocol")))
>  			my_debug = 1;
>  		close(fd);
>  		free(buff);
> -- 
> 1.8.1.2
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2013-10-04  0:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 20:54 [PATCH 0/6] kexec-tools fixes Geoff Levand
2013-10-02 20:49 ` [PATCH 3/6] purgatory: Fix out-of-source build error Geoff Levand
2013-10-02 20:49 ` [PATCH 5/6] kexec: Fix return value build warnings Geoff Levand
2013-10-03  1:06   ` Simon Horman
2013-10-03 20:19   ` [PATCH 0/2] V2 " Geoff Levand
2013-10-03 20:19     ` [PATCH 1/2] " Geoff Levand
2013-10-04  0:02       ` Simon Horman
2013-10-03 20:19     ` [PATCH 2/2] kexec: Handle read errors in fs2dt setup Geoff Levand
2013-10-04  0:02       ` Simon Horman [this message]
2013-10-02 20:49 ` [PATCH 4/6] kexec: Fix uninitialized build warning Geoff Levand
2013-10-02 20:49 ` [PATCH 2/6] kexec: Remove unused -? option handling Geoff Levand
2013-10-02 20:49 ` [PATCH 1/6] kexec: Fix the -? option Geoff Levand
2013-10-02 20:49 ` [PATCH 6/6] config: Update to automake-1.11 Geoff Levand
2013-10-03  1:07 ` [PATCH 0/6] kexec-tools fixes Simon Horman

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=20131004000244.GG29457@verge.net.au \
    --to=horms@verge.net.au \
    --cc=geoff@infradead.org \
    --cc=kexec@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox