* [PATCH] ISDN cmx: Avoid potential NULL deref in dsp_cmx_send_member() and shrink code size.
@ 2010-12-18 22:33 Jesper Juhl
2010-12-31 19:19 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2010-12-18 22:33 UTC (permalink / raw)
To: Karsten Keil
Cc: David S. Miller, Julia Lawall, Tejun Heo, netdev, linux-kernel,
Andreas Eversberg
Hi there,
In drivers/isdn/mISDN/dsp_cmx.c::dsp_cmx_send_member() we currently have
this code:
if (dsp->conf && dsp->conf->software && dsp->conf->hardware)
tx_data_only = 1;
if (dsp->conf->software && dsp->echo.hardware)
tx_data_only = 1;
The first line implies that 'dsp->conf' may be NULL. If it is, then the
third line will dereference a NULL pointer.
This patch reworks the code so that we avoid the potential NULL deref.
It also has the added benefit that the object file size shrinks a bit.
before:
text data bss dec hex filename
18840 112 5784 24736 60a0 drivers/isdn/mISDN/dsp_cmx.o
after:
text data bss dec hex filename
18816 112 5776 24704 6080 drivers/isdn/mISDN/dsp_cmx.o
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
dsp_cmx.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
compile tested only
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index 76d9e67..f76f595 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -1326,10 +1326,9 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
dsp->last_tx = 0;
return;
}
- if (dsp->conf && dsp->conf->software && dsp->conf->hardware)
- tx_data_only = 1;
- if (dsp->conf->software && dsp->echo.hardware)
- tx_data_only = 1;
+ if (dsp->conf && dsp->conf->software)
+ if (dsp->conf->hardware || dsp->echo.hardware)
+ tx_data_only = 1;
}
#ifdef CMX_DEBUG
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ISDN cmx: Avoid potential NULL deref in dsp_cmx_send_member() and shrink code size.
2010-12-18 22:33 [PATCH] ISDN cmx: Avoid potential NULL deref in dsp_cmx_send_member() and shrink code size Jesper Juhl
@ 2010-12-31 19:19 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-12-31 19:19 UTC (permalink / raw)
To: jj; +Cc: isdn, julia, tj, netdev, linux-kernel, jolly
From: Jesper Juhl <jj@chaosbits.net>
Date: Sat, 18 Dec 2010 23:33:40 +0100 (CET)
> Hi there,
>
> In drivers/isdn/mISDN/dsp_cmx.c::dsp_cmx_send_member() we currently have
> this code:
>
> if (dsp->conf && dsp->conf->software && dsp->conf->hardware)
> tx_data_only = 1;
> if (dsp->conf->software && dsp->echo.hardware)
> tx_data_only = 1;
>
> The first line implies that 'dsp->conf' may be NULL. If it is, then the
> third line will dereference a NULL pointer.
>
> This patch reworks the code so that we avoid the potential NULL deref.
> It also has the added benefit that the object file size shrinks a bit.
>
> before:
> text data bss dec hex filename
> 18840 112 5784 24736 60a0 drivers/isdn/mISDN/dsp_cmx.o
> after:
> text data bss dec hex filename
> 18816 112 5776 24704 6080 drivers/isdn/mISDN/dsp_cmx.o
>
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-31 19:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-18 22:33 [PATCH] ISDN cmx: Avoid potential NULL deref in dsp_cmx_send_member() and shrink code size Jesper Juhl
2010-12-31 19:19 ` 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).