Skip to content

Commit 0cb6498

Browse files
zbalatonnpiggin
authored andcommitted
ppc/amigaone: Check blk_pwrite return value
Coverity reported that return value of blk_pwrite() maybe should not be ignored. We can't do much if this happens other than report an error but let's do that to silence this report. Resolves: Coverity CID 1593725 Signed-off-by: BALATON Zoltan <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Message-ID: <[email protected]> Signed-off-by: Nicholas Piggin <[email protected]>
1 parent d8b1c3e commit 0cb6498

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

hw/ppc/amigaone.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ static void nvram_write(void *opaque, hwaddr addr, uint64_t val,
108108
uint8_t *p = memory_region_get_ram_ptr(&s->mr);
109109

110110
p[addr] = val;
111-
if (s->blk) {
112-
blk_pwrite(s->blk, addr, 1, &val, 0);
111+
if (s->blk && blk_pwrite(s->blk, addr, 1, &val, 0) < 0) {
112+
error_report("%s: could not write %s", __func__, blk_name(s->blk));
113113
}
114114
}
115115

@@ -151,15 +151,17 @@ static void nvram_realize(DeviceState *dev, Error **errp)
151151
*c = cpu_to_be32(CRC32_DEFAULT_ENV);
152152
/* Also copies terminating \0 as env is terminated by \0\0 */
153153
memcpy(p + 4, default_env, sizeof(default_env));
154-
if (s->blk) {
155-
blk_pwrite(s->blk, 0, sizeof(crc) + sizeof(default_env), p, 0);
154+
if (s->blk &&
155+
blk_pwrite(s->blk, 0, sizeof(crc) + sizeof(default_env), p, 0) < 0
156+
) {
157+
error_report("%s: could not write %s", __func__, blk_name(s->blk));
156158
}
157159
return;
158160
}
159161
if (*c == 0) {
160162
*c = cpu_to_be32(crc32(0, p + 4, NVRAM_SIZE - 4));
161-
if (s->blk) {
162-
blk_pwrite(s->blk, 0, 4, p, 0);
163+
if (s->blk && blk_pwrite(s->blk, 0, 4, p, 0) < 0) {
164+
error_report("%s: could not write %s", __func__, blk_name(s->blk));
163165
}
164166
}
165167
if (be32_to_cpu(*c) != crc) {

0 commit comments

Comments
 (0)