diff mbox

[2/2] fm10k: Avoid crashing the kernel

Message ID 1455668365-30782-2-git-send-email-jacob.e.keller@intel.com
State Deferred
Delegated to: Jeff Kirsher
Headers show

Commit Message

Jacob Keller Feb. 17, 2016, 12:19 a.m. UTC
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 <jacob.e.keller@intel.com>
---
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(-)

Comments

Singh, Krishneil K Feb. 25, 2016, 8:26 p.m. UTC | #1
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Tuesday, February 16, 2016 4:19 PM
To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
Subject: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing the kernel

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 <jacob.e.keller@intel.com>
---
Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
Allan, Bruce W Feb. 25, 2016, 9:46 p.m. UTC | #2
> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.org] On
> Behalf Of Singh, Krishneil K
> Sent: Thursday, February 25, 2016 12:27 PM
> To: Keller, Jacob E; Intel Wired LAN
> Subject: Re: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing the kernel
> 
> 
> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.org] On
> Behalf Of Jacob Keller
> Sent: Tuesday, February 16, 2016 4:19 PM
> To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
> Subject: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing the kernel
> 
> 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 <jacob.e.keller@intel.com>
> ---
> Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>

Please hold off on submitting this patch to netdev.
Jacob Keller Feb. 26, 2016, 1:11 a.m. UTC | #3
On Thu, 2016-02-25 at 21:46 +0000, Allan, Bruce W wrote:
> > 
> > -----Original Message-----
> > From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.
> > org] On
> > Behalf Of Singh, Krishneil K
> > Sent: Thursday, February 25, 2016 12:27 PM
> > To: Keller, Jacob E; Intel Wired LAN
> > Subject: Re: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing
> > the kernel
> > 
> > 
> > -----Original Message-----
> > From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.
> > org] On
> > Behalf Of Jacob Keller
> > Sent: Tuesday, February 16, 2016 4:19 PM
> > To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
> > Subject: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing the
> > kernel
> > 
> > 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 <jacob.e.keller@intel.com>
> > ---
> > Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
> Please hold off on submitting this patch to netdev.

What's the reasoning here for holding submission?

Thanks,
Jake
Allan, Bruce W Feb. 26, 2016, 1:15 a.m. UTC | #4
> -----Original Message-----
> From: Keller, Jacob E
> Sent: Thursday, February 25, 2016 5:12 PM
> To: Singh, Krishneil K; Allan, Bruce W; intel-wired-lan@lists.osuosl.org
> Subject: Re: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing the kernel
> 
> On Thu, 2016-02-25 at 21:46 +0000, Allan, Bruce W wrote:
> > >
> > > -----Original Message-----
> > > From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.
> > > org] On
> > > Behalf Of Singh, Krishneil K
> > > Sent: Thursday, February 25, 2016 12:27 PM
> > > To: Keller, Jacob E; Intel Wired LAN
> > > Subject: Re: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing
> > > the kernel
> > >
> > >
> > > -----Original Message-----
> > > From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.
> > > org] On
> > > Behalf Of Jacob Keller
> > > Sent: Tuesday, February 16, 2016 4:19 PM
> > > To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
> > > Subject: [Intel-wired-lan] [PATCH 2/2] fm10k: Avoid crashing the
> > > kernel
> > >
> > > 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 <jacob.e.keller@intel.com>
> > > ---
> > > Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
> > Please hold off on submitting this patch to netdev.
> 
> What's the reasoning here for holding submission?
> 
> Thanks,
> Jake

I want to look into this further.
diff mbox

Patch

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);
 }