netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fm10k_main.c: fix missing return value check of alloc_skb()
@ 2018-08-18  2:00 Jiecheng Wu
  2018-08-18  2:14 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Jiecheng Wu @ 2018-08-18  2:00 UTC (permalink / raw)
  To: netdev

Function fm10k_init_module() defined in drivers/net/ethernet/intel/fm10k/fm10k_main.c calls alloc_workqueue() to allocate memory for struct workqueue_struct which is dereferenced immediately. As alloc_workqueue() may return NULL on failure, this code piece may cause NULL pointer dereference bug.
---
 drivers/net/ethernet/intel/fm10k/fm10k_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index 3f53654..78a43d6 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -41,6 +41,8 @@ static int __init fm10k_init_module(void)
 	/* create driver workqueue */
 	fm10k_workqueue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0,
 					  fm10k_driver_name);
+	if (!fm10k_workqueue)
+		return -ENOMEM;
 
 	fm10k_dbg_init();
 
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fm10k_main.c: fix missing return value check of alloc_skb()
  2018-08-18  2:00 [PATCH] fm10k_main.c: fix missing return value check of alloc_skb() Jiecheng Wu
@ 2018-08-18  2:14 ` Andrew Lunn
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2018-08-18  2:14 UTC (permalink / raw)
  To: Jiecheng Wu; +Cc: netdev

On Sat, Aug 18, 2018 at 10:00:58AM +0800, Jiecheng Wu wrote:
> Function fm10k_init_module() defined in drivers/net/ethernet/intel/fm10k/fm10k_main.c calls alloc_workqueue() to allocate memory for struct workqueue_struct which is dereferenced immediately. As alloc_workqueue() may return NULL on failure, this code piece may cause NULL pointer dereference bug.

Hi Jiecheng

Please wrap your commit message to around 80 character wide.

You also need to add a Signed-off-by to your patch. Please see 

https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#developer-s-certificate-of-origin-1-1

scripts/checkpatch.pl will help you get these things rights.

	Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] fm10k_main.c: fix missing return value check of alloc_skb()
@ 2018-08-18  2:27 Jiecheng Wu
  0 siblings, 0 replies; 3+ messages in thread
From: Jiecheng Wu @ 2018-08-18  2:27 UTC (permalink / raw)
  To: netdev

Function fm10k_init_module() defined in drivers/net/ethernet/intel/fm10k/fm10k_main.c
 calls alloc_workqueue() to allocate memory for struct workqueue_struct which is 
 dereferenced immediately. As alloc_workqueue() may return NULL on failure, 
 this code piece may cause NULL pointer dereference bug.
---
 drivers/net/ethernet/intel/fm10k/fm10k_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index 3f53654..78a43d6 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -41,6 +41,8 @@ static int __init fm10k_init_module(void)
 	/* create driver workqueue */
 	fm10k_workqueue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0,
 					  fm10k_driver_name);
+	if (!fm10k_workqueue)
+		return -ENOMEM;
 
 	fm10k_dbg_init();
 
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-18  5:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-18  2:00 [PATCH] fm10k_main.c: fix missing return value check of alloc_skb() Jiecheng Wu
2018-08-18  2:14 ` Andrew Lunn
  -- strict thread matches above, loose matches on Subject: below --
2018-08-18  2:27 Jiecheng Wu

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).