From 2a64e78c7bec66fc6c7b4a78c118507cbfd248bf Mon Sep 17 00:00:00 2001 From: Shunichi Wakabayashi <8855640+s-wakaba@users.noreply.github.com> Date: Sun, 25 Sep 2022 16:46:10 +0900 Subject: [PATCH] bugfix: saving errno of ioctl() call in a temporary variable to prevent overwriting by following avrdude_message() call --- src/linuxspi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/linuxspi.c b/src/linuxspi.c index c7806081..881fe74a 100644 --- a/src/linuxspi.c +++ b/src/linuxspi.c @@ -93,9 +93,10 @@ static int linuxspi_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, u errno = 0; ret = ioctl(fd_spidev, SPI_IOC_MESSAGE(1), &tr); if (ret != len) { + int ioctl_errno = errno; avrdude_message(MSG_INFO, "\n%s: unable to send SPI message", progname); - if (errno) - avrdude_message(MSG_INFO, ". %s", strerror(errno)); + if (ioctl_errno) + avrdude_message(MSG_INFO, ". %s", strerror(ioctl_errno)); avrdude_message(MSG_INFO, "\n"); }