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] [day] [month] [year] [list]
Message-id: <55F93B26.2000401@samsung.com>
Date:	Wed, 16 Sep 2015 11:49:26 +0200
From:	Robert Baldyga <r.baldyga@...sung.com>
To:	Krzysztof Opasiak <k.opasiak@...sung.com>, balbi@...com
Cc:	gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org, b.zolnierkie@...sung.com,
	m.szyprowski@...sung.com, andrzej.p@...sung.com
Subject: Re: [PATCH 05/26] usb: gadget: f_ecm: eliminate abuse of ep->driver
 data

On 09/15/2015 05:45 PM, Krzysztof Opasiak wrote:
> 
> 
> On 09/15/2015 04:26 PM, Robert Baldyga wrote:
>> Since ep->driver_data is not used for endpoint claiming, neither for
>> enabled/disabled state storing, we can reduce number of places where
>> we read or modify it's value, as now it has no particular meaning for
>> function or framework logic.
>>
>> In case of f_ecm, ep->driver_data was used only for endpoint claiming
>> and marking endpoints as enabled, so we can simplify code by reducing
>> it.
>>
>> Signed-off-by: Robert Baldyga <r.baldyga@...sung.com>
> 
> ( ... )
> 
>>
>> @@ -820,14 +811,6 @@ fail:
>>   		usb_ep_free_request(ecm->notify, ecm->notify_req);
>>   	}
>>
>> -	/* we might as well release our claims on endpoints */
>> -	if (ecm->notify)
>> -		ecm->notify->driver_data = NULL;
>> -	if (ecm->port.out_ep)
>> -		ecm->port.out_ep->driver_data = NULL;
>> -	if (ecm->port.in_ep)
>> -		ecm->port.in_ep->driver_data = NULL;
>> -
>>   	ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
>>
>>   	return status;
>>
> 
> You have done this in almost all functions but personally I'm really 
> concern about this change.
> 
> By convention function should free all allocated resources when exiting 
> with non 0 code. Endpoints are some kind of resources, they are 
> "allocated" using usb_ep_autoconfig() and if you are not going to use 
> them because error occurred you should free the using 
> usb_ep_autoconfig_release(). Moreover, you have done this in source sink 
> function so why not do this in all other?


Well, if bind() returns an error code, composite calls
usb_ep_autoconfig_reset() anyway, so manual endpoint releasing in error
path isn't necessary. We can compare the way it works with devm_*
functions family - you don't need to care about resource lifetime as
it's managed for you.

The function f_sourcesink is a bit different, because it can work with
two different endpoint configurations {bulk-in, bulk-out} or {bulk-in,
bulk-out, iso-in, iso-out}. When bulk endpoints are obtained
successfully it tries to get iso endpoints, but if one if them is not
available it releases previously obtained iso and ends with success. In
such case it simply starts in bulk-only configuration.

Best regards,
Robert
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ