lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150605124144.GA26755@markusri_laptop.vincit.intranet>
Date:	Fri, 5 Jun 2015 15:41:44 +0300
From:	Markus Rinne <markus.rinne@...cit.fi>
To:	wim@...ana.be
Cc:	linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] watchdog: imx2_wdt: Fix ioctl() results

WDIOC_SETTIMEOUT and WDIOC_GETTIMEOUT returned the initial timeout and
not the one that was last set.  Fix this by updating struct
watchdog_device member 'timeout'.  This is how it's supposed to be done
according to Documentation/watchdog/watchdog-kernel-api.txt.

This is the test case I used:

#include <fcntl.h>
#include <linux/watchdog.h>
#include <sys/stat.h>
#include <sys/types.h>

#include <assert.h>
#include <stdlib.h>

static const int TIMEOUT = 127;

int main(void)
{
	int fd = open("/dev/watchdog", O_WRONLY);
	if (fd == -1)
		return EXIT_FAILURE;

	int timeout = TIMEOUT;
	ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
	assert(timeout == TIMEOUT);

	close(fd);

	return EXIT_SUCCESS;
}

Signed-off-by: Markus Rinne <markus.rinne@...cit.fi>
---
 drivers/watchdog/imx2_wdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 5e6d808..b636799 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -168,6 +168,7 @@ static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
 
 	regmap_update_bits(wdev->regmap, IMX2_WDT_WCR, IMX2_WDT_WCR_WT,
 			   WDOG_SEC_TO_COUNT(new_timeout));
+	wdog->timeout = new_timeout;
 	return 0;
 }
 
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ