Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752766AbbKXC15 (ORCPT ); Mon, 23 Nov 2015 21:27:57 -0500 Received: from mail-by2on0111.outbound.protection.outlook.com ([207.46.100.111]:29973 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752566AbbKXC1z (ORCPT ); Mon, 23 Nov 2015 21:27:55 -0500 Authentication-Results: spf=permerror (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; samsung.com; dkim=none (message not signed) header.d=none;samsung.com; dmarc=none action=none header.from=freescale.com; Date: Tue, 24 Nov 2015 10:24:50 +0800 From: Peter Chen To: Alan Stern CC: Marek Szyprowski , , , Ruslan Bilovol , Bartlomiej Zolnierkiewicz Subject: Re: [PATCH v7 4/4] usb: gadget: udc-core: independent registration of gadgets and gadget drivers Message-ID: <20151124022449.GA25698@shlinux2> References: <1448268998-4682-5-git-send-email-m.szyprowski@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC015;1:G7f1jgEosNw8t+WU6pPPBzIp+xjPvCyAOU5GLrWuKgQORQyJUW3UlaYconYDGO/lwgUV+jqW4al30Ye+VmhtJ3YWwyCYop27oUqnl6aBrGJ3B8KjQ89NoBmqVM7bsdtyN+6BtA91q3OlyXs5p25JvV9JZoUyV2spm28mWJeCtc1dkA4lBu8uk10WBqbRZdRLr+Y0jLIf4kDnbHCZL1PvIq1SF/7l69zAGlqf8e+tZAe63Vgi7lFdn4NDV+dTG9l1rb4eZd486Uq1JsS3zbOvw2hUOrzuEpVBH1mAGfkX01DSQ03O6GIIW9OAt5DdNaqEfna1sKkx2KqIhqkZxirh1cnydjwbQaEdc6rrIgdPE8bQvcQFshdTDWhPnwQ9HrmVCEdzssgF/imuOV+JAXSfSqUfa5KCKpNWlGMfeJSl5haWWon/j1cAMi9v7BXXqyks X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1060300003)(448002)(24454002)(189002)(199003)(50466002)(106466001)(87936001)(4290100001)(5007970100001)(2171001)(54356999)(11100500001)(76176999)(77096005)(83506001)(110136002)(110436001)(85326001)(5001920100001)(2950100001)(5001960100002)(33716001)(6806005)(92566002)(50986999)(19580405001)(104016004)(47776003)(86362001)(69596002)(4001350100001)(33656002)(81156007)(97736004)(5008740100001)(19580395003)(97756001)(606003)(46406003)(23726003);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB554;H:az84smr01.freescale.net;FPR:;SPF:PermError;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB554;2:3m/NKwhWLpLguNo4wvoSIvk8DgczSGuACLwafMlCW1lzCOPijTeFDzSV5c5Nn1syPt1BLuzFLkgG/80RTGOpNNslCL0n3+UgrNBj5sFUzRJ6nFFozQq5nvYyRIXPlrJvEinhIT8j5zVdWB3sNyvvYg==;3:aIFP5lPOhgiUnIe83d0259yZvaB1z2gzro846WAnolIKrWvELa2I0IKQD6ki9UzIQI67vtK9unFK1wFQAvUE3UOysqu2lYtLa4myV7WTrVVeVn3yLpVayBgIZ56MQWyjrShaEfWE74/7H0gKcbqQZsSCKgwkTPz3jS9gGNch0AJ8WBLbkP4fLwy5dUSBaDfhU0lMY790ALcgjqYdUAaV+eVTZJhqvzsTqpAHlrYiadk=;25:RstDruNOQ+QH9uNHaCBFz/TmzJycICdYcf9uSj2rF0n2dcz6fN2VUgZi7+AQI1egW293MNU7jdeOsTiRJSWv+mSug+1PvlHb44DflhkbQBenC2yHT2dvVPSxN/vMzjSHispwL5NGJt+AgLpa9HxR8PvNTu/evSmwuVnaEwl2SESUOsEDJtTuEgR7uKvLcdJES8sgQ+k8IKlkDIYB0NeuIpBxK4kYk8DlU90FMIolWCrD54XWt11EYk0b2l4k8S9v X-Microsoft-Antispam: UriScan:;BCL:1;PCL:0;RULEID:;SRVR:BY2PR03MB554; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB554;20:JsBasaqblDemy8/VtDSZaqebJnysDohAbjtQ3l+zISn6I0uLM/x7GXulRR6rxDOZiqebmfhdohpspzsG4n4UEPY8RxC7tJ575gn0vAFwmoLO8hCCANLgPv/caC+AMnGB+VXTtA68E5nPK+7H7ywaXlprUWhS0pG4IsyAN0wsOfWe4TnuPFo5PeJAcjYcDxuMpYas0vYZ2rhzVn9s+Z1tmEPnEH6mB21ooWqwgOXV6oefyACC3EJ8sxr82Y1wj5ArxpJ9xJhunUngK+k6E/mjTVB0RlagONH/wpcvYybSw8slVpBgW36+MYG4TyGz3q3iwsTTPPjsl2lx/UPm4SvOaWgf7MBqlwBEtiqFupqzMG0=;4:77O+ruRouNRwQ+LRtgRsG7KxPFdpN8xWxMoDj7VVEo+xdUn4G7x76NxUvjxaxCjB2NJNjBjnQZog2Dc/+MkKhl5igz+0zf5KaimpmaKL4rvOTWknnLSdaVucXvbXakJSqJ7zuc30gOK+Lvazp69HzQ1jrWVP1S45MmcowBllHJVTm8r0gwYqRW1RDWdxz6lk2QrmYFoTsxSPy+p+tEq3Btn9d5HzbJinCcJfR3R6vSyVcc9l3Zg42k3EcYUUIkgkaks/wTlXLtkykuwu00FZSS7tJeqMEFD8UvTawzJotMq+0oi58pPbhArwYiU5i5NKUO1NSI2IlFJ7k2gwETyhMdAnTotrAmnDkChdrvPx2q3oFc2MtcpQZrEJg/T1p0VnLjgKl07G3fBxq3sHDiM1T1R+861lJD9C3exBwDXYZWMdLeN3Lij5trf1AG10tjdV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:1;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(1201001)(10201501046)(3002001);SRVR:BY2PR03MB554;BCL:1;PCL:0;RULEID:;SRVR:BY2PR03MB554; X-Forefront-PRVS: 0770F75EA9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB554;23:791IyvuBwLTT0tnqWae0JAriIEX/jgUSyADgpyS+it?= =?us-ascii?Q?OfUR6s1mIDsROH/JI21XZcynXWfXyqnUODssTQ30C3pUy5QVtHNdfrEH0PzX?= =?us-ascii?Q?I+OQj7Dwr8eAVYemNvfi9cpOUh+J5p8hFR6bsle79b/rvbGzffvIHv9BkUX1?= =?us-ascii?Q?GfhQjzXpcGcAJxXHS4ZSr/MO0dHDxt1gM17Vdsm0pFxjv6xp1MCcWeilcsMq?= =?us-ascii?Q?dUvEtPaijqteHvUd2M1RDaClMFZHHXhGsXH5JTwj15fRSJALb9u7JInzaSBp?= =?us-ascii?Q?kB2jwxpHkdy1N3YSWuxDM93PgriyFCYhFy8FQjrA+I4sITQtaDuWRYkUkikZ?= =?us-ascii?Q?eNCNJUxAUvXNLv1UupSVuEhRrhOZ4x/COn8YubPop7kC/V20fcQa/agrlZnl?= =?us-ascii?Q?DT5Wy2Qi+6JR7sJn2/F8GqvPf/eCnB235COLduIm9RTUXPWqR9EQmw6f8N85?= =?us-ascii?Q?blv308HW7efhZMpMkRQBQiVjuPsHNzJtZ/hmJ48ffczKgupm9jnBiGS5WcGq?= =?us-ascii?Q?G3mWu8imzdGWtZtWvawUrDkri2T/vEEyeCn/9UOKlXJkNpgNce8+RIKGDvN0?= =?us-ascii?Q?YeKaY5UyqUZrnB23BlRGng6/NcTuFp/qbDBwpKFDbj7j0L4kJ+Y0xYZJaQWr?= =?us-ascii?Q?U074kCTX2TXPAaLno2bLkrBR/NAjqCF1nLMrrpXFrIsfnAmrQWO7/1vT0Lvq?= =?us-ascii?Q?eI+vKh+GuPaVXRdogVrzvVrrL9yxOR/ziP94hKSGnJS9iC6v7l8DNLPThuI/?= =?us-ascii?Q?gJIJSiewMkXvrXnz6+FKhSmOWBdeNUAdQbjS7BJAKGkMbpIcnixHMXJmi6pk?= =?us-ascii?Q?TEGGskEtUsYOfrHh2zOKuQFIfkrI6MjM+3nZdcnlhZA6I7YAJ6znPsXsiMzS?= =?us-ascii?Q?Iq4ujkLFfTMt9CytjiW5taCPCCbByv3IdIEtJGahnSCbx61JRLw3RzPT9BDj?= =?us-ascii?Q?NcIbxfTryoZaWHOfAA9BrXniobWxye8cHqeQ0uSL4hZp/Qrlp5GLUIu7iscC?= =?us-ascii?Q?hpyTlv9Tik4t4vYXTKUFG8avdbdazvnsuwmrG09fqiBX+b+MqdldSAobudRX?= =?us-ascii?Q?zlXOAuqJ8TFGWG6b5G8rfqIcLVLkRf+uVG3KJA6mqCFN8qv4K7GavjiwoVVj?= =?us-ascii?Q?OJbFTkHx14MaQb65XI0Tv98XMhKNCu6YlK+1VEROZBzF7cyiNCQQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB554;5:xAnPJxwcqIRbZVxLu5vPjcvp+LbyLcFf8B3JPFkKd7ailoCE4XYHDdXr1mBMSP5TntgNXLi3Pp4dHnM/5FlRJlFqpbUU15EuPdt3anpBGdj8MN4V9X08GTegNgIvNrMqt42HQC4UOgIGchI81hcdwg==;24:oXiKYr5ZaQPbVAZgM+UPk5rhcSXvo+bcvHTpPwNmHrPPtnTPPrMoG9+KQpUmVrdJp/RjSwimwcoyAdE75wE6wflDw2JNiVauP19lj+Ev3F8= SpamDiagnosticOutput: 1:5 SpamDiagnosticMetadata: 00000000%2D0000%2D0000%2D0000%2D000000000000 SpamDiagnosticMetadata: 1 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2015 02:27:52.1315 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB554 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2676 Lines: 72 On Mon, Nov 23, 2015 at 10:32:53AM -0500, Alan Stern wrote: > On Mon, 23 Nov 2015, Marek Szyprowski wrote: > > > From: Ruslan Bilovol > > > > Change behavior during registration of gadgets and > > gadget drivers in udc-core. Instead of previous > > approach when for successful probe of usb gadget driver > > at least one usb gadget should be already registered > > use another one where gadget drivers and gadgets > > can be registered in udc-core independently. > > > > Independent registration of gadgets and gadget drivers > > is useful for built-in into kernel gadget and gadget > > driver case - because it's possible that gadget is > > really probed only on late_init stage (due to deferred > > probe) whereas gadget driver's probe is silently failed > > on module_init stage due to no any UDC added. > > > > Also it is useful for modules case - now there is no > > difference what module to insert first: gadget module > > or gadget driver one. > > > > Tested-by: Maxime Ripard > > Signed-off-by: Ruslan Bilovol > > [simplified code as requested by Alan Stern and Felipe Balbi, > > fixed checkpatch issues] > > Signed-off-by: Marek Szyprowski > > Tested-by: Peter Chen > > I missed this the last time through... > > > @@ -403,6 +408,18 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, > > usb_gadget_set_state(gadget, USB_STATE_NOTATTACHED); > > udc->vbus = true; > > > > + /* pick up one of pending gadget drivers */ > > + list_for_each_entry(driver, &gadget_driver_pending_list, pending) { > > + if (!driver->udc_name || strcmp(driver->udc_name, > > + dev_name(&udc->dev)) == 0) { > > + ret = udc_bind_to_driver(udc, driver); > > + if (ret) > > + goto err4; > > + list_del(&driver->pending); > > This has to be list_del_init(). And somewhere in > usb_gadget_probe_driver() you need to do > INIT_LIST_HEAD(&driver->pending). > > > @@ -577,6 +596,10 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) > > break; > > } > > > > + if (ret) { > > + list_del(&driver->pending); > > Otherwise this will cause a crash or corrupt some random area of > memory. > Alan, would you please explain more what use case will cause memory corruption for above code? -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/