All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash
@ 2013-02-21 11:54 Shaik Ameer Basha
  2013-02-21 11:54 ` [PATCH] [media] fimc-lite: Initialize 'step' field in fimc_lite_ctrl structure Shaik Ameer Basha
  2013-03-07 14:51 ` [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash Sylwester Nawrocki
  0 siblings, 2 replies; 4+ messages in thread
From: Shaik Ameer Basha @ 2013-02-21 11:54 UTC (permalink / raw)
  To: linux-media; +Cc: s.nawrocki

Changing the variable type to 'int' from 'unsigned int'. Driver
logic expects the variable type to be 'int'.

Signed-off-by: Shaik Ameer Basha <shaik.ameer@samsung.com>
---
 drivers/media/platform/s5p-fimc/fimc-lite-reg.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
index f0af075..3c7dd65 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
@@ -128,7 +128,7 @@ static const u32 src_pixfmt_map[8][3] = {
 void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
 {
 	enum v4l2_mbus_pixelcode pixelcode = dev->fmt->mbus_code;
-	unsigned int i = ARRAY_SIZE(src_pixfmt_map);
+	int i = ARRAY_SIZE(src_pixfmt_map);
 	u32 cfg;
 
 	while (i-- >= 0) {
@@ -224,7 +224,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f)
 		{ V4L2_MBUS_FMT_VYUY8_2X8, FLITE_REG_CIODMAFMT_CRYCBY },
 	};
 	u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT);
-	unsigned int i = ARRAY_SIZE(pixcode);
+	int i = ARRAY_SIZE(pixcode);
 
 	while (i-- >= 0)
 		if (pixcode[i][0] == dev->fmt->mbus_code)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] [media] fimc-lite: Initialize 'step' field in fimc_lite_ctrl structure
  2013-02-21 11:54 [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash Shaik Ameer Basha
@ 2013-02-21 11:54 ` Shaik Ameer Basha
  2013-03-07 14:51 ` [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash Sylwester Nawrocki
  1 sibling, 0 replies; 4+ messages in thread
From: Shaik Ameer Basha @ 2013-02-21 11:54 UTC (permalink / raw)
  To: linux-media; +Cc: s.nawrocki

v4l2_ctrl_new() uses check_range() for control range checking.
This function expects 'step' value for V4L2_CTRL_TYPE_BOOLEAN type control.
If 'step' value doesn't match to '1', it returns -ERANGE error.

This patch adds the default .step value to 1.

Signed-off-by: Shaik Ameer Basha <shaik.ameer@samsung.com>
---
 drivers/media/platform/s5p-fimc/fimc-lite.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c b/drivers/media/platform/s5p-fimc/fimc-lite.c
index bfc4206..bbc35de 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -1408,6 +1408,7 @@ static const struct v4l2_ctrl_config fimc_lite_ctrl = {
 	.id	= V4L2_CTRL_CLASS_USER | 0x1001,
 	.type	= V4L2_CTRL_TYPE_BOOLEAN,
 	.name	= "Test Pattern 640x480",
+	.step	= 1,
 };
 
 static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash
  2013-02-21 11:54 [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash Shaik Ameer Basha
  2013-02-21 11:54 ` [PATCH] [media] fimc-lite: Initialize 'step' field in fimc_lite_ctrl structure Shaik Ameer Basha
@ 2013-03-07 14:51 ` Sylwester Nawrocki
  2013-03-08  6:07   ` Shaik Ameer Basha
  1 sibling, 1 reply; 4+ messages in thread
From: Sylwester Nawrocki @ 2013-03-07 14:51 UTC (permalink / raw)
  To: Shaik Ameer Basha; +Cc: linux-media

On 02/21/2013 12:54 PM, Shaik Ameer Basha wrote:
> Changing the variable type to 'int' from 'unsigned int'. Driver
> logic expects the variable type to be 'int'.
> 
> Signed-off-by: Shaik Ameer Basha <shaik.ameer@samsung.com>
> ---
>  drivers/media/platform/s5p-fimc/fimc-lite-reg.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
> index f0af075..3c7dd65 100644
> --- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
> +++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
> @@ -128,7 +128,7 @@ static const u32 src_pixfmt_map[8][3] = {
>  void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
>  {
>  	enum v4l2_mbus_pixelcode pixelcode = dev->fmt->mbus_code;
> -	unsigned int i = ARRAY_SIZE(src_pixfmt_map);
> +	int i = ARRAY_SIZE(src_pixfmt_map);
>  	u32 cfg;
>  
>  	while (i-- >= 0) {
> @@ -224,7 +224,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f)
>  		{ V4L2_MBUS_FMT_VYUY8_2X8, FLITE_REG_CIODMAFMT_CRYCBY },
>  	};
>  	u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT);
> -	unsigned int i = ARRAY_SIZE(pixcode);
> +	int i = ARRAY_SIZE(pixcode);
>  
>  	while (i-- >= 0)
>  		if (pixcode[i][0] == dev->fmt->mbus_code)
> 

There was a build warning like:

drivers/media/platform/s5p-fimc/fimc-lite-reg.c: In function ‘flite_hw_set_output_dma’:
drivers/media/platform/s5p-fimc/fimc-lite-reg.c:230: warning: array subscript is below array bounds
drivers/media/platform/s5p-fimc/fimc-lite-reg.c: In function ‘flite_hw_set_source_format’:
drivers/media/platform/s5p-fimc/fimc-lite-reg.c:135: warning: array subscript is below array bounds

thus I squashed following change before applying this patch:

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
index 3c7dd65..ac9663c 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
@@ -131,7 +131,7 @@ void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
        int i = ARRAY_SIZE(src_pixfmt_map);
        u32 cfg;
 
-       while (i-- >= 0) {
+       while (--i >= 0) {
                if (src_pixfmt_map[i][0] == pixelcode)
                        break;
        }
@@ -226,7 +226,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f)
        u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT);
        int i = ARRAY_SIZE(pixcode);
 
-       while (i-- >= 0)
+       while (--i >= 0)
                if (pixcode[i][0] == dev->fmt->mbus_code)
                        break;
        cfg &= ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK;

--

Regards,
Sylwester

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash
  2013-03-07 14:51 ` [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash Sylwester Nawrocki
@ 2013-03-08  6:07   ` Shaik Ameer Basha
  0 siblings, 0 replies; 4+ messages in thread
From: Shaik Ameer Basha @ 2013-03-08  6:07 UTC (permalink / raw)
  To: Sylwester Nawrocki; +Cc: linux-media

On Thu, Mar 7, 2013 at 8:21 PM, Sylwester Nawrocki
<s.nawrocki@samsung.com> wrote:
> On 02/21/2013 12:54 PM, Shaik Ameer Basha wrote:
>> Changing the variable type to 'int' from 'unsigned int'. Driver
>> logic expects the variable type to be 'int'.
>>
>> Signed-off-by: Shaik Ameer Basha <shaik.ameer@samsung.com>
>> ---
>>  drivers/media/platform/s5p-fimc/fimc-lite-reg.c |    4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
>> index f0af075..3c7dd65 100644
>> --- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
>> +++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
>> @@ -128,7 +128,7 @@ static const u32 src_pixfmt_map[8][3] = {
>>  void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
>>  {
>>       enum v4l2_mbus_pixelcode pixelcode = dev->fmt->mbus_code;
>> -     unsigned int i = ARRAY_SIZE(src_pixfmt_map);
>> +     int i = ARRAY_SIZE(src_pixfmt_map);
>>       u32 cfg;
>>
>>       while (i-- >= 0) {
>> @@ -224,7 +224,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f)
>>               { V4L2_MBUS_FMT_VYUY8_2X8, FLITE_REG_CIODMAFMT_CRYCBY },
>>       };
>>       u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT);
>> -     unsigned int i = ARRAY_SIZE(pixcode);
>> +     int i = ARRAY_SIZE(pixcode);
>>
>>       while (i-- >= 0)
>>               if (pixcode[i][0] == dev->fmt->mbus_code)
>>
>
> There was a build warning like:
>
> drivers/media/platform/s5p-fimc/fimc-lite-reg.c: In function ‘flite_hw_set_output_dma’:
> drivers/media/platform/s5p-fimc/fimc-lite-reg.c:230: warning: array subscript is below array bounds
> drivers/media/platform/s5p-fimc/fimc-lite-reg.c: In function ‘flite_hw_set_source_format’:
> drivers/media/platform/s5p-fimc/fimc-lite-reg.c:135: warning: array subscript is below array bounds
>
> thus I squashed following change before applying this patch:

Thanks for that :)

-Shaik

>
> diff --git a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
> index 3c7dd65..ac9663c 100644
> --- a/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
> +++ b/drivers/media/platform/s5p-fimc/fimc-lite-reg.c
> @@ -131,7 +131,7 @@ void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
>         int i = ARRAY_SIZE(src_pixfmt_map);
>         u32 cfg;
>
> -       while (i-- >= 0) {
> +       while (--i >= 0) {
>                 if (src_pixfmt_map[i][0] == pixelcode)
>                         break;
>         }
> @@ -226,7 +226,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f)
>         u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT);
>         int i = ARRAY_SIZE(pixcode);
>
> -       while (i-- >= 0)
> +       while (--i >= 0)
>                 if (pixcode[i][0] == dev->fmt->mbus_code)
>                         break;
>         cfg &= ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK;
>
> --
>
> Regards,
> Sylwester
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-08  6:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-21 11:54 [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash Shaik Ameer Basha
2013-02-21 11:54 ` [PATCH] [media] fimc-lite: Initialize 'step' field in fimc_lite_ctrl structure Shaik Ameer Basha
2013-03-07 14:51 ` [PATCH] [media] fimc-lite: Fix the variable type to avoid possible crash Sylwester Nawrocki
2013-03-08  6:07   ` Shaik Ameer Basha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.