mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
sinowealth-nubwo: fix incorrect firmware version getting error check
If by any chance returned `size` was `0`, it would erroneously return 0, which would do an uninitialized pointer dereference in sinowealthnubwo_probe(). This fixes a convoluted warning by clang-analyze.
This commit is contained in:
@@ -105,9 +105,12 @@ sinowealth_get_firmware_string(struct ratbag_device *device, char **output)
|
||||
}
|
||||
|
||||
size = ratbag_hidraw_get_feature_report(device, SINOWEALTHNUBWO_GET_FIRMWARE_CMD_REPORTID, buff, SINOWEALTHNUBWO_GET_FIRMWARE_MSGSIZE);
|
||||
if (size < 0) {
|
||||
return size;
|
||||
}
|
||||
if (size != SINOWEALTHNUBWO_GET_FIRMWARE_MSGSIZE) {
|
||||
log_error(device->ratbag ,"Firmware report reply size mismatch expected %d got %d\n", SINOWEALTHNUBWO_GET_FIRMWARE_MSGSIZE, size);
|
||||
return size;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
*output = strdup_ascii_only((char *) buff + SINOWEALTHNUBWO_GET_FIRMWARE_MSGOFFSET);
|
||||
|
||||
Reference in New Issue
Block a user