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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230427133350.31064-4-oneukum@suse.com>
Date:   Thu, 27 Apr 2023 15:33:45 +0200
From:   Oliver Neukum <oneukum@...e.com>
To:     wim@...ux-watchdog.org, linux@...ck-us.net,
        linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Oliver Neukum <oneukum@...e.com>
Subject: [PATCH 3/8] pcwd_usb: usb_pcwd_open handle and return errors

Operations on the bus can suffer an IO error.
Handle it undoing partial operations and return
it to user space

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Oliver Neukum <oneukum@...e.com>
---
 drivers/watchdog/pcwd_usb.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index d5d68a529620..ed3be8926a15 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -273,7 +273,7 @@ static int usb_pcwd_start(struct usb_pcwd_private *usb_pcwd)
 
 	if ((retval == 0) || (lsb == 0)) {
 		pr_err("Card did not acknowledge enable attempt\n");
-		return -1;
+		return -EIO;
 	}
 
 	return 0;
@@ -484,10 +484,22 @@ static int usb_pcwd_open(struct inode *inode, struct file *file)
 		goto error;
 
 	/* Activate */
-	usb_pcwd_start(usb_pcwd_device);
-	usb_pcwd_keepalive(usb_pcwd_device);
+	retval = usb_pcwd_start(usb_pcwd_device);
+	if (retval < 0)
+		goto err_bail;
+	retval = usb_pcwd_keepalive(usb_pcwd_device);
+	if (retval < 0)
+		goto err_bail_and_stop;
 	retval = stream_open(inode, file);
+	if (retval < 0)
+		goto err_bail_and_stop;
+	mutex_unlock(&disconnect_mutex);
+	return retval;
 
+err_bail_and_stop:
+	usb_pcwd_stop(usb_pcwd_device);
+err_bail:
+	clear_bit(0, &is_active);
 error:
 	mutex_unlock(&disconnect_mutex);
 	return retval;
-- 
2.40.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ