* [PATCH 1/1] media: v4l: Guarantee non-NULL return from v4l2_find_nearest_size()
@ 2024-04-15 6:04 Sakari Ailus
2024-04-22 9:36 ` Hans Verkuil
0 siblings, 1 reply; 2+ messages in thread
From: Sakari Ailus @ 2024-04-15 6:04 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil, Mikhail Rudenko
Guarantee that v4l2_find_nearest_size() returns a non-NULL value when the
mode array passed to it has non-zero number of entries.
Fixes: 95ce9c28601a ("media: v4l: common: Add a function to obtain best size from a list")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index d34d210908d9..12e8cbe92d7c 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -159,7 +159,7 @@ __v4l2_find_nearest_size(const void *array, size_t array_size,
size_t height_offset, s32 width, s32 height)
{
u32 error, min_error = U32_MAX;
- const void *best = NULL;
+ const void *best = array;
unsigned int i;
if (!array)
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] media: v4l: Guarantee non-NULL return from v4l2_find_nearest_size()
2024-04-15 6:04 [PATCH 1/1] media: v4l: Guarantee non-NULL return from v4l2_find_nearest_size() Sakari Ailus
@ 2024-04-22 9:36 ` Hans Verkuil
0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2024-04-22 9:36 UTC (permalink / raw)
To: Sakari Ailus, linux-media; +Cc: Mikhail Rudenko
On 15/04/2024 08:04, Sakari Ailus wrote:
> Guarantee that v4l2_find_nearest_size() returns a non-NULL value when the
> mode array passed to it has non-zero number of entries.
>
> Fixes: 95ce9c28601a ("media: v4l: common: Add a function to obtain best size from a list")
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> drivers/media/v4l2-core/v4l2-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index d34d210908d9..12e8cbe92d7c 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -159,7 +159,7 @@ __v4l2_find_nearest_size(const void *array, size_t array_size,
> size_t height_offset, s32 width, s32 height)
> {
> u32 error, min_error = U32_MAX;
> - const void *best = NULL;
> + const void *best = array;
> unsigned int i;
>
> if (!array)
Has this actually been observed? I don't think it is possible for this
to happen. In fact, I think this actually introduces a new bug: if
array != NULL and array_size == 0, then this would return NULL (correct),
but with this patch it returns 'array' (wrong).
I will drop this patch from the PR until this is clarified.
If this issue was observed, then I can't help thinking that this patch
just addresses the symptom and not the underlying cause.
Regards,
Hans
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-22 9:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15 6:04 [PATCH 1/1] media: v4l: Guarantee non-NULL return from v4l2_find_nearest_size() Sakari Ailus
2024-04-22 9:36 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).