aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-08-11 11:31:08 +0200
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-09-02 17:57:05 +0200
commit7baa9c39fc3d525216f0cedcfda5374c26d50e80 (patch)
treed7d3411ad7643b88cc4d7aaf7d09fc9fdb7a530b
parentc5ade4f9d289fed61df7a04950f8f607e26353e6 (diff)
downloadqemu-7baa9c39fc3d525216f0cedcfda5374c26d50e80.zip
qemu-7baa9c39fc3d525216f0cedcfda5374c26d50e80.tar.gz
qemu-7baa9c39fc3d525216f0cedcfda5374c26d50e80.tar.bz2
hw/scsi/mptsas: Avoid silent integer truncation in MPI_FUNC_IOC_INIT
For the MaxDevices 8-bit field of the request / response structures of the MPI_FUNCTION_IOC_INIT command, the 0x00 value means "max 256 devices". This is not a problem because when max_devices=256, its value (0x100), being casted to a uint8_t, is truncated to 0x00. However Coverity complains for an "Overflowed constant". Fix by re-using the request fields in the response, since they are not modified and use the same types. Fix: Coverity 1547736 (Overflowed constant) Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20250811095550.93655-1-philmd@linaro.org>
-rw-r--r--hw/scsi/mptsas.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index 1ebe0b8..4ada35b 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -579,11 +579,11 @@ static void mptsas_process_ioc_init(MPTSASState *s, MPIMsgIOCInit *req)
}
memset(&reply, 0, sizeof(reply));
- reply.WhoInit = s->who_init;
+ reply.WhoInit = req->WhoInit;
reply.MsgLength = sizeof(reply) / 4;
reply.Function = req->Function;
- reply.MaxDevices = s->max_devices;
- reply.MaxBuses = s->max_buses;
+ reply.MaxDevices = req->MaxDevices;
+ reply.MaxBuses = req->MaxBuses;
reply.MsgContext = req->MsgContext;
mptsas_fix_ioc_init_reply_endianness(&reply);