drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++++ 1 file changed, 4 insertions(+)
The NULL check added for fled_cdev before dereference.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru>
Fixes: 42bd6f59ae90 ("media: Add registration helpers for V4L2 flash sub-devices")
---
drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index 355595a0fefa..36cc46e80eea 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -291,12 +291,16 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c)
* No conversion is needed as LED Flash class also uses
* microseconds for flash timeout units.
*/
+ if (!fled_cdev)
+ return -EINVAL;
return led_set_flash_timeout(fled_cdev, c->val);
case V4L2_CID_FLASH_INTENSITY:
/*
* No conversion is needed as LED Flash class also uses
* microamperes for flash intensity units.
*/
+ if (!fled_cdev)
+ return -EINVAL;
return led_set_flash_brightness(fled_cdev, c->val);
}
--
2.25.1
Hi Alexandr, On Wed, Dec 07, 2022 at 05:18:07PM +0300, Aleksandr Burakov wrote: > The NULL check added for fled_cdev before dereference. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru> > Fixes: 42bd6f59ae90 ("media: Add registration helpers for V4L2 flash sub-devices") > --- > drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c > index 355595a0fefa..36cc46e80eea 100644 > --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c > +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c > @@ -291,12 +291,16 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c) > * No conversion is needed as LED Flash class also uses > * microseconds for flash timeout units. > */ > + if (!fled_cdev) > + return -EINVAL; > return led_set_flash_timeout(fled_cdev, c->val); > case V4L2_CID_FLASH_INTENSITY: > /* > * No conversion is needed as LED Flash class also uses > * microamperes for flash intensity units. > */ > + if (!fled_cdev) > + return -EINVAL; > return led_set_flash_brightness(fled_cdev, c->val); > } > fled_cdev won't be NULL above, this is checked elsewhere in the V4L2 flash LED class code. I guess the question then is whether doing such a check is meaningful. It would require a bug elsewhere in the code to happen. -- Kind regards, Sakari Ailus
&cmd->asiv of size 96 can overflow because its index (asiv_offs + 8)
can be equal to 96 (0x58 + 0x08) that is out of range.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru>
Fixes: eaf4722d4645 ("GenWQE Character device and DDCB queue")
---
drivers/misc/genwqe/card_dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c
index 55fc5b80e649..d58ce2622307 100644
--- a/drivers/misc/genwqe/card_dev.c
+++ b/drivers/misc/genwqe/card_dev.c
@@ -867,7 +867,7 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req)
struct genwqe_ddcb_cmd *cmd = &req->cmd;
struct dma_mapping *m;
- for (i = 0, asiv_offs = 0x00; asiv_offs <= 0x58;
+ for (i = 0, asiv_offs = 0x00; asiv_offs < 0x58;
i++, asiv_offs += 0x08) {
u64 u_addr;
--
2.25.1
On Wed, Dec 07, 2022 at 05:18:08PM +0300, Aleksandr Burakov wrote: > &cmd->asiv of size 96 can overflow because its index (asiv_offs + 8) > can be equal to 96 (0x58 + 0x08) that is out of range. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru> > Fixes: eaf4722d4645 ("GenWQE Character device and DDCB queue") > --- > drivers/misc/genwqe/card_dev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c > index 55fc5b80e649..d58ce2622307 100644 > --- a/drivers/misc/genwqe/card_dev.c > +++ b/drivers/misc/genwqe/card_dev.c > @@ -867,7 +867,7 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req) > struct genwqe_ddcb_cmd *cmd = &req->cmd; > struct dma_mapping *m; > > - for (i = 0, asiv_offs = 0x00; asiv_offs <= 0x58; > + for (i = 0, asiv_offs = 0x00; asiv_offs < 0x58; > i++, asiv_offs += 0x08) { > > u64 u_addr; > -- > 2.25.1 > Where is patch 1/2 of this series?
Hello! The subject was created this way due to technical issues. There is only one patch here. With best regards, A. Burakov ----- Исходное сообщение ----- От: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org> Кому: "Александр Бураков" <a.burakov@rosalinux.ru> Копия: "Frank Haverkamp" <haver@linux.ibm.com>, "Arnd Bergmann" <arnd@arndb.de>, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Отправленные: Среда, 7 Декабрь 2022 г 19:23:12 Тема: Re: [PATCH 2/2] misc: genwqe: card_dev: Array index overflow fix in ddcb_cmd_fixups() On Wed, Dec 07, 2022 at 05:18:08PM +0300, Aleksandr Burakov wrote: > &cmd->asiv of size 96 can overflow because its index (asiv_offs + 8) > can be equal to 96 (0x58 + 0x08) that is out of range. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru> > Fixes: eaf4722d4645 ("GenWQE Character device and DDCB queue") > --- > drivers/misc/genwqe/card_dev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c > index 55fc5b80e649..d58ce2622307 100644 > --- a/drivers/misc/genwqe/card_dev.c > +++ b/drivers/misc/genwqe/card_dev.c > @@ -867,7 +867,7 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req) > struct genwqe_ddcb_cmd *cmd = &req->cmd; > struct dma_mapping *m; > > - for (i = 0, asiv_offs = 0x00; asiv_offs <= 0x58; > + for (i = 0, asiv_offs = 0x00; asiv_offs < 0x58; > i++, asiv_offs += 0x08) { > > u64 u_addr; > -- > 2.25.1 > Where is patch 1/2 of this series?
A: http://en.wikipedia.org/wiki/Top_post Q: Were do I find info about this thing called top-posting? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? A: No. Q: Should I include quotations after my reply? http://daringfireball.net/2007/07/on_top On Thu, Dec 08, 2022 at 01:55:01PM +0300, Александр Бураков wrote: > Hello! > > The subject was created this way due to technical issues. There is only one patch here. Great, then please fix up those issues and resend a version 2 of this patch, otherwise it confuses us all. Please remember that we optimize for review, and as such, if you make a mistake like this, it's up to you to fix it up, not us. thanks, greg k-h
© 2016 - 2025 Red Hat, Inc.