Commit adcfdbde authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vivid: fix smatch warnings

Reorganize code to fix two smatch warnings:

drivers/media/platform/vivid/vivid-core.c: drivers/media/platform/vivid/vivid-core.c:889 vivid_create_instance() warn: potentially one past the end of array
'dev->query_dv_timings_qmenu[dev->query_dv_timings_size]'
drivers/media/platform/vivid/vivid-core.c: drivers/media/platform/vivid/vivid-core.c:889 vivid_create_instance() warn: potentially one past the end of array
'dev->query_dv_timings_qmenu[dev->query_dv_timings_size]'
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 8b8130f0
...@@ -625,6 +625,7 @@ static void vivid_dev_release(struct v4l2_device *v4l2_dev) ...@@ -625,6 +625,7 @@ static void vivid_dev_release(struct v4l2_device *v4l2_dev)
vfree(dev->bitmap_out); vfree(dev->bitmap_out);
tpg_free(&dev->tpg); tpg_free(&dev->tpg);
kfree(dev->query_dv_timings_qmenu); kfree(dev->query_dv_timings_qmenu);
kfree(dev->query_dv_timings_qmenu_strings);
kfree(dev); kfree(dev);
} }
...@@ -876,20 +877,31 @@ static int vivid_create_instance(struct platform_device *pdev, int inst) ...@@ -876,20 +877,31 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
if (!dev->edid) if (!dev->edid)
goto free_dev; goto free_dev;
/* create a string array containing the names of all the preset timings */
while (v4l2_dv_timings_presets[dev->query_dv_timings_size].bt.width) while (v4l2_dv_timings_presets[dev->query_dv_timings_size].bt.width)
dev->query_dv_timings_size++; dev->query_dv_timings_size++;
/*
* Create a char pointer array that points to the names of all the
* preset timings
*/
dev->query_dv_timings_qmenu = kmalloc_array(dev->query_dv_timings_size, dev->query_dv_timings_qmenu = kmalloc_array(dev->query_dv_timings_size,
(sizeof(void *) + 32), sizeof(char *), GFP_KERNEL);
GFP_KERNEL); /*
if (dev->query_dv_timings_qmenu == NULL) * Create a string array containing the names of all the preset
* timings. Each name is max 31 chars long (+ terminating 0).
*/
dev->query_dv_timings_qmenu_strings =
kmalloc_array(dev->query_dv_timings_size, 32, GFP_KERNEL);
if (!dev->query_dv_timings_qmenu ||
!dev->query_dv_timings_qmenu_strings)
goto free_dev; goto free_dev;
for (i = 0; i < dev->query_dv_timings_size; i++) { for (i = 0; i < dev->query_dv_timings_size; i++) {
const struct v4l2_bt_timings *bt = &v4l2_dv_timings_presets[i].bt; const struct v4l2_bt_timings *bt = &v4l2_dv_timings_presets[i].bt;
char *p = (char *)&dev->query_dv_timings_qmenu[dev->query_dv_timings_size]; char *p = dev->query_dv_timings_qmenu_strings + i * 32;
u32 htot, vtot; u32 htot, vtot;
p += i * 32;
dev->query_dv_timings_qmenu[i] = p; dev->query_dv_timings_qmenu[i] = p;
htot = V4L2_DV_BT_FRAME_WIDTH(bt); htot = V4L2_DV_BT_FRAME_WIDTH(bt);
......
...@@ -305,6 +305,7 @@ struct vivid_dev { ...@@ -305,6 +305,7 @@ struct vivid_dev {
enum vivid_signal_mode dv_timings_signal_mode; enum vivid_signal_mode dv_timings_signal_mode;
char **query_dv_timings_qmenu; char **query_dv_timings_qmenu;
char *query_dv_timings_qmenu_strings;
unsigned query_dv_timings_size; unsigned query_dv_timings_size;
unsigned query_dv_timings_last; unsigned query_dv_timings_last;
unsigned query_dv_timings; unsigned query_dv_timings;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment