linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: mt76: mt7921: fix error code of return in mt7921_acpi_read
@ 2023-01-16 15:22 Aaron Ma
  2023-01-16 15:41 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Aaron Ma @ 2023-01-16 15:22 UTC (permalink / raw)
  To: nbd, lorenzo, ryder.lee, shayne.chen, sean.wang, kvalo, davem,
	edumazet, kuba, pabeni, matthias.bgg, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel, aaron.ma

Kernel NULL pointer dereference when ACPI SAR table isn't implemented well.
Fix the error code of return to mark the ACPI SAR table as invalid.

[    5.077128] mt7921e 0000:06:00.0: sar cnt = 0
[    5.077381] BUG: kernel NULL pointer dereference, address:
0000000000000004
[    5.077630] #PF: supervisor read access in kernel mode
[    5.077883] #PF: error_code(0x0000) - not-present page
[    5.078138] PGD 0 P4D 0
[    5.078398] Oops: 0000 [#1] PREEMPT SMP NOPTI
[    5.079202] RIP: 0010:mt7921_init_acpi_sar+0x106/0x220
[mt7921_common]
...
[    5.080786] Call Trace:
[    5.080786]  <TASK>
[    5.080786]  mt7921_register_device+0x37d/0x490 [mt7921_common]
[    5.080786]  mt7921_pci_probe.part.0+0x2ee/0x310 [mt7921e]
[    5.080786]  mt7921_pci_probe+0x52/0x70 [mt7921e]
[    5.080786]  local_pci_probe+0x47/0x90
[    5.080786]  pci_call_probe+0x55/0x190
[    5.080786]  pci_device_probe+0x84/0x120

Fixes: f965333e491e ("mt76: mt7921: introduce ACPI SAR support")
Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
---
 drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c b/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c
index 47e034a9b003..ed9241d4aa64 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c
@@ -33,14 +33,17 @@ mt7921_acpi_read(struct mt7921_dev *dev, u8 *method, u8 **tbl, u32 *len)
 	    sar_root->package.elements[0].type != ACPI_TYPE_INTEGER) {
 		dev_err(mdev->dev, "sar cnt = %d\n",
 			sar_root->package.count);
+		ret = -EINVAL;
 		goto free;
 	}
 
 	if (!*tbl) {
 		*tbl = devm_kzalloc(mdev->dev, sar_root->package.count,
 				    GFP_KERNEL);
-		if (!*tbl)
+		if (!*tbl) {
+			ret = -ENOMEM;
 			goto free;
+		}
 	}
 	if (len)
 		*len = sar_root->package.count;
@@ -52,9 +55,9 @@ mt7921_acpi_read(struct mt7921_dev *dev, u8 *method, u8 **tbl, u32 *len)
 			break;
 		*(*tbl + i) = (u8)sar_unit->integer.value;
 	}
-free:
 	ret = (i == sar_root->package.count) ? 0 : -EINVAL;
 
+free:
 	kfree(sar_root);
 
 	return ret;
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] wifi: mt76: mt7921: fix error code of return in mt7921_acpi_read
  2023-01-16 15:22 [PATCH] wifi: mt76: mt7921: fix error code of return in mt7921_acpi_read Aaron Ma
@ 2023-01-16 15:41 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2023-01-16 15:41 UTC (permalink / raw)
  To: Aaron Ma
  Cc: nbd, lorenzo, ryder.lee, shayne.chen, sean.wang, davem, edumazet,
	kuba, pabeni, matthias.bgg, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel

Aaron Ma <aaron.ma@canonical.com> writes:

> Kernel NULL pointer dereference when ACPI SAR table isn't implemented well.
> Fix the error code of return to mark the ACPI SAR table as invalid.
>
> [    5.077128] mt7921e 0000:06:00.0: sar cnt = 0
> [    5.077381] BUG: kernel NULL pointer dereference, address:
> 0000000000000004
> [    5.077630] #PF: supervisor read access in kernel mode
> [    5.077883] #PF: error_code(0x0000) - not-present page
> [    5.078138] PGD 0 P4D 0
> [    5.078398] Oops: 0000 [#1] PREEMPT SMP NOPTI
> [    5.079202] RIP: 0010:mt7921_init_acpi_sar+0x106/0x220
> [mt7921_common]
> ...
> [    5.080786] Call Trace:
> [    5.080786]  <TASK>
> [    5.080786]  mt7921_register_device+0x37d/0x490 [mt7921_common]
> [    5.080786]  mt7921_pci_probe.part.0+0x2ee/0x310 [mt7921e]
> [    5.080786]  mt7921_pci_probe+0x52/0x70 [mt7921e]
> [    5.080786]  local_pci_probe+0x47/0x90
> [    5.080786]  pci_call_probe+0x55/0x190
> [    5.080786]  pci_device_probe+0x84/0x120
>
> Fixes: f965333e491e ("mt76: mt7921: introduce ACPI SAR support")
> Signed-off-by: Aaron Ma <aaron.ma@canonical.com>

Felix, if this is ok should this go to v6.2?

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-16 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 15:22 [PATCH] wifi: mt76: mt7921: fix error code of return in mt7921_acpi_read Aaron Ma
2023-01-16 15:41 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).