]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ath10k: don't assume this is a PCI dev in generic code
authorBrian Norris <briannorris@chromium.org>
Fri, 2 Nov 2018 17:17:48 +0000 (10:17 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 6 Nov 2018 16:22:50 +0000 (18:22 +0200)
Not all devices using this driver are backed by a PCI device, so it's
not fair to assume 'to_pci_dev()' is valid. Fortunately, we only were
using this to convert straight back to a bare 'device', which means we
were only doing no-op pointer arithmetic, and not actually accessing
potentially out-of-bounds memory. But this is still bad practice.

Just use 'ar->dev' directly, since that's really all we're looking for.

Fixes: 209b2a68de76 ("ath10k: add platform regulatory domain support")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/mac.c

index 2b8c8bf80b0d9affd3b4ba417a2abc81db4efdd7..c5130fa264eb502a7957a4f06583971dbc1e27a4 100644 (file)
@@ -8317,7 +8317,6 @@ static u32 ath10k_mac_wrdd_get_mcc(struct ath10k *ar, union acpi_object *wrdd)
 
 static int ath10k_mac_get_wrdd_regulatory(struct ath10k *ar, u16 *rd)
 {
-       struct pci_dev __maybe_unused *pdev = to_pci_dev(ar->dev);
        acpi_handle root_handle;
        acpi_handle handle;
        struct acpi_buffer wrdd = {ACPI_ALLOCATE_BUFFER, NULL};
@@ -8325,7 +8324,7 @@ static int ath10k_mac_get_wrdd_regulatory(struct ath10k *ar, u16 *rd)
        u32 alpha2_code;
        char alpha2[3];
 
-       root_handle = ACPI_HANDLE(&pdev->dev);
+       root_handle = ACPI_HANDLE(ar->dev);
        if (!root_handle)
                return -EOPNOTSUPP;