Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] s3c-camif: forever loop in camif_hw_set_source_format()

Because "i" is unsigned then "i-- >= 0" is always true. If we don't
find what we are looking for then we loop forever.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Dan Carpenter and committed by
Mauro Carvalho Chehab
d345a5e5 5c47776a

+4 -4
+4 -4
drivers/media/platform/s3c-camif/camif-regs.c
··· 106 106 void camif_hw_set_source_format(struct camif_dev *camif) 107 107 { 108 108 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; 109 - unsigned int i = ARRAY_SIZE(src_pixfmt_map); 109 + int i; 110 110 u32 cfg; 111 111 112 - while (i-- >= 0) { 112 + for (i = ARRAY_SIZE(src_pixfmt_map) - 1; i >= 0; i--) { 113 113 if (src_pixfmt_map[i][0] == mf->code) 114 114 break; 115 115 } 116 - 117 - if (i == 0 && src_pixfmt_map[i][0] != mf->code) { 116 + if (i < 0) { 117 + i = 0; 118 118 dev_err(camif->dev, 119 119 "Unsupported pixel code, falling back to %#08x\n", 120 120 src_pixfmt_map[i][0]);