Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1562215
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4/5] um: ubd: Move two assignments for the variable "err" in ubd_remove() |
| Date | 2017-01-18 23:10 +0100 |
| Message-ID | <t16Ax-1or-5@gated-at.bofh.it> (permalink) |
| References | <t16qR-15L-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 22:23:18 +0100
A local variable was set to an error code in two cases before a concrete
error situation was detected. Thus move the corresponding assignments into
if branches to indicate a software failure there.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/um/drivers/ubd_kern.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 85410279beab..6d686f735538 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1049,19 +1049,21 @@ static int ubd_remove(int n, char **error_out)
{
struct gendisk *disk = ubd_gendisk[n];
struct ubd *ubd_dev;
- int err = -ENODEV;
+ int err;
mutex_lock(&ubd_lock);
ubd_dev = &ubd_devs[n];
-
- if(ubd_dev->file == NULL)
+ if (!ubd_dev->file) {
+ err = -ENODEV;
goto out;
+ }
/* you cannot remove a open disk */
- err = -EBUSY;
- if(ubd_dev->count > 0)
+ if (ubd_dev->count > 0) {
+ err = -EBUSY;
goto out;
+ }
ubd_gendisk[n] = NULL;
if(disk != NULL){
--
2.11.0
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 4/5] um: ubd: Move two assignments for the variable "err" in ubd_remove() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 23:10 +0100
csiph-web