From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758681AbcDHPT6 (ORCPT ); Fri, 8 Apr 2016 11:19:58 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:36992 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1758602AbcDHPTq (ORCPT ); Fri, 8 Apr 2016 11:19:46 -0400 Date: Fri, 8 Apr 2016 11:19:45 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Michal Nazarewicz cc: Felipe Balbi , , , Ivaylo Dimitrov , Subject: Re: [PATCHv2] usb: f_mass_storage: test whether thread is running before starting another In-Reply-To: <1460103851-16102-1-git-send-email-mina86@mina86.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 8 Apr 2016, Michal Nazarewicz wrote: > When binding the function to usb_configuration, check whether the thread > is running before starting another one. Without that, when function > instance is added to multiple configurations, fsg_bing starts multiple > threads with all but the latest one being forgotten by the driver. This > leads to obvious thread leaks, possible lockups when trying to halt the > machine and possible more issues. > > This fixes issues with legacy/multi¹ gadget as well as configfs gadgets > when mass_storage function is added to multiple configurations. > > This change also simplifies API since the legacy gadgets no longer need > to worry about starting the thread by themselves (which was where bug > in legacy/multi was in the first place). > > N.B., this patch doesn’t address adding single mass_storage function > instance to a single configuration twice. Thankfully, there’s no > legitimate reason for such setup plus, if I’m not mistaken, configfs > gadget doesn’t even allow it to be expressed. > > ¹ I have no example failure though. Conclusion that legacy/multi has > a bug is based purely on me reading the code. > > Signed-off-by: Michal Nazarewicz > Tested-by: Ivaylo Dimitrov > Cc: Alan Stern > Cc: stable@vger.kernel.org Acked-by: Alan Stern