Skip to contentSkip to conversation

smu_sat_get_sdb_partition() - unsigned len cannot be negative

PATCH New roel kluin 1 participant 1 message Nov 29, 2008 Linux for power macintosh

lore
Share & tools
lore

roel kluin

author
#0 lore raw

PATCH 1/1 smu_sat_get_sdb_partition() - unsigned len cannot be negative

i2c_smbus_read_word_data() returns a s32, which may be negative but unsigned len cannot be negative.

---
for i2c_smbus_read_word_data(), see
vi drivers/i2c/i2c-core.c +1663

drivers/macintosh/windfarm_smu_sat.c +3 -2
index 7f2be4b..7847e98 100644
@@ -87,11 +87,12 @@ struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
 		return NULL;
 	}
 
-	len = i2c_smbus_read_word_data(&sat->i2c, 9);
-	if (len < 0) {
+	err = i2c_smbus_read_word_data(&sat->i2c, 9);
+	if (err < 0) {
 		printk(KERN_ERR "smu_sat_get_sdb_part rd len error\n");
 		return NULL;
 	}
+	len = err;
 	if (len == 0) {
 		printk(KERN_ERR "smu_sat_get_sdb_part no partition %x\n", id);
 		return NULL;