linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: dm1105: Limit number of cards to avoid buffer over read
@ 2018-07-18 14:13 Anton Vasilyev
  0 siblings, 0 replies; only message in thread
From: Anton Vasilyev @ 2018-07-18 14:13 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Anton Vasilyev, Sean Young, Hans Verkuil, Arvind Yadav,
	Gustavo A. R. Silva, linux-media, linux-kernel, ldv-project

dm1105_probe() counts number of cards at dm1105_devcount,
but missed bounds check before dereference a card array.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
---
 drivers/media/pci/dm1105/dm1105.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c
index c9db108751a7..1ddb0576fb7b 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -986,6 +986,9 @@ static int dm1105_probe(struct pci_dev *pdev,
 	int ret = -ENOMEM;
 	int i;
 
+	if (dm1105_devcount >= ARRAY_SIZE(card))
+		return -ENODEV;
+
 	dev = kzalloc(sizeof(struct dm1105_dev), GFP_KERNEL);
 	if (!dev)
 		return -ENOMEM;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-18 14:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18 14:13 [PATCH] media: dm1105: Limit number of cards to avoid buffer over read Anton Vasilyev

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).