答复: [PATCH v7] usb: gadget: u_serial: Add null pointer check in gs_read_complete & gs_write_complete

From: 胡连勤
Date: Tue Aug 27 2024 - 05:27:14 EST


Hi Prashanth:

>> Considering that in some extreme cases, when the unbind operation is
>> being executed, gserial_disconnect has already cleared gser->ioport,
>> and the controller has not stopped & pullup 0, sys.usb.config is reset

>As mentioned by Michael earlier, avoid android specific (sys.usb.config) operations.
OK, I'll need to submit the description later.

>> and the bind operation will be re-executed, calling gs_read_complete,
>> which will result in accessing gser->iport, resulting in a null
>> pointer dereference, add a null pointer check to prevent this situation.
>>
>> Added a static spinlock to prevent gser->ioport from becoming null
>> after the newly added check.
>>
>> Unable to handle kernel NULL pointer dereference at

[...]
>>
>> Fixes: c1dca562be8a ("usb gadget: split out serial core")
>> Cc: stable@xxxxxxxxxxxxxxx
>> Signed-off-by: Lianqin Hu <hulianqin@xxxxxxxx>
>> ---
>> v7:
>> - Remove code comments
>> - Update the commit text
>> - Add the Fixes tag
>> - CC stable kernel
>> - Add serial_port_lock protection when checking port pointer
>> - Optimize code comments
> > - Delete log printing

> We usually indicate what had changed in each versions.
> v7: Remove code comments
> v6: xx
> v5: xx
> v4: xx
> v3: xx
> v2: Delete log printing
OK, I will modify the version information according to the above requirements, so that you can see the changes in each version more intuitively.

>> ---
>No need for this '---' here, just leave an empty line
I removed the "---" and changed it to a blank line.

>> drivers/usb/gadget/function/u_serial.c | 33
>> ++++++++++++++++++++++----
>> 1 file changed, 28 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/function/u_serial.c
>> b/drivers/usb/gadget/function/u_serial.c
>> index b394105e55d6..e43d8065f7ec 100644
>> --- a/drivers/usb/gadget/function/u_serial.c
>> +++ b/drivers/usb/gadget/function/u_serial.c
>> @@ -452,20 +452,43 @@ static void gs_rx_push(struct work_struct *work)

Thanks