[<prev] [next>] [day] [month] [year] [list]
Message-ID: <089721e7-367a-477d-a4b7-a712244bb5d3@web.de>
Date: Wed, 18 Sep 2024 20:32:26 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: kernel-janitors@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
Christian Brauner <brauner@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jeff Layton <jlayton@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] ibmasmfs: Use common error handling code in
command_file_read()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Wed, 18 Sep 2024 19:50:27 +0200
Add a label so that a bit of exception handling can be better reused
at the end of this function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
drivers/misc/ibmasm/ibmasmfs.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index c44de892a61e..93b69f473452 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -280,14 +280,15 @@ static ssize_t command_file_read(struct file *file, char __user *buf, size_t cou
spin_unlock_irqrestore(&command_data->sp->lock, flags);
if (cmd->status != IBMASM_CMD_COMPLETE) {
- command_put(cmd);
- return -EIO;
+ len = -EIO;
+ goto put_command;
}
len = min(count, cmd->buffer_size);
if (copy_to_user(buf, cmd->buffer, len)) {
- command_put(cmd);
- return -EFAULT;
+ len = -EFAULT;
+ goto put_command;
}
+put_command:
command_put(cmd);
return len;
--
2.46.0
Powered by blists - more mailing lists