linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spidev_test: Fix input file check when transferring file
@ 2016-11-04 10:30 Michal Vokáč
       [not found] ` <1478255403-11149-1-git-send-email-vokac.m-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Vokáč @ 2016-11-04 10:30 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
	stillcompiling-Re5JQEeQqe8AvxtiuMwx3w, Michal Vokáč

Check the input file fd instead of spidev fd.
The spidev fd is supposed to be OK otherwise the transfer_file() function
would not be called at all.

Signed-off-by: Michal Vokáč <vokac.m-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 tools/spi/spidev_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
index f046b77..816f119 100644
--- a/tools/spi/spidev_test.c
+++ b/tools/spi/spidev_test.c
@@ -315,7 +315,7 @@ static void transfer_file(int fd, char *filename)
 		pabort("can't stat input file");
 
 	tx_fd = open(filename, O_RDONLY);
-	if (fd < 0)
+	if (tx_fd < 0)
 		pabort("can't open input file");
 
 	tx = malloc(sb.st_size);
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: spidev_test: Fix input file check when transferring file
       [not found] ` <1478255403-11149-1-git-send-email-vokac.m-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-11-04 10:50   ` Joshua Clayton
  0 siblings, 0 replies; 2+ messages in thread
From: Joshua Clayton @ 2016-11-04 10:50 UTC (permalink / raw)
  To: Michal Vokáč
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, linux-spi-u79uwXL29TY76Z2rM5mHXA

Hi, Michal
On Friday, November 04, 2016 11:30:03 AM Michal Vokáč wrote:
> Check the input file fd instead of spidev fd.
> The spidev fd is supposed to be OK otherwise the transfer_file() function
> would not be called at all.
> 
> Signed-off-by: Michal Vokáč <vokac.m-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  tools/spi/spidev_test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
> index f046b77..816f119 100644
> --- a/tools/spi/spidev_test.c
> +++ b/tools/spi/spidev_test.c
> @@ -315,7 +315,7 @@ static void transfer_file(int fd, char *filename)
>  		pabort("can't stat input file");
>  
>  	tx_fd = open(filename, O_RDONLY);
> -	if (fd < 0)
> +	if (tx_fd < 0)
>  		pabort("can't open input file");
>  
>  	tx = malloc(sb.st_size);
> 
Good catch. That is definitely a bug in the previous code.

Reviewed-by: Joshua Clayton <stillcompiling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-04 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-04 10:30 [PATCH] spi: spidev_test: Fix input file check when transferring file Michal Vokáč
     [not found] ` <1478255403-11149-1-git-send-email-vokac.m-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-04 10:50   ` Joshua Clayton

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