vdpa: Fix pointer math bug in vdpasim_get_config()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 6 Apr 2020 14:45:52 +0000 (17:45 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:15:16 +0000 (13:15 +0200)
commit5e8e8c3d96d428b0d24e7898f6dd5c2950fe5ce3
treec456bb93183b32145de533b564b4a0291d0c1c70
parent86e42d0d425b699eb18b36509bbe999e8b81b56b
vdpa: Fix pointer math bug in vdpasim_get_config()

[ Upstream commit cf16fe9243bfa2863491026fc727618c7c593c84 ]

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: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200406144552.GF68494@mwanda
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vdpa/vdpa_sim/vdpa_sim.c