diff options
author | Frank Praznik <frank.praznik@oh.rr.com> | 2014-02-20 20:36:02 +0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-02-24 20:38:46 +0400 |
commit | ac3c9a94094b515ab135886eb4547bb889d5b31a (patch) | |
tree | 359fe7bb4da2918428b687ce89311f201c560962 /drivers/hid/hid-sony.c | |
parent | c8de9dbb35d3e4efce2bce513192f34ca962d8c0 (diff) | |
download | linux-ac3c9a94094b515ab135886eb4547bb889d5b31a.tar.xz |
HID: sony: Perform a boundry check on the sixaxis battery level index.
Make sure that an out-of-bounds read doesn't occur in the Sixaxis battery level
lookup table in the event that the controller sends an invalid battery status
value in the report.
Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-sony.c')
-rw-r--r-- | drivers/hid/hid-sony.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index a51a9c0636be..b39e3abd6cdd 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -854,7 +854,8 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size) battery_capacity = 100; battery_charging = !(rd[30] & 0x01); } else { - battery_capacity = sixaxis_battery_capacity[rd[30]]; + __u8 index = rd[30] <= 5 ? rd[30] : 5; + battery_capacity = sixaxis_battery_capacity[index]; battery_charging = 0; } cable_state = !((rd[31] >> 4) & 0x01); |