]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: unisys: check the whole channel instead of just guid for match
authorSameer Wadgaonkar <sameer.wadgaonkar@unisys.com>
Wed, 27 Sep 2017 17:14:43 +0000 (13:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Sep 2017 09:20:21 +0000 (11:20 +0200)
Validate that the channel contents match the channel type that we are
matching.

Signed-off-by: Sameer Wadgaonkar <sameer.wadgaonkar@unisys.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorbus_main.c
drivers/staging/unisys/visorhba/visorhba_main.c
drivers/staging/unisys/visorinput/visorinput.c
drivers/staging/unisys/visornic/visornic_main.c

index 7df06f1b9fbd992130bc627f13dd514e057cc67d..cc6a9d834f63a669f317a8f34a60cb2f0b0e8778 100644 (file)
@@ -143,14 +143,23 @@ static int visorbus_match(struct device *xdev, struct device_driver *xdrv)
        int i;
        struct visor_device *dev;
        struct visor_driver *drv;
+       struct visorchannel *chan;
 
        dev = to_visor_device(xdev);
        channel_type = visorchannel_get_guid(dev->visorchannel);
        drv = to_visor_driver(xdrv);
+       chan = dev->visorchannel;
        if (!drv->channel_types)
                return 0;
        for (i = 0; !guid_is_null(&drv->channel_types[i].guid); i++)
-               if (guid_equal(&drv->channel_types[i].guid, channel_type))
+               if (guid_equal(&drv->channel_types[i].guid, channel_type) &&
+                   visor_check_channel(visorchannel_get_header(chan),
+                                       xdev,
+                                       &drv->channel_types[i].guid,
+                                       (char *)drv->channel_types[i].name,
+                                       drv->channel_types[i].min_bytes,
+                                       drv->channel_types[i].version,
+                                       VISOR_CHANNEL_SIGNATURE))
                        return i + 1;
        return 0;
 }
index b84b40e78f8f1eb6c8455351efa1dc4a6e958a8d..91e6e358f506e8645791bdbebcaf756e0c961c76 100644 (file)
@@ -40,7 +40,8 @@ static struct visor_channeltype_descriptor visorhba_channel_types[] = {
        /* Note that the only channel type we expect to be reported by the
         * bus driver is the VISOR_VHBA channel.
         */
-       { VISOR_VHBA_CHANNEL_GUID, "sparvhba" },
+       { VISOR_VHBA_CHANNEL_GUID, "sparvhba", sizeof(struct channel_header),
+         VISOR_VHBA_CHANNEL_VERSIONID },
        {}
 };
 
index 1b58663709e6d4013c9932fb8eda8c82bd30f266..450f003743c00af0d1fd8a3ceab3425253621cc5 100644 (file)
@@ -712,8 +712,9 @@ static int visorinput_resume(struct visor_device *dev,
 
 /* GUIDS for all channel types supported by this driver. */
 static struct visor_channeltype_descriptor visorinput_channel_types[] = {
-       { VISOR_KEYBOARD_CHANNEL_GUID, "keyboard"},
-       { VISOR_MOUSE_CHANNEL_GUID, "mouse"},
+       { VISOR_KEYBOARD_CHANNEL_GUID, "keyboard",
+         sizeof(struct channel_header), 0 },
+       { VISOR_MOUSE_CHANNEL_GUID, "mouse", sizeof(struct channel_header), 0 },
        {}
 };
 
index c5f0b012378fa80d1c2c54216d449dd8d0568bec..f3188884131093a185fa270f08c28a20e34c1a70 100644 (file)
@@ -49,7 +49,8 @@ static struct visor_channeltype_descriptor visornic_channel_types[] = {
        /* Note that the only channel type we expect to be reported by the
         * bus driver is the VISOR_VNIC channel.
         */
-       { VISOR_VNIC_CHANNEL_GUID, "ultravnic" },
+       { VISOR_VNIC_CHANNEL_GUID, "ultravnic", sizeof(struct channel_header),
+         VISOR_VNIC_CHANNEL_VERSIONID },
        {}
 };
 MODULE_DEVICE_TABLE(visorbus, visornic_channel_types);