[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode
From: |
Corey Minyard |
Subject: |
Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode |
Date: |
Tue, 26 Jan 2021 17:47:24 -0600 |
On Tue, Jan 26, 2021 at 11:32:37AM -0800, wuhaotsh--- via wrote:
> +
> +static void npcm7xx_smbus_read_byte_fifo(NPCM7xxSMBusState *s)
> +{
> + uint8_t received_bytes = NPCM7XX_SMBRXF_STS_RX_BYTES(s->rxf_sts);
> +
> + if (received_bytes == 0) {
> + npcm7xx_smbus_recv_fifo(s);
> + return;
> + }
> +
> + s->sda = s->rx_fifo[s->rx_cur];
> + s->rx_cur = (s->rx_cur + 1u) % NPCM7XX_SMBUS_FIFO_SIZE;
> + --s->rxf_sts;
This open-coded decrement seems a little risky. Are you sure in every
case that s->rxf_sts > 0? There's no way what's running in the VM can
game this and cause a buffer overrun? One caller to this function seems
to protect against this, and another does not.
Other than this, I didn't see any issues with this patch.
-corey
- [PATCH 0/6] hw/i2c: Add NPCM7XX SMBus Device, Hao Wu, 2021/01/26
- [PATCH 3/6] hw/arm: Add I2C device tree for NPCM750 eval board, Hao Wu, 2021/01/26
- [PATCH 2/6] hw/i2c: Implement NPCM7XX SMBus Module Single Mode, Hao Wu, 2021/01/26
- [PATCH 4/6] hw/arm: Add I2C device tree for Quanta GSJ, Hao Wu, 2021/01/26
- [PATCH 1/6] hw/arm: Remove GPIO from unimplemented NPCM7XX, Hao Wu, 2021/01/26
- [PATCH 5/6] hw/i2c: Add a QTest for NPCM7XX SMBus Device, Hao Wu, 2021/01/26
- [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode, Hao Wu, 2021/01/26
- Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode,
Corey Minyard <=
- Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode, Hao Wu, 2021/01/27
- Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode, Corey Minyard, 2021/01/27
- Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode, Hao Wu, 2021/01/27
- Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode, Corey Minyard, 2021/01/27
- Re: [PATCH 6/6] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode, Corey Minyard, 2021/01/28