All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] isdn: hisax: l3ni1.c:  Fix for possible null pointer dereference
@ 2014-07-06 12:04 Rickard Strandqvist
  2014-07-08 23:06 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-07-06 12:04 UTC (permalink / raw)
  To: Karsten Keil, Rickard Strandqvist; +Cc: netdev, linux-kernel

There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/isdn/hisax/l3ni1.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c
index 0df6691..8dc791b 100644
--- a/drivers/isdn/hisax/l3ni1.c
+++ b/drivers/isdn/hisax/l3ni1.c
@@ -2059,13 +2059,17 @@ static int l3ni1_cmd_global(struct PStack *st, isdn_ctrl *ic)
 			memcpy(p, ic->parm.ni1_io.data, ic->parm.ni1_io.datalen); /* copy data */
 			l = (p - temp) + ic->parm.ni1_io.datalen; /* total length */
 
-			if (ic->parm.ni1_io.timeout > 0)
-				if (!(pc = ni1_new_l3_process(st, -1)))
-				{ free_invoke_id(st, id);
+			if (ic->parm.ni1_io.timeout > 0) {
+				pc = ni1_new_l3_process(st, -1);
+				if (!pc) {
+					free_invoke_id(st, id);
 					return (-2);
 				}
-			pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */
-			pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */
+				/* remember id */
+				pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id;
+				/* and procedure */
+				pc->prot.ni1.proc = ic->parm.ni1_io.proc;
+			}
 
 			if (!(skb = l3_alloc_skb(l)))
 			{ free_invoke_id(st, id);
-- 
1.7.10.4


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

* Re: [PATCH] isdn: hisax: l3ni1.c: Fix for possible null pointer dereference
  2014-07-06 12:04 [PATCH] isdn: hisax: l3ni1.c: Fix for possible null pointer dereference Rickard Strandqvist
@ 2014-07-08 23:06 ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-07-08 23:06 UTC (permalink / raw)
  To: rickard_strandqvist; +Cc: isdn, netdev, linux-kernel

From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Date: Sun,  6 Jul 2014 14:04:37 +0200

> There is otherwise a risk of a possible null pointer dereference.
> 
> Was largely found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>

Applied, thanks.

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

* Re: [PATCH] isdn: hisax: l3ni1.c: Fix for possible null pointer dereference
  2014-05-17 17:19 Rickard Strandqvist
@ 2014-05-19  1:13 ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-05-19  1:13 UTC (permalink / raw)
  To: rickard_strandqvist; +Cc: isdn, netdev, linux-kernel

From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Date: Sat, 17 May 2014 19:19:40 +0200

> @@ -2064,8 +2064,12 @@ static int l3ni1_cmd_global(struct PStack *st, isdn_ctrl *ic)
>  				{ free_invoke_id(st, id);
>  					return (-2);
>  				}
> -			pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */
> -			pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */
> +
> +			if (pc)
> +			{
> +				pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */
> +				pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */
> +			}

Like I said for your other patch, you should fix this by putting these
assignments in the timeout > 0 code block.

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

* [PATCH] isdn: hisax: l3ni1.c:  Fix for possible null pointer dereference
@ 2014-05-17 17:19 Rickard Strandqvist
  2014-05-19  1:13 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-05-17 17:19 UTC (permalink / raw)
  To: Karsten Keil, Rickard Strandqvist; +Cc: netdev, linux-kernel

There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/isdn/hisax/l3ni1.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c
index 0df6691..367b9d6 100644
--- a/drivers/isdn/hisax/l3ni1.c
+++ b/drivers/isdn/hisax/l3ni1.c
@@ -2064,8 +2064,12 @@ static int l3ni1_cmd_global(struct PStack *st, isdn_ctrl *ic)
 				{ free_invoke_id(st, id);
 					return (-2);
 				}
-			pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */
-			pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */
+
+			if (pc)
+			{
+				pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */
+				pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */
+			}
 
 			if (!(skb = l3_alloc_skb(l)))
 			{ free_invoke_id(st, id);
-- 
1.7.10.4


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

end of thread, other threads:[~2014-07-08 23:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-06 12:04 [PATCH] isdn: hisax: l3ni1.c: Fix for possible null pointer dereference Rickard Strandqvist
2014-07-08 23:06 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2014-05-17 17:19 Rickard Strandqvist
2014-05-19  1:13 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.