From patchwork Wed Oct 10 09:29:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 148546 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp617386lji; Wed, 10 Oct 2018 02:30:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV60KF7+7znqePG/FwhYW3ZVyr2B693CHXvhQKHCkbvILq/nnMJ3mppxl8pYxx63HA5AxxQBk X-Received: by 2002:a65:4145:: with SMTP id x5-v6mr4826357pgp.309.1539163801450; Wed, 10 Oct 2018 02:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539163801; cv=none; d=google.com; s=arc-20160816; b=rVY44L0DJ5QBq61x5qOoOnQW9t71mzArEmAgSsmrm2/9rWT8cf4eZ2diCq/mtl1uqJ nToV9XBElliU/e40bWv/ExuyuiiP8jAGQbN0NSR6mAsLbA0DbhTOpYnBRkO7JXyVyTzI fYKEX239daZWNkUDOWzMTxPq3/ep3ZF58RTuvWng10UWiHBLNeg0fB9abcIp4PhHQ45i mxiPp99tFX5Eg7tRU6T41QRrIJ7A7SNzlzuJg89Q9vW+r5g3jwf4+O2nw0zLLevF9Ms6 wM41Yg027FHR6ZN2pGWQMNepeicsLjJKNb7UR7ZJNBjK5+I36F1idaC4d884wmNdFHoD YS2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=VAY8GX4ta6JXyQAYfpeQVycPtRT2uthkiW7mRzYrSgc=; b=Eln+FGZq65jWE0XBHVVSQasjWHIwAmMwOeMeAcgYhkDkohNsV71xHfpAdg9kzK+wvI Ml796HdFz5I68ServZbn5bdNsF5Msaw1k2QcLtdluEjE8Qp1eKuVpNJ4ZUN9909BaFCZ KmFzbnmevSrLmlD+caJOcgChX5mVN7hA0t10ngGVNIn33ns+lIe8sd/Mx0hLdytD9MlF n7RJcWlaKt5SGskWxjcDpbLJSUREOv7/flv0YNtIhgYcnu8atTw8H6yiC6sGLICcY/gH FkWWX6eFfbQsZUo7lIgAfSa9pu+HaxWWnjKUSDbszrWhJxplOngS7ykB4pDSeEYaf1VE HIMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g9YiX0lk; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si27119281pfd.102.2018.10.10.02.30.01; Wed, 10 Oct 2018 02:30:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g9YiX0lk; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726827AbeJJQvT (ORCPT + 14 others); Wed, 10 Oct 2018 12:51:19 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:34097 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbeJJQvS (ORCPT ); Wed, 10 Oct 2018 12:51:18 -0400 Received: by mail-pl1-f195.google.com with SMTP id f18-v6so2263528plr.1 for ; Wed, 10 Oct 2018 02:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VAY8GX4ta6JXyQAYfpeQVycPtRT2uthkiW7mRzYrSgc=; b=g9YiX0lkYeNf9+qu8xdNhBe+DJ7rjtH/XN3O6a6fDHiNP0stb6TO3S4d6wqx4eYHMm RP4tbeKjfNsHYCplfldipisUjuvUxBhCPeG/HZa1/rWD4sZCXmilSBHPdn0+Chu2dOy9 8xLFp45q8JIY/YYaR1EVljp1oyxx9QnoEM0Fo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VAY8GX4ta6JXyQAYfpeQVycPtRT2uthkiW7mRzYrSgc=; b=QQ4b1+3+587MzgQVaoTMH3WA0mipAQTF57r+73XMqCfqgzwwBtGyfYlLAmNX0CXvuG S4u91q3evAtH9HHaZCLqc94pAVpw96BEFnzCBmFB27XrCxK94IKM/1BMf0V2RhcAJ0Ox h++6V4qi6FXP3PrS3s5WipuZTH0VXjMZgT4ct+vZpnLkELMv9qHBf+wXVKZEwo567N0x /xWaO94GORVUhhcfSD7OSaD6Jsd13BvnBv++YHbbp3//AvATy+udElSCpWF/2oeEZVW9 oCZiIaN1fI8x82vy/7kk77JIRg6/moA3iGryLEk/UfXdohVXM+nnY3xhMTO+G81L5Y50 DSfg== X-Gm-Message-State: ABuFfoji6bTqFTU8MZ30ySxKEWvswA/yIsN49XGxqUI3ldTi93U5ApZg i3e53RDIo+IRuNR9xwPO+KhXn/zWF6I= X-Received: by 2002:a17:902:7109:: with SMTP id a9-v6mr32301921pll.310.1539163799833; Wed, 10 Oct 2018 02:29:59 -0700 (PDT) Received: from localhost.localdomain ([106.51.16.178]) by smtp.gmail.com with ESMTPSA id k71-v6sm37977548pge.44.2018.10.10.02.29.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Oct 2018 02:29:58 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Yu Wang , Kalle Valo Subject: [PATCH for-4.14.y 3/4] ath10k: fix kernel panic issue during pci probe Date: Wed, 10 Oct 2018 14:59:48 +0530 Message-Id: <1539163789-32338-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539163789-32338-1-git-send-email-amit.pundir@linaro.org> References: <1539163789-32338-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yu Wang commit 50e79e25250bf928369996277e85b00536b380c7 upstream. If device gone during chip reset, ar->normal_mode_fw.board is not initialized, but ath10k_debug_print_hwfw_info() will try to access its member, which will cause 'kernel NULL pointer' issue. This was found using a faulty device (pci link went down sometimes) in a random insmod/rmmod/other-op test. To fix it, check ar->normal_mode_fw.board before accessing the member. pci 0000:02:00.0: BAR 0: assigned [mem 0xf7400000-0xf75fffff 64bit] ath10k_pci 0000:02:00.0: enabling device (0000 -> 0002) ath10k_pci 0000:02:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0 ath10k_pci 0000:02:00.0: failed to read device register, device is gone ath10k_pci 0000:02:00.0: failed to wait for target init: -5 ath10k_pci 0000:02:00.0: failed to warm reset: -5 ath10k_pci 0000:02:00.0: firmware crashed during chip reset ath10k_pci 0000:02:00.0: firmware crashed! (uuid 5d018951-b8e1-404a-8fde-923078b4423a) ath10k_pci 0000:02:00.0: (null) target 0x00000000 chip_id 0x00340aff sub 0000:0000 ath10k_pci 0000:02:00.0: kconfig debug 1 debugfs 1 tracing 1 dfs 1 testmode 1 ath10k_pci 0000:02:00.0: firmware ver api 0 features crc32 00000000 ... BUG: unable to handle kernel NULL pointer dereference at 00000004 ... Call Trace: [] ath10k_print_driver_info+0x12/0x20 [ath10k_core] [] ath10k_pci_fw_crashed_dump+0x6d/0x4d0 [ath10k_pci] [] ? ath10k_pci_sleep.part.19+0x57/0xc0 [ath10k_pci] [] ath10k_pci_hif_power_up+0x14e/0x1b0 [ath10k_pci] [] ? do_page_fault+0xb/0x10 [] ath10k_core_register_work+0x24/0x840 [ath10k_core] [] ? netlbl_unlhsh_remove+0x178/0x410 [] ? __do_page_fault+0x480/0x480 [] process_one_work+0x114/0x3e0 [] worker_thread+0x37/0x4a0 [] kthread+0xa4/0xc0 [] ? create_worker+0x180/0x180 [] ? kthread_park+0x50/0x50 [] ret_from_fork+0x1b/0x28 Code: 78 80 b8 50 09 00 00 00 75 5d 8d 75 94 c7 44 24 08 aa d7 52 fb c7 44 24 04 64 00 00 00 89 34 24 e8 82 52 e2 c5 8b 83 dc 08 00 00 <8b> 50 04 8b 08 31 c0 e8 20 57 e3 c5 89 44 24 10 8b 83 58 09 00 EIP: []- ath10k_debug_print_board_info+0x34/0xb0 [ath10k_core] SS:ESP 0068:f4921d90 CR2: 0000000000000004 Signed-off-by: Yu Wang Signed-off-by: Kalle Valo [AmitP: Minor rebasing for 4.14.y and 4.9.y] Signed-off-by: Amit Pundir --- To be applied on 4.9.y as well. Build tested on 4.14.74 and 4.9.131 for ARCH=arm/arm64 allmodconfig. drivers/net/wireless/ath/ath10k/debug.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index df514507d3f1..22003895f854 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2005-2011 Atheros Communications Inc. * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. + * Copyright (c) 2018, The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -163,6 +164,8 @@ void ath10k_debug_print_hwfw_info(struct ath10k *ar) void ath10k_debug_print_board_info(struct ath10k *ar) { char boardinfo[100]; + const struct firmware *board; + u32 crc; if (ar->id.bmi_ids_valid) scnprintf(boardinfo, sizeof(boardinfo), "%d:%d", @@ -170,11 +173,16 @@ void ath10k_debug_print_board_info(struct ath10k *ar) else scnprintf(boardinfo, sizeof(boardinfo), "N/A"); + board = ar->normal_mode_fw.board; + if (!IS_ERR_OR_NULL(board)) + crc = crc32_le(0, board->data, board->size); + else + crc = 0; + ath10k_info(ar, "board_file api %d bmi_id %s crc32 %08x", ar->bd_api, boardinfo, - crc32_le(0, ar->normal_mode_fw.board->data, - ar->normal_mode_fw.board->size)); + crc); } void ath10k_debug_print_boot_info(struct ath10k *ar)