aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorByungho An <bh74.an@samsung.com>2014-03-28 13:57:44 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-28 14:42:24 -0400
commit2405e8f64c14a2cc9967f1f9bbeb1ba48b6cc2a1 (patch)
treeb90594ff4db31c3d5cd16c6b626b307a2552fc56 /drivers/net/ethernet
parent40b92cad5efb9a03cff2f01dc96532e1a6bffa14 (diff)
net: sxgbe: fix potential null dereference
This fixes following: drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c:1828 sxgbe_hw_init() error: potential null dereference 'priv->hw'. (kmalloc returns null) Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Byungho An <bh74.an@samsung.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index ee1fd3c4568f..a72688e8dc6c 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -2039,11 +2039,13 @@ static void sxgbe_get_ops(struct sxgbe_ops * const ops_ptr)
2039 * Description: this function checks the HW capability 2039 * Description: this function checks the HW capability
2040 * (if supported) and sets the driver's features. 2040 * (if supported) and sets the driver's features.
2041 */ 2041 */
2042static void sxgbe_hw_init(struct sxgbe_priv_data * const priv) 2042static int sxgbe_hw_init(struct sxgbe_priv_data * const priv)
2043{ 2043{
2044 u32 ctrl_ids; 2044 u32 ctrl_ids;
2045 2045
2046 priv->hw = kmalloc(sizeof(*priv->hw), GFP_KERNEL); 2046 priv->hw = kmalloc(sizeof(*priv->hw), GFP_KERNEL);
2047 if(!priv->hw)
2048 return -ENOMEM;
2047 2049
2048 /* get the hardware ops */ 2050 /* get the hardware ops */
2049 sxgbe_get_ops(priv->hw); 2051 sxgbe_get_ops(priv->hw);
@@ -2064,6 +2066,8 @@ static void sxgbe_hw_init(struct sxgbe_priv_data * const priv)
2064 2066
2065 if (priv->hw_cap.rx_csum_offload) 2067 if (priv->hw_cap.rx_csum_offload)
2066 pr_info("RX Checksum offload supported\n"); 2068 pr_info("RX Checksum offload supported\n");
2069
2070 return 0;
2067} 2071}
2068 2072
2069/** 2073/**
@@ -2102,7 +2106,9 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
2102 sxgbe_verify_args(); 2106 sxgbe_verify_args();
2103 2107
2104 /* Init MAC and get the capabilities */ 2108 /* Init MAC and get the capabilities */
2105 sxgbe_hw_init(priv); 2109 ret = sxgbe_hw_init(priv);
2110 if (ret)
2111 goto error_free_netdev;
2106 2112
2107 /* allocate memory resources for Descriptor rings */ 2113 /* allocate memory resources for Descriptor rings */
2108 ret = txring_mem_alloc(priv); 2114 ret = txring_mem_alloc(priv);