media: media_device_enum_links32: clean a reserved field [Linux 4.9.187]

This Linux kernel change "media: media_device_enum_links32: clean a reserved field" is included in the Linux 4.9.187 release. This change is authored by Jungo Lin <jungo.lin [at] mediatek.com> on Tue Apr 2 21:44:27 2019 -0400. The commit for this change in Linux stable tree is 7897961 (patch) which is from upstream commit f493088. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream f493088.

media: media_device_enum_links32: clean a reserved field

[ Upstream commit f49308878d7202e07d8761238e01bd0e5fce2750 ]

In v4l2-compliance utility, test MEDIA_IOC_ENUM_ENTITIES
will check whether reserved field of media_links_enum filled
with zero.

However, for 32 bit program, the reserved field is missing
copy from kernel space to user space in media_device_enum_links32
function.

This patch adds the cleaning a reserved field logic in
media_device_enum_links32 function.

Signed-off-by: Jungo Lin <jungo.lin@mediatek.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>

There are 9 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/media/media-device.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 6f46c59..6062c0c 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -474,6 +474,7 @@ static long media_device_enum_links32(struct media_device *mdev,
 {
    struct media_links_enum links;
    compat_uptr_t pads_ptr, links_ptr;
+   int ret;

    memset(&links, 0, sizeof(links));

@@ -485,7 +486,13 @@ static long media_device_enum_links32(struct media_device *mdev,
    links.pads = compat_ptr(pads_ptr);
    links.links = compat_ptr(links_ptr);

-   return media_device_enum_links(mdev, &links);
+   ret = media_device_enum_links(mdev, &links);
+   if (ret)
+       return ret;
+
+   memset(ulinks->reserved, 0, sizeof(ulinks->reserved));
+
+   return 0;
 }

 #define MEDIA_IOC_ENUM_LINKS32     _IOWR('|', 0x02, struct media_links_enum32)

Leave a Reply

Your email address will not be published. Required fields are marked *