Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753739AbdDLOaG (ORCPT ); Wed, 12 Apr 2017 10:30:06 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:53118 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752458AbdDLOaE (ORCPT ); Wed, 12 Apr 2017 10:30:04 -0400 Date: Wed, 12 Apr 2017 10:30:02 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Felipe Balbi cc: Greg KH , Roger Quadros , , USB list , Kernel development list Subject: Re: [PATCH v3 1/3] usb: udc: allow adding and removing the same gadget device In-Reply-To: <87wpaqb1vb.fsf@linux.intel.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1291 Lines: 39 On Wed, 12 Apr 2017, Felipe Balbi wrote: > >> Maybe... But I can't shake the feeling that Greg KH would strongly > >> disagree. Hasn't he said, many times in the past, that any dynamically > >> allocated device structure _must_ have a real release routine? > >> usb_udc_nop_release() doesn't qualify. > > > > Aw, I wanted to publically yell at someone like the kernel documentation > > says I am allowed to do so if anyone does such a foolish thing :) > > heh, except that we're not dynamically allocating struct device at all > :-) Here's what we have for most UDCs (net2280.c included): > > struct my_udc { > struct gadget gadget; > [...] > }; > > probe() > { > struct my_udc *u; > > u = kzalloc(sizeof(*u), GFP_KERNEL); > [...] > return 0; > } Allow me to point out that the struct device is embedded inside the struct gadget (actually struct usb_gadget) embedded inside the struct my_udc, which _is_ dynamically allocated. Therefore the struct device is located in dynamically allocated memory. > Now, if this kzalloc() would be replaced with devm_kzalloc() wouldn't > this result on a functionally equivalent execution to the patch I > proposed above? It would, and it would be equally wrong. Alan Stern