2007-04-13 14:20:16

by Michael Wu

[permalink] [raw]
Subject: [PATCH] eeprom_93cx6: do not assume zeroed buffer

eeprom_93cx6: do not assume zeroed buffer

From: Michael Wu <[email protected]>

eeprom_93cx6_read_bits assumes u16 *data is already zeroed. This removes
that assumption.

Thanks to Andrea Merello <[email protected]> for discovering this issue.

Signed-off-by: Michael Wu <[email protected]>
---

drivers/misc/eeprom_93cx6.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/eeprom_93cx6.c b/drivers/misc/eeprom_93cx6.c
index e5d016b..a948ddc 100644
--- a/drivers/misc/eeprom_93cx6.c
+++ b/drivers/misc/eeprom_93cx6.c
@@ -127,6 +127,7 @@ static void eeprom_93cx6_read_bits(struct eeprom_93cx6
*eeprom,
u16 *data, const u16 count)
{
unsigned int i;
+ u16 buf = 0;

eeprom->register_read(eeprom);

@@ -153,10 +154,12 @@ static void eeprom_93cx6_read_bits(struct eeprom_93cx6
*eeprom,
* Read if the bit has been set.
*/
if (eeprom->reg_data_out)
- *data |= (1 << (i - 1));
+ buf |= (1 << (i - 1));

eeprom_93cx6_pulse_low(eeprom);
}
+
+ *data = buf;
}

static void eeprom_93cx6_ewen(struct eeprom_93cx6 *eeprom)


Attachments:
(No filename) (1.07 kB)
(No filename) (189.00 B)
Download all attachments

2007-04-13 15:25:05

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: [PATCH] eeprom_93cx6: do not assume zeroed buffer

On Friday 13 April 2007 16:17, Michael Wu wrote:
> eeprom_93cx6: do not assume zeroed buffer
>
> From: Michael Wu <[email protected]>
>
> eeprom_93cx6_read_bits assumes u16 *data is already zeroed. This removes
> that assumption.

ACK. :)
This was indeed an issue where I was doubting if the driver should make sure the data
was set to zero or that the calling driver should be responsible.

Ivo