From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752053AbbCKBx4 (ORCPT ); Tue, 10 Mar 2015 21:53:56 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:46017 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbbCKBxy (ORCPT ); Tue, 10 Mar 2015 21:53:54 -0400 Date: Tue, 10 Mar 2015 20:53:11 -0500 From: Felipe Balbi To: Ruslan Bilovol CC: Alan Stern , "Balbi, Felipe" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Krzysztof Opasiak , Peter Chen , "gregkh@linuxfoundation.org" , Andrzej Pietrasiewicz Subject: Re: [PATCHv3 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers Message-ID: <20150311015311.GC21726@saruman.tx.rr.com> Reply-To: References: <1424207877-30915-6-git-send-email-ruslan.bilovol@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="f+W+jCU1fRNres8c" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --f+W+jCU1fRNres8c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Wed, Mar 11, 2015 at 02:21:38AM +0200, Ruslan Bilovol wrote: > >> @@ -469,6 +488,16 @@ int usb_gadget_unregister_driver(struct usb_gadge= t_driver *driver) > >> break; > >> } > >> > >> + if (ret) { > >> + struct usb_gadget_driver *tmp; > >> + > >> + list_for_each_entry(tmp, &gadget_driver_pending_list, pe= nding) > >> + if (tmp =3D=3D driver) { > >> + list_del(&driver->pending); > >> + ret =3D 0; > >> + break; > >> + } > >> + } > > > > If you add the list_init and list_del_init above, this loop won't be > > needed. You can just call list_del. >=20 > I disagree with this. This function is externally visible and we can't > guarantee that some buggy code will not call it with uninitialized > 'pending' list_head. For example, if it never called usb_gadget_probe_dri= ver() > but calls usb_gadget_unregister_driver(). those cases deserve to suffer a really painfull and horrible death by means of a kernel oops ;-) Sure, defensive programming and all, but at some point we need to consider certain cases ridiculous and just not do anything about them, so people know that they need more coffee and attention while writing code. --=20 balbi --f+W+jCU1fRNres8c Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJU/6AHAAoJEIaOsuA1yqREZjgP/iJZ3bKJe9wiZ/jeyIz8DpK7 NddoJArus2T48Qlau2ksbHlqpCyjwaiPaPIhZhZW65F904qRYx1APgfj7hdPKEco tsG4UVfTtWEVrvPM6oHsrHvYsTYEDeDQ0RiOE9T1xhTnWam9kpCR8kuOPAo4XcxE 8QFt6kCs1GXq008jq3GS0hUOrPSdMCkZIpe9Z89Q4QAVrMs5wEjUarRQa/hwZvQH dOK8eN4IoRTZWWhBZoPE2XxwjVWGbbR9Q6gN5qYu85t5gRnFgqMlWLLPYqw+vKRL Tl/QKiLGSDHpBRS1sw4dhzxC5lI4NxZVmmZ4TSZsm7C139W9ThCeA8huus/ysPSn kyQbFtrH/T8sOm/8J4JAaXFdL6Q4VdhVcqrAbIsyyH3RCE1gWIS9D4krglTDhl+O HYbDibhnVKZJiZqV5yEqQOa5k086ZqFJMRyv7VZ0WPd7EnVZLZdiHgdyM0l+zTIQ 9uYcyimZvPeRzLyA1oOMXHpj5SVlQGiNtMfMNY6txyuGMEI70gaYo0UZwmE82PNI XaavNkVjXEG/5WzOFs0BESup+4/mJVPLGaMG+9wl7IwUU9+4dYmNGcJq9SNCfpuf WxwTGDOO9VeLn2wmgHpPgXvzXyzs0mcP41Olc8mGULw/HRjpFmPPQCn1cR1rPB1A xNE/e5az63vrJ3A5QTMA =309o -----END PGP SIGNATURE----- --f+W+jCU1fRNres8c--