Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deepin-Kernel-SIG] [FROMLIST] [linux 6.6-y] Bluetooth: btusb: Add NULL check for data in btusb_suspend #546

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

opsiff
Copy link
Member

@opsiff opsiff commented Dec 31, 2024

When performing warm boot tests with an MT7920 device, we encounter NULL pointer dereferences with failure rate 5/30. The crash occurs during device suspend when btusb attempts to access data->hdev where data is NULL. This may happen due to a race condition between PM suspend and device disconnect. The root cause needs further investigation.

BUG: kernel NULL pointer dereference, address: 0000000000000000
Workqueue: pm pm_runtime_work
RIP: 0010:btusb_suspend+0x1d/0x1d0 [btusb]

Add a NULL check for data and return -ENODEV in this case to prevent the NULL pointer dereference. This indicates that the device is no longer available, which is appropriate when the driver's private data is missing.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

When performing warm boot tests with an MT7920 device, we encounter
NULL pointer dereferences with failure rate 5/30. The crash occurs
during device suspend when btusb attempts to access data->hdev where
data is NULL. This may happen due to a race condition between PM suspend
and device disconnect. The root cause needs further investigation.

BUG: kernel NULL pointer dereference, address: 0000000000000000
Workqueue: pm pm_runtime_work
RIP: 0010:btusb_suspend+0x1d/0x1d0 [btusb]

Add a NULL check for data and return -ENODEV in this case to prevent
the NULL pointer dereference. This indicates that the device is no
longer available, which is appropriate when the driver's private data
is missing.

Signed-off-by: En-Wei Wu <en-wei.wu@canonical.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • btusb_suspend函数中新增了对data指针的检查,确保在data为空时返回-ENODEV错误码。

是否建议立即修改:

  • 否,因为提交的代码已经添加了对data指针的空指针检查,这是一个合理的改动,可以防止空指针解引用的问题。但是,需要确保这个改动不会引入新的问题,比如是否所有调用btusb_suspend的地方都已经处理了-ENODEV错误码的情况。

其他建议:

  • 确保所有调用btusb_suspend的地方都已经处理了-ENODEV错误码,以避免潜在的运行时错误。
  • 考虑添加注释说明为什么在data为空时返回-ENODEV,以便其他开发者理解这一逻辑。
  • 如果data指针的空检查是必要的,建议在整个btusb.c文件中查找其他可能存在类似问题的代码,并进行相应的检查和修改。

@opsiff opsiff merged commit 9f3eafe into linux-6.6.y Dec 31, 2024
7 of 10 checks passed
@opsiff opsiff changed the title FROMLIST: Bluetooth: btusb: Add NULL check for data in btusb_suspend [Deepin-Kernel-SIG] [FROMLIST] [linux 6.6-y] Bluetooth: btusb: Add NULL check for data in btusb_suspend Jan 2, 2025
@opsiff opsiff deleted the btusb-null branch January 2, 2025 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants