Author: delphij
Date: Sun Jul 26 22:30:55 2020
New Revision: 363585
URL: https://svnweb.freebsd.org/changeset/base/363585

Log:
  gctl_get_geom: Skip validation of g_class.
  
  The caller from kernel is expected to provide an valid g_class
  pointer, instead of traversing the global g_class list, just
  use that pointer directly instead.
  
  Reviewed by:          mav
  MFC after:            2 weeks
  Differential Revision:        https://reviews.freebsd.org/D25811

Modified:
  head/sys/geom/geom.h
  head/sys/geom/geom_ctl.c

Modified: head/sys/geom/geom.h
==============================================================================
--- head/sys/geom/geom.h        Sun Jul 26 22:30:01 2020        (r363584)
+++ head/sys/geom/geom.h        Sun Jul 26 22:30:55 2020        (r363585)
@@ -434,7 +434,7 @@ void *gctl_get_paraml(struct gctl_req *req, const char
 void *gctl_get_paraml_opt(struct gctl_req *req, const char *param, int len);
 int gctl_error(struct gctl_req *req, const char *fmt, ...) __printflike(2, 3);
 struct g_class *gctl_get_class(struct gctl_req *req, char const *arg);
-struct g_geom *gctl_get_geom(struct gctl_req *req, struct g_class *mpr, char 
const *arg);
+struct g_geom *gctl_get_geom(struct gctl_req *req, struct g_class *mp, char 
const *arg);
 struct g_provider *gctl_get_provider(struct gctl_req *req, char const *arg);
 
 #endif /* _GEOM_GEOM_H_ */

Modified: head/sys/geom/geom_ctl.c
==============================================================================
--- head/sys/geom/geom_ctl.c    Sun Jul 26 22:30:01 2020        (r363584)
+++ head/sys/geom/geom_ctl.c    Sun Jul 26 22:30:55 2020        (r363585)
@@ -409,25 +409,20 @@ gctl_get_class(struct gctl_req *req, char const *arg)
 }
 
 struct g_geom *
-gctl_get_geom(struct gctl_req *req, struct g_class *mpr, char const *arg)
+gctl_get_geom(struct gctl_req *req, struct g_class *mp, char const *arg)
 {
        char const *p;
-       struct g_class *mp;
        struct g_geom *gp;
 
+       MPASS(mp != NULL);
        p = gctl_get_asciiparam(req, arg);
        if (p == NULL) {
                gctl_error(req, "Missing %s argument", arg);
                return (NULL);
        }
-       LIST_FOREACH(mp, &g_classes, class) {
-               if (mpr != NULL && mpr != mp)
-                       continue;
-               LIST_FOREACH(gp, &mp->geom, geom) {
-                       if (!strcmp(p, gp->name))
-                               return (gp);
-               }
-       }
+       LIST_FOREACH(gp, &mp->geom, geom)
+               if (!strcmp(p, gp->name))
+                       return (gp);
        gctl_error(req, "Geom not found: \"%s\"", p);
        return (NULL);
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to