]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
staging: vchiq: Introduce vchiq_validate_params()
authorNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Mon, 29 Jun 2020 15:09:20 +0000 (17:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Jul 2020 13:47:05 +0000 (15:47 +0200)
When adding a new service validate the configuration parameters
provided, and remove unnecessary checks in vchi, now that we have
validated service's config.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-23-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c

index e0027148963edcbb5d1b74a3dcb6462ab60c3301..0a2419bd305bd17e636087072aa99851b0c348d6 100644 (file)
@@ -2265,6 +2265,16 @@ fail_free_handler_thread:
        return VCHIQ_ERROR;
 }
 
+static int vchiq_validate_params(const struct vchiq_service_params *params)
+{
+       if (!params->callback || !params->fourcc) {
+               vchiq_loud_error("Can't add service, invalid params\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 /* Called from application thread when a client or server service is created. */
 struct vchiq_service *
 vchiq_add_service_internal(struct vchiq_state *state,
@@ -2275,8 +2285,13 @@ vchiq_add_service_internal(struct vchiq_state *state,
        struct vchiq_service *service;
        struct vchiq_service __rcu **pservice = NULL;
        struct vchiq_service_quota *service_quota;
+       int ret;
        int i;
 
+       ret = vchiq_validate_params(params);
+       if (ret)
+               return NULL;
+
        service = kmalloc(sizeof(*service), GFP_KERNEL);
        if (!service)
                return service;
index b4884d0b82cdb94cff1eebd78756056babf5e52e..3ce4b7b5d55ee35045cda64e22457fb2982b06d5 100644 (file)
@@ -271,15 +271,11 @@ static enum vchiq_status shim_callback(enum vchiq_reason reason,
        struct vchi_service *service =
                (struct vchi_service *)VCHIQ_GET_SERVICE_USERDATA(handle);
 
-       if (!service->callback)
-               goto release;
-
        if (reason == VCHIQ_MESSAGE_AVAILABLE)
                vchiu_queue_push(&service->queue, header);
 
        service->callback(service->callback_param, reason, bulk_user);
 
-release:
        return VCHIQ_SUCCESS;
 }