Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern allow passing a NULL proplib dictionary to modctl(M...



details:   https://anonhg.NetBSD.org/src/rev/917c728599ac
branches:  trunk
changeset: 748198:917c728599ac
user:      jnemeth <jnemeth%NetBSD.org@localhost>
date:      Fri Oct 16 00:27:07 2009 +0000

description:
allow passing a NULL proplib dictionary to modctl(MODCTL_LOAD, ...)

diffstat:

 sys/kern/kern_module.c |   8 ++++++--
 sys/kern/sys_module.c  |  43 ++++++++++++++++++++++++++-----------------
 2 files changed, 32 insertions(+), 19 deletions(-)

diffs (101 lines):

diff -r 794eab624f08 -r 917c728599ac sys/kern/kern_module.c
--- a/sys/kern/kern_module.c    Fri Oct 16 00:16:32 2009 +0000
+++ b/sys/kern/kern_module.c    Fri Oct 16 00:27:07 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_module.c,v 1.51 2009/10/03 00:06:37 elad Exp $    */
+/*     $NetBSD: kern_module.c,v 1.52 2009/10/16 00:27:07 jnemeth Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.51 2009/10/03 00:06:37 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.52 2009/10/16 00:27:07 jnemeth Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1252,6 +1252,10 @@
        const char *props_key;
        bool error;
 
+       if (new_dict == NULL) {                 /* nothing to merge */
+               return true;
+       }
+
        error = false;
        props_iter = prop_dictionary_iterator(new_dict);
        if (props_iter == NULL) {
diff -r 794eab624f08 -r 917c728599ac sys/kern/sys_module.c
--- a/sys/kern/sys_module.c     Fri Oct 16 00:16:32 2009 +0000
+++ b/sys/kern/sys_module.c     Fri Oct 16 00:27:07 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_module.c,v 1.9 2009/04/28 17:57:00 skrll Exp $     */
+/*     $NetBSD: sys_module.c,v 1.10 2009/10/16 00:27:07 jnemeth Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.9 2009/04/28 17:57:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.10 2009/10/16 00:27:07 jnemeth Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,29 +63,38 @@
        if (error != 0)
                goto out2;
 
-       propslen = ml->ml_propslen + 1;
-       props = (char *)kmem_alloc(propslen, KM_SLEEP);
-       if (props == NULL) {
-               error = ENOMEM;
-               goto out2;
-       }
+       if (ml->ml_props != NULL) {
+               propslen = ml->ml_propslen + 1;
+               props = (char *)kmem_alloc(propslen, KM_SLEEP);
+               if (props == NULL) {
+                       error = ENOMEM;
+                       goto out2;
+               }
 
-       error = copyinstr(ml->ml_props, props, propslen, NULL);
-       if (error != 0)
-               goto out3;
+               error = copyinstr(ml->ml_props, props, propslen, NULL);
+               if (error != 0)
+                       goto out3;
 
-       dict = prop_dictionary_internalize(props);
-       if (dict == NULL) {
-               error = EINVAL;
-               goto out3;
+               dict = prop_dictionary_internalize(props);
+               if (dict == NULL) {
+                       error = EINVAL;
+                       goto out3;
+               }
+       } else {
+               dict = NULL;
+               props = NULL;
        }
 
        error = module_load(path, ml->ml_flags, dict, MODULE_CLASS_ANY);
 
-       prop_object_release(dict);
+       if (dict != NULL) {
+               prop_object_release(dict);
+       }
 
 out3:
-       kmem_free(props, propslen);
+       if (props != NULL) {
+               kmem_free(props, propslen);
+       }
 out2:
        PNBUF_PUT(path);
 out1:



Home | Main Index | Thread Index | Old Index