Skip to contentSkip to conversation

spi: spidev_test: Fix input file check when transferring file

PATCH In review Michal Vokáč 2 participants 2 messages Nov 4, 2016 1 message not in the archive SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: spidev_test: Fix input file check when transferring file

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.

---
 tools/spi/spidev_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/spi/spidev_test.c +1 -1
index f046b77..816f119 100644
@@ -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);
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reviewed-by
#2 lore raw
In reply to a message not in the archive

Hi, Michal

Quoted 15 lines · 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.

---
 tools/spi/spidev_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/spi/spidev_test.c +0 -0
index f046b77..816f119 100644

tools/spi/spidev_test.c static void transfer_file(int fd, char *filename) · line 321

Quoted 8 lines
tools/spi/spidev_test.c +1 -1
@@ -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.

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html