All of lore.kernel.org
 help / color / mirror / Atom feed
From: HoP <jpetrous@gmail.com>
To: linux-media@vger.kernel.org, Antti <crope@iki.fi>
Subject: [PATH v2] cxd2820r: fix possible out-of-array lookup
Date: Fri, 29 Jul 2011 08:57:54 +0200	[thread overview]
Message-ID: <CAJbz7-0BNRvKb82fhcvZf63hXp-RXV+WT4uX0h9_zaDPfTPgiA@mail.gmail.com> (raw)

When I2C_WRITE is used the msg[] array contains one element only.
Don't access msg[1] in that case. Also moved rest of msg2[1]
setting to be used only if needed.

Signed-off-by: Honza Petrous <jpetrous@smartimp.cz>

---

diff -r ae517614bf00 drivers/media/dvb/frontends/cxd2820r_core.c
--- a/drivers/media/dvb/frontends/cxd2820r_core.c	Thu Jul 28 15:44:49 2011 +0200
+++ b/drivers/media/dvb/frontends/cxd2820r_core.c	Thu Jul 28 16:20:17 2011 +0200
@@ -747,12 +747,7 @@ static int cxd2820r_tuner_i2c_xfer(struc
 			.flags = 0,
 			.len = sizeof(obuf),
 			.buf = obuf,
-		}, {
-			.addr = priv->cfg.i2c_address,
-			.flags = I2C_M_RD,
-			.len = msg[1].len,
-			.buf = msg[1].buf,
-		}
+		},
 	};

 	obuf[0] = 0x09;
@@ -760,6 +755,11 @@ static int cxd2820r_tuner_i2c_xfer(struc
 	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[1].addr = priv->cfg.i2c_address,
+		msg2[1].flags = I2C_M_RD,
+		msg2[1].len = msg[1].len,
+		msg2[1].buf = msg[1].buf,
 	}
 	memcpy(&obuf[2], msg[0].buf, msg[0].len);

             reply	other threads:[~2011-07-29  6:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29  6:57 HoP [this message]
2011-07-29 12:54 ` [PATH v2] cxd2820r: fix possible out-of-array lookup Antti Palosaari
2011-08-07 18:08   ` [PATCH] CXD2820R: Replace i2c message translation with repeater gate control Steve Kerrison
2011-08-08 23:16     ` Antti Palosaari
2011-08-09 10:16       ` [PATCH v2] " Steve Kerrison
2011-08-09 10:45         ` Antti Palosaari
2011-08-21 22:59   ` [PATH v2] cxd2820r: fix possible out-of-array lookup Antti Palosaari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJbz7-0BNRvKb82fhcvZf63hXp-RXV+WT4uX0h9_zaDPfTPgiA@mail.gmail.com \
    --to=jpetrous@gmail.com \
    --cc=crope@iki.fi \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.