* [PATCH net-next] net: sxgbe: fix potential null dereference
@ 2014-03-28 17:57 Byungho An
2014-03-28 18:43 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Byungho An @ 2014-03-28 17:57 UTC (permalink / raw)
To: netdev, linux-samsung-soc
Cc: 'David Miller', 'kbuild test robot',
'Girish K S', 'Siva Reddy',
'Vipul Pandya'
From: Byungho An <bh74.an@samsung.com>
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>
---
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 10 ++++++++--
1 file 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 ee1fd3c..a72688e 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)
* Description: this function checks the HW capability
* (if supported) and sets the driver's features.
*/
-static void sxgbe_hw_init(struct sxgbe_priv_data * const priv)
+static int sxgbe_hw_init(struct sxgbe_priv_data * const priv)
{
u32 ctrl_ids;
priv->hw = kmalloc(sizeof(*priv->hw), GFP_KERNEL);
+ if(!priv->hw)
+ return -ENOMEM;
/* get the hardware ops */
sxgbe_get_ops(priv->hw);
@@ -2064,6 +2066,8 @@ static void sxgbe_hw_init(struct sxgbe_priv_data * const priv)
if (priv->hw_cap.rx_csum_offload)
pr_info("RX Checksum offload supported\n");
+
+ return 0;
}
/**
@@ -2102,7 +2106,9 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
sxgbe_verify_args();
/* Init MAC and get the capabilities */
- sxgbe_hw_init(priv);
+ ret = sxgbe_hw_init(priv);
+ if (ret)
+ goto error_free_netdev;
/* allocate memory resources for Descriptor rings */
ret = txring_mem_alloc(priv);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: sxgbe: fix potential null dereference
2014-03-28 17:57 [PATCH net-next] net: sxgbe: fix potential null dereference Byungho An
@ 2014-03-28 18:43 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-03-28 18:43 UTC (permalink / raw)
To: bh74.an
Cc: netdev, linux-samsung-soc, fengguang.wu, ks.giri, siva.kallam,
vipul.pandya
From: Byungho An <bh74.an@samsung.com>
Date: Fri, 28 Mar 2014 10:57:44 -0700
> From: Byungho An <bh74.an@samsung.com>
>
> 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>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-28 18:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-28 17:57 [PATCH net-next] net: sxgbe: fix potential null dereference Byungho An
2014-03-28 18:43 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).