diff options
author | Antti Palosaari <crope@iki.fi> | 2011-05-25 17:32:44 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 22:52:09 +0200 |
commit | d838f4c318f12785a81e3e073a71ba4bb4ccd8cf (patch) | |
tree | 674ff39294fce448755e461bd9cdfcd3850446ba /drivers/media/dvb | |
parent | [media] anysee: style issues, comments, etc (diff) | |
download | linux-d838f4c318f12785a81e3e073a71ba4bb4ccd8cf.tar.xz linux-d838f4c318f12785a81e3e073a71ba4bb4ccd8cf.zip |
[media] cxd2820r: malloc buffers instead of stack
kmalloc I2C buffers
Signed-off-by: Antti Palosaari <crope@iki.fi>
Cc: Dan Carpenter <error27@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/frontends/cxd2820r_core.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/media/dvb/frontends/cxd2820r_core.c b/drivers/media/dvb/frontends/cxd2820r_core.c index 0779f69db793..903cbdbbc73b 100644 --- a/drivers/media/dvb/frontends/cxd2820r_core.c +++ b/drivers/media/dvb/frontends/cxd2820r_core.c @@ -740,12 +740,13 @@ static int cxd2820r_tuner_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num) { struct cxd2820r_priv *priv = i2c_get_adapdata(i2c_adap); - u8 obuf[msg[0].len + 2]; + int ret; + u8 *obuf = kmalloc(msg[0].len + 2, GFP_KERNEL); struct i2c_msg msg2[2] = { { .addr = priv->cfg.i2c_address, .flags = 0, - .len = sizeof(obuf), + .len = msg[0].len + 2, .buf = obuf, }, { .addr = priv->cfg.i2c_address, @@ -755,15 +756,24 @@ static int cxd2820r_tuner_i2c_xfer(struct i2c_adapter *i2c_adap, } }; + if (!obuf) + return -ENOMEM; + obuf[0] = 0x09; obuf[1] = (msg[0].addr << 1); if (num == 2) { /* I2C read */ obuf[1] = (msg[0].addr << 1) | I2C_M_RD; /* I2C RD flag */ - msg2[0].len = sizeof(obuf) - 1; /* maybe HW bug ? */ + msg2[0].len = msg[0].len + 2 - 1; /* '-1' maybe HW bug ? */ } memcpy(&obuf[2], msg[0].buf, msg[0].len); - return i2c_transfer(priv->i2c, msg2, num); + ret = i2c_transfer(priv->i2c, msg2, num); + if (ret < 0) + warn("tuner i2c failed ret:%d", ret); + + kfree(obuf); + + return ret; } static struct i2c_algorithm cxd2820r_tuner_i2c_algo = { |