From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com ([134.134.136.65]:14167 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754192AbbFORKq (ORCPT ); Mon, 15 Jun 2015 13:10:46 -0400 From: Daniel Verkamp To: stable@vger.kernel.org Cc: Daniel Verkamp , Jon Mason Subject: [PATCH] ntb: initialize max_mw for Atom before using it Date: Mon, 15 Jun 2015 10:08:55 -0700 Message-Id: <1434388135-13573-1-git-send-email-daniel.verkamp@intel.com> In-Reply-To: <1434386296.146175.3.camel@intel.com> References: <1434386296.146175.3.camel@intel.com> Sender: stable-owner@vger.kernel.org List-ID: Commit ab760a0 (ntb: Adding split BAR support for Haswell platforms) changed ntb_device's mw from a fixed-size array into a pointer that is allocated based on limits.max_mw; however, on Atom platforms, max_mw is not initialized until ntb_device_setup(), which happens after the allocation. Fill out max_mw in ntb_atom_detect() to match ntb_xeon_detect(); this happens before the use of max_mw in the ndev->mw allocation. Fixes a null pointer dereference on Atom platforms with ntb hardware. v2: fix typo (mw_max should be max_mw) Signed-off-by: Daniel Verkamp Acked-by: Dave Jiang Signed-off-by: Jon Mason --- Resend with patch inline on Dave's request. Applies to 4.0.y, 3.19.y, and 3.18.y. --- drivers/ntb/ntb_hw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c index b5c8707..15f9b7c 100644 --- a/drivers/ntb/ntb_hw.c +++ b/drivers/ntb/ntb_hw.c @@ -1660,6 +1660,7 @@ static int ntb_atom_detect(struct ntb_device *ndev) u32 ppd; ndev->hw_type = BWD_HW; + ndev->limits.max_mw = BWD_MAX_MW; rc = pci_read_config_dword(ndev->pdev, NTB_PPD_OFFSET, &ppd); if (rc) -- 2.4.3