From: Markus Elfring <Markus.Elfring@web.de>
To: kernel-janitors@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Christian Brauner <brauner@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jeff Layton <jlayton@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] ibmasmfs: Use common error handling code in command_file_read()
Date: Wed, 18 Sep 2024 20:32:26 +0200 [thread overview]
Message-ID: <089721e7-367a-477d-a4b7-a712244bb5d3@web.de> (raw)
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
reply other threads:[~2024-09-18 18:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=089721e7-367a-477d-a4b7-a712244bb5d3@web.de \
--to=markus.elfring@web.de \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jlayton@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®