2014-02-28 21:23:10

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 0/3] media/drx39xyj: fix DJH_DEBUG path null pointer dereferences, and compile errors.

This patch series fixes null pointer dereference boot failure as well as
compile errors.

Shuah Khan (3):
media/drx39xyj: fix pr_dbg undefined compile errors when DJH_DEBUG is
defined
media/drx39xyj: remove return that prevents DJH_DEBUG code to run
media/drx39xyj: fix boot failure due to null pointer dereference

drivers/media/dvb-frontends/drx39xyj/drxj.c | 31 ++++++++++++++++++-----------
1 file changed, 19 insertions(+), 12 deletions(-)

--
1.8.3.2


2014-02-28 21:23:23

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 3/3] media/drx39xyj: fix boot failure due to null pointer dereference

DJH_DEBUG only code path in drxbsp_i2c_write_read() dereferences
w_dev_addr and subsequently w_dev_addr->user_data->i2c which results
in failure during boot. This patch fixes the null pointer derefence
bug as well as the following compile errors:

LD arch/x86/built-in.o
CC drivers/media/dvb-frontends/drx39xyj/drxj.o
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxbsp_i2c_write_read’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:25: error: redeclaration of ‘state’ with no linkage
struct drx39xxj_state *state = w_dev_addr->user_data;
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1512:25: note: previous declaration of ‘state’ was here
struct drx39xxj_state *state;
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct drx39xxj_state *state = w_dev_addr->user_data;
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1560:17: error: redeclaration of ‘msg’ with no linkage
struct i2c_msg msg[2] = {
^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1513:17: note: previous declaration of ‘msg’ was here
struct i2c_msg msg[2];
^

Signed-off-by: Shuah Khan <[email protected]>
---
drivers/media/dvb-frontends/drx39xyj/drxj.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 72c541a..585d891 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -1551,14 +1551,23 @@ int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
}

#ifdef DJH_DEBUG
- struct drx39xxj_state *state = w_dev_addr->user_data;
+ if (w_dev_addr == NULL || r_dev_addr == NULL)
+ return 0;

- struct i2c_msg msg[2] = {
- {.addr = w_dev_addr->i2c_addr,
- .flags = 0, .buf = wData, .len = w_count},
- {.addr = r_dev_addr->i2c_addr,
- .flags = I2C_M_RD, .buf = r_data, .len = r_count},
- };
+ state = w_dev_addr->user_data;
+
+ if (state->i2c == NULL)
+ return 0;
+
+ msg[0].addr = w_dev_addr->i2c_addr;
+ msg[0].flags = 0;
+ msg[0].buf = wData;
+ msg[0].len = w_count;
+ msg[1].addr = r_dev_addr->i2c_addr;
+ msg[1].flags = I2C_M_RD;
+ msg[1].buf = r_data;
+ msg[1].len = r_count;
+ num_msgs = 2;

pr_debug("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
w_dev_addr->i2c_addr, state->i2c, w_count, r_count);
--
1.8.3.2

2014-02-28 21:23:49

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 1/3] media/drx39xyj: fix pr_dbg undefined compile errors when DJH_DEBUG is defined

drxj.c fails to compile with the following errors when DJH_DEBUG
is defined.

drivers/media/dvb-frontends/drx39xyj/drxj.c:1567:2: error: implicit declaration of function ‘pr_dbg’ [-Werror=implicit-function-declaration]
pr_dbg("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
^

Signed-off-by: Shuah Khan <[email protected]>
---
drivers/media/dvb-frontends/drx39xyj/drxj.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index ed68c52..a78af4e 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -1562,7 +1562,7 @@ int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
.flags = I2C_M_RD, .buf = r_data, .len = r_count},
};

- pr_dbg("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
+ pr_debug("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
w_dev_addr->i2c_addr, state->i2c, w_count, r_count);

if (i2c_transfer(state->i2c, msg, 2) != 2) {
@@ -20640,7 +20640,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
for (i = 0; i < 2000; i++) {
fe_status_t status;
drx39xxj_read_status(fe, &status);
- pr_dbg("i=%d status=%d\n", i, status);
+ pr_debug("i=%d status=%d\n", i, status);
msleep(100);
i += 100;
}
@@ -20663,7 +20663,7 @@ static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
int result;

#ifdef DJH_DEBUG
- pr_dbg("i2c gate call: enable=%d state=%d\n", enable,
+ pr_debug("i2c gate call: enable=%d state=%d\n", enable,
state->i2c_gate_open);
#endif

--
1.8.3.2

2014-02-28 21:23:48

by Shuah Khan

[permalink] [raw]
Subject: [PATCH 2/3] media/drx39xyj: remove return that prevents DJH_DEBUG code to run

drxbsp_i2c_write_read() has return that prevents DJH_DEBUG code to run.
Remove it.

Signed-off-by: Shuah Khan <[email protected]>
---
drivers/media/dvb-frontends/drx39xyj/drxj.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index a78af4e..72c541a 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -1550,8 +1550,6 @@ int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
return -EREMOTEIO;
}

- return 0;
-
#ifdef DJH_DEBUG
struct drx39xxj_state *state = w_dev_addr->user_data;

--
1.8.3.2

2014-03-01 00:15:59

by Devin Heitmueller

[permalink] [raw]
Subject: Re: [PATCH 0/3] media/drx39xyj: fix DJH_DEBUG path null pointer dereferences, and compile errors.

On Fri, Feb 28, 2014 at 4:22 PM, Shuah Khan <[email protected]> wrote:
> This patch series fixes null pointer dereference boot failure as well as
> compile errors.

Seems kind of strange that I wasn't on the CC for this, since I was
the original author of all that code (in fact, DJH are my initials).

Mauro, did you strip off my authorship when you pulled the patches from my tree?

The patches themselves look sane, and I will send a formal Acked-by
once I can get in front of a real computer.

Devin

--
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com

2014-03-01 03:27:37

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 0/3] media/drx39xyj: fix DJH_DEBUG path null pointer dereferences, and compile errors.

On 02/28/2014 05:13 PM, Devin Heitmueller wrote:
> Seems kind of strange that I wasn't on the CC for this, since I was the
> original author of all that code (in fact, DJH are my initials).
>
> Mauro, did you strip off my authorship when you pulled the patches from
> my tree?
>
> The patches themselves look sane, and I will send a formal Acked-by once
> I can get in front of a real computer.
>
> Devin

Thanks for the ack. I will include you on the cc for future patches. I
am working in Mauro's experimental git and probably that explains why
get_maintainer.pl just showed linux-media and Mauro.

-- Shuah

>
> On Feb 28, 2014 4:23 PM, "Shuah Khan" <[email protected]
> <mailto:[email protected]>> wrote:
>
> This patch series fixes null pointer dereference boot failure as well as
> compile errors.
>
> Shuah Khan (3):
> media/drx39xyj: fix pr_dbg undefined compile errors when DJH_DEBUG is
> defined
> media/drx39xyj: remove return that prevents DJH_DEBUG code to run
> media/drx39xyj: fix boot failure due to null pointer dereference
>
> drivers/media/dvb-frontends/drx39xyj/drxj.c | 31
> ++++++++++++++++++-----------
> 1 file changed, 19 insertions(+), 12 deletions(-)
>
> --
> 1.8.3.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-media" in
> the body of a message to [email protected]
> <mailto:[email protected]>
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>


--
Shuah Khan
Senior Linux Kernel Developer - Open Source Group
Samsung Research America(Silicon Valley)
[email protected] | (970) 672-0658