lkml.org 
[lkml]   [2022]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 2/9] usb: typec: Add retimer handle to port
From
Date
On 7/8/22 12:21 PM, Greg Kroah-Hartman wrote:
[...]
>>> Similar to mux and orientation switch, add a handle for registered
>>> retimer to the port, so that it has handles to the various switches
>>> connected to it.
>>>
>>> Signed-off-by: Prashant Malani <pmalani@chromium.org>
>>> ---
>>>
>>> Changes since v2:
>>> - No changes.
>>>
>>> Changes since v1:
>>> - Relinquish retimer reference during typec_release.
>>>
>>> drivers/usb/typec/class.c | 9 +++++++++
>>> drivers/usb/typec/class.h | 1 +
>>> 2 files changed, 10 insertions(+)
>>>
>>> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
>>> index 9062836bb638..f08e32d552b4 100644
>>> --- a/drivers/usb/typec/class.c
>>> +++ b/drivers/usb/typec/class.c
>> [...]
>>> @@ -2249,6 +2251,13 @@ struct typec_port *typec_register_port(struct device *parent,
>>> return ERR_PTR(ret);
>>> }
>>>
>>> + port->retimer = typec_retimer_get(&port->dev);
>>> + if (IS_ERR(port->retimer)) {
>>> + ret = PTR_ERR(port->retimer);
>>> + put_device(&port->dev);
>>> + return ERR_PTR(ret);
>>
>> Why convert it to and fro, and not just return port->retimer?
>
> That would be a use-after-free as port might now be gone.

Ah, indeed!
It would also ensue an explicit pointer cast...

> thanks,
>
> greg k-h

MBR, Sergey

\
 
 \ /
  Last update: 2022-07-08 11:40    [W:0.064 / U:1.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site