public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/module.c: for looping, need use 'goto' instead of 'break' to jump out in time
@ 2013-05-07  6:27 Chen Gang
  2013-05-08  0:29 ` Rusty Russell
  0 siblings, 1 reply; 11+ messages in thread
From: Chen Gang @ 2013-05-07  6:27 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Linus Torvalds, linux-kernel@vger.kernel.org


In the 'for' looping, when error occurs, the 'break' only jump out of
'switch', and still in 'for' looping.  If error occurs multiple times,
the original error value will be overwrite.

Currently, that will not cause issue, but still better to improve it,
so that let it return the first real error code in time.

The related commit: "1da177e Linux-2.6.12-rc"


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/module.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index b049939..7e012ff 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1977,7 +1977,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 			printk("%s: please compile with -fno-common\n",
 			       mod->name);
 			ret = -ENOEXEC;
-			break;
+			goto tail;
 
 		case SHN_ABS:
 			/* Don't need to do anything */
@@ -2000,7 +2000,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 			printk(KERN_WARNING "%s: Unknown symbol %s (err %li)\n",
 			       mod->name, name, PTR_ERR(ksym));
 			ret = PTR_ERR(ksym) ?: -ENOENT;
-			break;
+			goto tail;
 
 		default:
 			/* Divert to percpu allocation if a percpu var. */
@@ -2013,6 +2013,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 		}
 	}
 
+tail:
 	return ret;
 }
 
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-05-23  5:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-07  6:27 [PATCH] kernel/module.c: for looping, need use 'goto' instead of 'break' to jump out in time Chen Gang
2013-05-08  0:29 ` Rusty Russell
2013-05-08  3:09   ` Chen Gang
2013-05-13  1:17     ` Rusty Russell
2013-05-13  3:33       ` Chen Gang
2013-05-13 12:24         ` [PATCH v2] kernel/module.c: cleanup patch for looping, let return 'bool' value instead of real error number Chen Gang
2013-05-14  2:16           ` Chen Gang
2013-05-17  4:33             ` [PATCH v3] kernel/module.c: need return the first error code to upper caller when error occurs Chen Gang
2013-05-22 11:26               ` Chen Gang
2013-05-23  3:54                 ` Rusty Russell
2013-05-23  5:13                   ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox