| Date | Tue, 2 Dec 2014 11:13:46 +0100 | From | Thomas Huth <> | Subject | Re: [PATCH v8 03/50] mic_virtio: robust feature array size calculation |
| |
On Mon, 1 Dec 2014 18:02:59 +0200 "Michael S. Tsirkin" <mst@redhat.com> wrote:
> mic reads sizeof(vdev->features) bits from device, but in fact it stores > bits in local features variable. use sizeof(features) to make code > robust against future changes extending sizeof(vdev->features). > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > drivers/misc/mic/card/mic_virtio.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c > index 4f070ad..d5da9ff 100644 > --- a/drivers/misc/mic/card/mic_virtio.c > +++ b/drivers/misc/mic/card/mic_virtio.c > @@ -76,8 +76,7 @@ static u32 mic_get_features(struct virtio_device *vdev) > u8 __iomem *in_features = mic_vq_features(desc); > int feature_len = ioread8(&desc->feature_len); > > - bits = min_t(unsigned, feature_len, > - sizeof(vdev->features)) * 8; > + bits = min_t(unsigned, feature_len, sizeof(features)) * 8; > for (i = 0; i < bits; i++) > if (ioread8(&in_features[i / 8]) & (BIT(i % 8))) > features |= BIT(i);
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
|