There may be a potential null pointer risk if offset value is
less than 0 when doing memcmp in btmtk_process_coredump().
Checking offset is valid before doing memcmp.
Signed-off-by: Chris Lu <[email protected]>
Co-developed-by: Sean Wang <[email protected]>
---
v2: fix typo
---
drivers/bluetooth/btmtk.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 786f775196ae..0f290430ae0e 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -370,7 +370,7 @@ EXPORT_SYMBOL_GPL(btmtk_register_coredump);
int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb)
{
struct btmediatek_data *data = hci_get_priv(hdev);
- int err;
+ int err, offset;
if (!IS_ENABLED(CONFIG_DEV_COREDUMP))
return 0;
@@ -392,15 +392,15 @@ int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb)
if (err < 0)
break;
data->cd_info.cnt++;
+ offset = skb->len - sizeof(MTK_COREDUMP_END);
/* Mediatek coredump data would be more than MTK_COREDUMP_NUM */
- if (data->cd_info.cnt > MTK_COREDUMP_NUM &&
- skb->len > sizeof(MTK_COREDUMP_END) &&
- !memcmp((char *)&skb->data[skb->len - sizeof(MTK_COREDUMP_END)],
- MTK_COREDUMP_END, sizeof(MTK_COREDUMP_END) - 1)) {
- bt_dev_info(hdev, "Mediatek coredump end");
- hci_devcd_complete(hdev);
- }
+ if (data->cd_info.cnt > MTK_COREDUMP_NUM && offset > 0)
+ if (!memcmp((char *)&skb->data[offset], MTK_COREDUMP_END,
+ sizeof(MTK_COREDUMP_END) - 1)) {
+ bt_dev_info(hdev, "Mediatek coredump end");
+ hci_devcd_complete(hdev);
+ }
break;
}
--
2.18.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=764635
---Test result---
Test Summary:
CheckPatch FAIL 0.98 seconds
GitLint PASS 0.34 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 33.41 seconds
CheckAllWarning PASS 37.07 seconds
CheckSparse PASS 41.83 seconds
CheckSmatch PASS 112.94 seconds
BuildKernel32 PASS 32.24 seconds
TestRunnerSetup PASS 494.86 seconds
TestRunner_l2cap-tester PASS 23.46 seconds
TestRunner_iso-tester PASS 42.33 seconds
TestRunner_bnep-tester PASS 10.63 seconds
TestRunner_mgmt-tester PASS 220.73 seconds
TestRunner_rfcomm-tester PASS 16.10 seconds
TestRunner_sco-tester PASS 17.10 seconds
TestRunner_ioctl-tester PASS 18.45 seconds
TestRunner_mesh-tester PASS 13.72 seconds
TestRunner_smp-tester PASS 14.62 seconds
TestRunner_userchan-tester PASS 11.37 seconds
IncrementalBuild PASS 30.90 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v2] Bluetooth: btmtk: Fix null pointer when processing coredump
WARNING: Co-developed-by: must be immediately followed by Signed-off-by:
#82:
Co-developed-by: Sean Wang <[email protected]>
---
total: 0 errors, 1 warnings, 30 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13309551.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
---
Regards,
Linux Bluetooth