summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-11-27 13:29:24 +0200
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 12:05:23 +0200
commit0ffaeadfc451a11b5da35578b2f9b977f9f46489 (patch)
tree930739568abe771406bd9e9a01c11c8707958f42
parente16e12be34648777606a2c03a3526409b38f0e63 (diff)
downloadlinux-0ffaeadfc451a11b5da35578b2f9b977f9f46489.tar.bz2
mic_virtio: robust feature array size calculation
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>
-rw-r--r--drivers/misc/mic/card/mic_virtio.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c
index 4f070ad1875c..d5da9ff646cb 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);