[PATCH 6/6] firmware-qemu_fw_cfg: Move a variable assignment in fw_cfg_sysfs_probe()

SF Markus Elfring
2016-09-18T12:58:33Z

Date: Sun, 18 Sep 2016 14:25:55 +0200

One local variable was set to an error code before a concrete
error situation was detected. Thus move the corresponding assignment into
two if branches to indicate a software failure there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/firmware/qemu_fw_cfg.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index a09e59c..23293a1 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -535,13 +535,16 @@ static int fw_cfg_sysfs_probe(struct platform_device *pdev)
return -EBUSY;

/* create by_key and by_name subdirs of /sys/firmware/qemu_fw_cfg/ */
- err = -ENOMEM;
fw_cfg_sel_ko = kobject_create_and_add("by_key", fw_cfg_top_ko);
- if (!fw_cfg_sel_ko)
+ if (!fw_cfg_sel_ko) {
+ err = -ENOMEM;
goto exit;
+ }
fw_cfg_fname_kset = kset_create_and_add("by_name", NULL, fw_cfg_top_ko);
- if (!fw_cfg_fname_kset)
+ if (!fw_cfg_fname_kset) {
+ err = -ENOMEM;
goto cleanup_object;
+ }

/* initialize fw_cfg device i/o from platform data */
err = fw_cfg_do_platform_probe(pdev);
--
2.10.0