lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 30 Mar 2021 16:44:48 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org
Subject: Re: [PATCH v2 2/7] USB: serial: xr: use a table for device-specific
 settings

On Wed, Mar 24, 2021 at 08:41:06AM +0100, Mauro Carvalho Chehab wrote:
> The same driver is used by a wide range of MaxLinear devices.
> 
> Other models are close enough to use the same driver, but they
> use a different register set.
> 
> So, instead of having the registers hardcoded at the driver,
> use a table. This will allow further patches to add support for
> other devices.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
> ---
>  drivers/usb/serial/xr_serial.c | 151 ++++++++++++++++++++++++---------
>  1 file changed, 113 insertions(+), 38 deletions(-)
 
>  static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)
>  {
> +	struct xr_port_private *port_priv;
> +
>  	/* Don't bind to control interface */
>  	if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 0)
>  		return -ENODEV;
>  
> +	port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
> +	if (!port_priv)
> +		return -ENOMEM;

For historical reasons, you cannot allocate memory in probe() directly
(unless using devres) or this can leak on later probe errors.

Instead interface-wide allocations are done in attach() and released in
release(), while port-specific allocations are done in port_probe() and
released in port_remove().

Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ