Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754554AbdLOAT5 (ORCPT ); Thu, 14 Dec 2017 19:19:57 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:46608 "EHLO hera.aquilenet.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754424AbdLOATy (ORCPT ); Thu, 14 Dec 2017 19:19:54 -0500 Date: Fri, 15 Dec 2017 01:19:51 +0100 From: Samuel Thibault To: Benjamin Tissoires Cc: Dmitry Torokhov , Peter Hutterer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 2/2] input - leds: fix input_led_disconnect path Message-ID: <20171215001951.2gbwks6wmmsl7ssf@var.youpi.perso.aquilenet.fr> Mail-Followup-To: Samuel Thibault , Benjamin Tissoires , Dmitry Torokhov , Peter Hutterer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20171214132522.20346-1-benjamin.tissoires@redhat.com> <20171214132522.20346-3-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171214132522.20346-3-benjamin.tissoires@redhat.com> Organization: I am not organized User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1505 Lines: 46 Benjamin Tissoires, on jeu. 14 déc. 2017 14:25:22 +0100, wrote: > Before unregistering the led classes, we have to be sure there is no > more events in the input pipeline. > Closing the input node before removing the led classes flushes the > pipeline and this prevents segfaults. > > Found with https://github.com/whot/fuzzydevice > Link: https://bugzilla.kernel.org/show_bug.cgi?id=197679 > > Cc: stable@vger.kernel.org > Signed-off-by: Benjamin Tissoires input_close_device does run synchronize_rcu() which we seem to have to process before freeing the rest indeed. Thus, Acked-by: Samuel Thibault (though AFAIK it doesn't apply on the mainline tree) > --- > drivers/input/input-leds.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c > index c86eb3d648bf..8aefcc186a02 100644 > --- a/drivers/input/input-leds.c > +++ b/drivers/input/input-leds.c > @@ -211,6 +211,7 @@ static void input_leds_disconnect(struct input_handle *handle) > int i; > > cancel_delayed_work_sync(&leds->init_work); > + input_close_device(handle); > > for (i = 0; i < leds->num_leds; i++) { > struct input_led *led = &leds->leds[i]; > @@ -219,7 +220,6 @@ static void input_leds_disconnect(struct input_handle *handle) > kfree(led->cdev.name); > } > > - input_close_device(handle); > input_unregister_handle(handle); > > kfree(leds); > -- > 2.14.3 >