Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752556AbdLNNZm (ORCPT ); Thu, 14 Dec 2017 08:25:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51124 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752479AbdLNNZi (ORCPT ); Thu, 14 Dec 2017 08:25:38 -0500 From: Benjamin Tissoires To: Dmitry Torokhov , Samuel Thibault , Peter Hutterer Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires , stable@vger.kernel.org Subject: [PATCH 1/2] input - leds: do not iterate over non initialized leds Date: Thu, 14 Dec 2017 14:25:21 +0100 Message-Id: <20171214132522.20346-2-benjamin.tissoires@redhat.com> In-Reply-To: <20171214132522.20346-1-benjamin.tissoires@redhat.com> References: <20171214132522.20346-1-benjamin.tissoires@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 14 Dec 2017 13:25:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 994 Lines: 32 We only instantiate the led classes if there is a definition in input_led_info[]. However, the max for EV_LED is bigger than the values filled in this array, and there are some holes in it. In .connect(), we check for these holes, but in leds_init_work() we do not, leading to some nice kernel oopses. Found by running https://github.com/whot/fuzzydevice Cc: stable@vger.kernel.org Signed-off-by: Benjamin Tissoires --- drivers/input/input-leds.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c index 83d930f7396a..c86eb3d648bf 100644 --- a/drivers/input/input-leds.c +++ b/drivers/input/input-leds.c @@ -94,6 +94,9 @@ static void leds_init_work(struct work_struct *work) int led_no = 0; for_each_set_bit(led_code, leds->handle.dev->ledbit, LED_CNT) { + if (!input_led_info[led_code].name) + continue; + led = &leds->leds[led_no]; down_read(&led->cdev.trigger_lock); -- 2.14.3