* [PATCH] ibmasmfs: Use common error handling code in command_file_read()
@ 2024-09-18 18:32 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2024-09-18 18:32 UTC (permalink / raw)
To: kernel-janitors, Arnd Bergmann, Christian Brauner,
Greg Kroah-Hartman, Jeff Layton
Cc: LKML
From: Markus Elfring <elfring@users.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@users.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-18 18:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-18 18:32 [PATCH] ibmasmfs: Use common error handling code in command_file_read() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®