summaryrefslogtreecommitdiffstats
path: root/drivers/staging/media
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-05-27 16:38:12 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-06-09 15:19:03 +0100
commitfadac6afccf7d8a4efa1e0ca89958f6716685333 (patch)
tree55c23c991687ddd7613f3e35b3adef64c7c173c1 /drivers/staging/media
parent1657f2934daf89e8d9fa4b2697008909eb22c73e (diff)
downloadlinux-fadac6afccf7d8a4efa1e0ca89958f6716685333.tar.gz
linux-fadac6afccf7d8a4efa1e0ca89958f6716685333.tar.bz2
linux-fadac6afccf7d8a4efa1e0ca89958f6716685333.zip
media: atomisp: Fix buffer overrun in gmin_get_var_int()
Not all functions used in gmin_get_var_int() update len to the actual length of the returned string. So len may still have its initial value of the length of val[] when "val[len] = 0;" is run to ensure 0 termination. If this happens we end up writing one beyond the bounds of val[], fix this. Note this is a quick fix for this since the entirety of atomisp_gmin_platform.c will be removed once all atomisp sensor drivers have been moved over to runtime-pm + v4l2-async device registration. Closes: https://lore.kernel.org/linux-media/26f37e19-c240-4d77-831d-ef3f1a4dd51d@kili.mountain/ Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/staging/media')
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 93bfb3fadcf7..139ad7ad1dcf 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -1429,8 +1429,8 @@ static int gmin_get_config_var(struct device *maindev,
int gmin_get_var_int(struct device *dev, bool is_gmin, const char *var, int def)
{
- char val[CFG_VAR_NAME_MAX];
- size_t len = sizeof(val);
+ char val[CFG_VAR_NAME_MAX + 1];
+ size_t len = CFG_VAR_NAME_MAX;
long result;
int ret;