Skip to content

Commit cf16fe9

Browse files
Dan Carpentermstsirkin
authored andcommitted
vdpa: Fix pointer math bug in vdpasim_get_config()
If "offset" is non-zero then we end up copying from beyond the end of the config because of pointer math. We can fix this by casting the struct to a u8 pointer. Fixes: 2c53d0f ("vdpasim: vDPA device simulator") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/20200406144552.GF68494@mwanda Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 2874211 commit cf16fe9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset,
558558
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
559559

560560
if (offset + len < sizeof(struct virtio_net_config))
561-
memcpy(buf, &vdpasim->config + offset, len);
561+
memcpy(buf, (u8 *)&vdpasim->config + offset, len);
562562
}
563563

564564
static void vdpasim_set_config(struct vdpa_device *vdpa, unsigned int offset,

0 commit comments

Comments
 (0)