summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/frontends/tda10023.c
diff options
context:
space:
mode:
authorOliver Endriss <o.endriss@gmx.de>2008-06-20 00:45:55 +0200
committerOliver Endriss <o.endriss@gmx.de>2008-06-20 00:45:55 +0200
commit97e3f59993c1918eb305403d58dcbff3306ff1e5 (patch)
tree6ce8314c88a430e8214b12d4b34e1e1e94c7cf2d /linux/drivers/media/dvb/frontends/tda10023.c
parent54084f7c52a77294a6947de1b8a9662c14385fed (diff)
downloadmediapointer-dvb-s2-97e3f59993c1918eb305403d58dcbff3306ff1e5.tar.gz
mediapointer-dvb-s2-97e3f59993c1918eb305403d58dcbff3306ff1e5.tar.bz2
tda10023: Fix possible kernel oops during initialisation
From: Oliver Endriss <o.endriss@gmx.de> If the i2c write fails during initialisation, an oops happens because state->frontend.dvb is still undefined. Fixed. Thanks to Sigmund Augdal for reporting this bug, and to Hartmut Birr for suggesting the fix. Signed-off-by: Oliver Endriss <o.endriss@gmx.de> Thanks-to: Sigmund Augdal <sigmund@snap.tv> Thanks-to: Hartmut Birr <e9hack@gmail.com>
Diffstat (limited to 'linux/drivers/media/dvb/frontends/tda10023.c')
-rw-r--r--linux/drivers/media/dvb/frontends/tda10023.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/linux/drivers/media/dvb/frontends/tda10023.c b/linux/drivers/media/dvb/frontends/tda10023.c
index ec9d772c4..ccc63f064 100644
--- a/linux/drivers/media/dvb/frontends/tda10023.c
+++ b/linux/drivers/media/dvb/frontends/tda10023.c
@@ -74,9 +74,12 @@ static u8 tda10023_readreg (struct tda10023_state* state, u8 reg)
int ret;
ret = i2c_transfer (state->i2c, msg, 2);
- if (ret != 2)
- printk("DVB: TDA10023: %s: readreg error (ret == %i)\n",
- __func__, ret);
+ if (ret != 2) {
+ int num = state->frontend.dvb ? state->frontend.dvb->num : -1;
+ printk(KERN_ERR "DVB: TDA10023(%d): %s: readreg error "
+ "(reg == 0x%02x, ret == %i)\n",
+ num, __func__, reg, ret);
+ }
return b1[0];
}
@@ -87,11 +90,12 @@ static int tda10023_writereg (struct tda10023_state* state, u8 reg, u8 data)
int ret;
ret = i2c_transfer (state->i2c, &msg, 1);
- if (ret != 1)
- printk("DVB: TDA10023(%d): %s, writereg error "
+ if (ret != 1) {
+ int num = state->frontend.dvb ? state->frontend.dvb->num : -1;
+ printk(KERN_ERR "DVB: TDA10023(%d): %s, writereg error "
"(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
- state->frontend.dvb->num, __func__, reg, data, ret);
-
+ num, __func__, reg, data, ret);
+ }
return (ret != 1) ? -EREMOTEIO : 0;
}
@@ -485,7 +489,7 @@ struct dvb_frontend *tda10023_attach(const struct tda10023_config *config,
struct tda10023_state* state = NULL;
/* allocate memory for the internal state */
- state = kmalloc(sizeof(struct tda10023_state), GFP_KERNEL);
+ state = kzalloc(sizeof(struct tda10023_state), GFP_KERNEL);
if (state == NULL) goto error;
/* setup the state */