提交 36203e71 编写于 作者: J Jes Sorensen 提交者: Greg Kroah-Hartman

staging: unisys: visorchannel_read(): Use memcpy_fromio() directly

Note, this changes the behavior of visorchannel_read(). The old code
would return the channel header, if the offset argument was 0, and the
caller tried to read beyond the size of the visorchannel. Note this
only worked for offset == 0, but not for
(offset > 0) && (offset < header_size), which was inconsistent.

The new implementation returns an error if someone tries to read
beyond the visorchannel size.
Signed-off-by: NJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 ad44088f
......@@ -200,13 +200,12 @@ int
visorchannel_read(struct visorchannel *channel, ulong offset,
void *local, ulong nbytes)
{
int rc;
size_t size = sizeof(struct channel_header);
if (offset + nbytes > channel->memregion.nbytes)
return -EIO;
rc = visor_memregion_read(&channel->memregion, offset, local, nbytes);
if (rc && !offset && (nbytes >= size))
memcpy(&channel->chan_hdr, local, size);
return rc;
memcpy_fromio(local, channel->memregion.mapped + offset, nbytes);
return 0;
}
EXPORT_SYMBOL_GPL(visorchannel_read);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册