Limit the enabled wakeup protocols to be within a protocol group, as
defined by the proto_names array. For example this prevents the
selection of both rc-5 and nec, while allowing rc-5 alone (which
encompasses both normal rc-5 and rc-5x).

It doesn't usually make sense to enable more than one wakeup protocol
since only a single protocol can usually be used for wakeup at a time,
and doing so with encode based wakeup will result in an arbitrary
protocol being used if multiple are possible.

Reported-by: Antti Seppälä <a.sepp...@gmail.com>
Signed-off-by: James Hogan <james.ho...@imgtec.com>
Cc: Mauro Carvalho Chehab <m.che...@samsung.com>
Cc: Antti Seppälä <a.sepp...@gmail.com>
---
Sorry it took a little while to get around to submitting this.
---
 drivers/media/rc/rc-main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index e067fee..79d1060 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -979,6 +979,19 @@ static ssize_t store_protocols(struct device *device,
                goto out;
        }
 
+       if (fattr->type == RC_FILTER_WAKEUP) {
+               /* A proto_names entry must cover enabled wakeup protocols */
+               for (i = 0; i < ARRAY_SIZE(proto_names); i++)
+                       if (type & proto_names[i].type &&
+                           !(type & ~proto_names[i].type))
+                               break;
+               if (i == ARRAY_SIZE(proto_names)) {
+                       IR_dprintk(1, "Multiple distinct wakeup protocols\n");
+                       ret = -EINVAL;
+                       goto out;
+               }
+       }
+
        change_protocol = (fattr->type == RC_FILTER_NORMAL)
                ? dev->change_protocol : dev->change_wakeup_protocol;
        if (change_protocol) {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to