From patchwork Wed Feb 17 00:19:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Keller, Jacob E" X-Patchwork-Id: 583778 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id B29F71401E7 for ; Wed, 17 Feb 2016 11:19:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id EA69892269; Wed, 17 Feb 2016 00:19:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZWdEYWLx5n5a; Wed, 17 Feb 2016 00:19:29 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id A5BA8921B3; Wed, 17 Feb 2016 00:19:29 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 094C31C1619 for ; Wed, 17 Feb 2016 00:19:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 04C19954C8 for ; Wed, 17 Feb 2016 00:19:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kkhO46KMpsPQ for ; Wed, 17 Feb 2016 00:19:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by hemlock.osuosl.org (Postfix) with ESMTP id 9DE19953B0 for ; Wed, 17 Feb 2016 00:19:27 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 16 Feb 2016 16:19:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,457,1449561600"; d="scan'208";a="913758297" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([134.134.3.65]) by orsmga002.jf.intel.com with ESMTP; 16 Feb 2016 16:19:27 -0800 From: Jacob Keller To: Intel Wired LAN Date: Tue, 16 Feb 2016 16:19:25 -0800 Message-Id: <1455668365-30782-2-git-send-email-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.7.0.236.gda096a0.dirty In-Reply-To: <1455668365-30782-1-git-send-email-jacob.e.keller@intel.com> References: <1455668365-30782-1-git-send-email-jacob.e.keller@intel.com> Subject: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing the kernel X-BeenThere: intel-wired-lan@lists.osuosl.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@lists.osuosl.org Sender: "Intel-wired-lan" Use BUILD_BUG_ON() instead of BUG_ON() where appropriate to get a compile error rather than crash the kernel. Signed-off-by: Jacob Keller Signed-off-by: Jacob Keller Tested-by: Krishneil Singh --- I checked this works against allmodconfig, and defconfig. Note that only allmodconfig seems to break the use of BUILD_BUG_ON in the latter case, so I added a comment to indicate this. Sorry for the failures earlier. drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c index a1342be34be4..0b0531417835 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c @@ -468,7 +468,7 @@ static void fm10k_get_reg_q(struct fm10k_hw *hw, u32 *buff, int i) buff[idx++] = fm10k_read_reg(hw, FM10K_TX_SGLORT(i)); buff[idx++] = fm10k_read_reg(hw, FM10K_PFVTCTL(i)); - BUG_ON(idx != FM10K_REGS_LEN_Q); + BUILD_BUG_ON(idx != FM10K_REGS_LEN_Q); } /* If function above adds more registers this define needs to be updated */ @@ -484,6 +484,9 @@ static void fm10k_get_reg_vsi(struct fm10k_hw *hw, u32 *buff, int i) for (j = 0; j < 32; j++) buff[idx++] = fm10k_read_reg(hw, FM10K_RETA(i, j)); + /* Unfortunately some kernel configurations prevent us from using + * BUILD_BUG_ON here, notably allmodconfig. + */ BUG_ON(idx != FM10K_REGS_LEN_VSI); }