Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1879925ybc; Wed, 13 Nov 2019 05:50:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzyOqdOsEFhpjc3EgJIa+CO6+wCfVGgvkxUo1JNSGivoFSYLdzHagev0ku/kF9Whv0NPVJH X-Received: by 2002:a17:906:3495:: with SMTP id g21mr2868275ejb.190.1573653043376; Wed, 13 Nov 2019 05:50:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573653043; cv=none; d=google.com; s=arc-20160816; b=zw0wQ9I1IBZmtttVE/xqGxxviOoiT5CP7hKko5WHxNnnIHpWHPwkOpm8Ufv64bNh9O pz9h8VZ2vy7e7zwZX+FWbPWqi3MJRlhiWMt/2pCknR5ZkovCsb8LYOdLSH1Lx0m0CQwD 3ad2iuGgzMJgTrPCVjGSfdUUMJQoHchtKP3f8Peq50BpKClIO9lFhnvCQ+/+irtc+G3N kU0OZwkHrL1qLsYndQOkMxf0G7vgnKYAisE/cWFRKmPXhaipvkcTnqtjQEcBGhg9my2Q cOhHpdKfCkANLNAz1l6b5BVJSlpu3PPEJn3RSc5KC3Nydp4gG3xhbmAgWUsZnN6ulumS 9H5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Q6gp8Rnpzo7hfaOb045Ll6kBXwkiePhYfELtwB5uI7o=; b=YnbCC2qFH0Kd314m0xKnrj0y3ujxZYUL8joj2YQZTO8fsgTkZMaM9kcRF5Sps5pv7r qcpN5MUdmybYFPlL5yyHUi/YGPP2kV6xUfe8E694C6NJ2FOKVLeKLt3i31d5QvuINz/R cXXhbRyxuT7BEjIWV6IgFoLtZtdw+Sy4OQfBtfd9ruHZ/hhbWkqApOwf5Faa3zdnJSMO Qo0enTklEq6e0BxLR21xPMPrn+DX1205gLHs8/2JtYZGeZ78O5yQTbWqi47j+GaDimm3 QXK3LZg5ieHrIyma68KZdgKBui6MLAdxLao8y8gDOVYiUXTIvwhJr92PPWwkOkJfrLAv rg7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s40si1548946edd.233.2019.11.13.05.50.17; Wed, 13 Nov 2019 05:50:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbfKMNti (ORCPT + 99 others); Wed, 13 Nov 2019 08:49:38 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:47544 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbfKMNti (ORCPT ); Wed, 13 Nov 2019 08:49:38 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 68EB71C1250; Wed, 13 Nov 2019 14:49:36 +0100 (CET) Date: Wed, 13 Nov 2019 14:49:36 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Peter Chen , Felipe Balbi , Sasha Levin Subject: Re: [PATCH 4.19 093/125] usb: gadget: configfs: fix concurrent issue between composite APIs Message-ID: <20191113134935.GA20980@duo.ucw.cz> References: <20191111181438.945353076@linuxfoundation.org> <20191111181452.322265396@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" Content-Disposition: inline In-Reply-To: <20191111181452.322265396@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon 2019-11-11 19:28:52, Greg Kroah-Hartman wrote: > From: Peter Chen >=20 > [ Upstream commit 1a1c851bbd706ea9f3a9756c2d3db28523506d3b ] >=20 > We meet several NULL pointer issues if configfs_composite_unbind > and composite_setup (or composite_disconnect) are running together. > These issues occur when do the function switch stress test, the > configfs_compsoite_unbind is called from user mode by > echo "" to /sys/../UDC entry, and meanwhile, the setup interrupt > or disconnect interrupt occurs by hardware. The composite_setup > +++ b/drivers/usb/gadget/configfs.c > @@ -61,6 +61,8 @@ struct gadget_info { > bool use_os_desc; > char b_vendor_code; > char qw_sign[OS_STRING_QW_SIGN_LEN]; > + spinlock_t spinlock; > + bool unbind; > }; > =20 > static inline struct gadget_info *to_gadget_info(struct config_item *ite= m) > @@ -1244,6 +1246,7 @@ static int configfs_composite_bind(struct usb_gadge= t *gadget, > int ret; > =20 > /* the gi->lock is hold by the caller */ > + gi->unbind =3D 0; > cdev->gadget =3D gadget; Since variable is bool, I'd expect "=3D false" here? > + unsigned long flags; > =20 > /* the gi->lock is hold by the caller */ "is held". > cdev =3D get_gadget_data(gadget); > gi =3D container_of(cdev, struct gadget_info, cdev); > + spin_lock_irqsave(&gi->spinlock, flags); > + gi->unbind =3D 1; =3D true; > +static int configfs_composite_setup(struct usb_gadget *gadget, > + const struct usb_ctrlrequest *ctrl) > +{ > + struct usb_composite_dev *cdev; > + struct gadget_info *gi; > + unsigned long flags; > + int ret; > + > + cdev =3D get_gadget_data(gadget); > + if (!cdev) > + return 0; > + > + gi =3D container_of(cdev, struct gadget_info, cdev); > + spin_lock_irqsave(&gi->spinlock, flags); > + cdev =3D get_gadget_data(gadget); cdev already contains required value, why get it second time? (If it needs to be done under lock, comment might be useful...) Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --9amGYk9869ThD9tj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCXcwJ7wAKCRAw5/Bqldv6 8hTcAKCkZ8+lOfe0KoaldFtnuuwaU+hcAgCfUtdgELdKe9XSVUlkKviX4Tmx90Y= =M6Kj -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--