[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240801135649.76995-1-m.lobanov@rosalinux.ru>
Date: Thu, 1 Aug 2024 09:54:28 -0400
From: Mikhail Lobanov <m.lobanov@...alinux.ru>
To: Hans Verkuil <hverkuil-cisco@...all.nl>
Cc: Mikhail Lobanov <m.lobanov@...alinux.ru>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org,
lvc-project@...uxtesting.org
Subject:
Subject: [PATCH] cobalt: adding a check to the driver
This patch addresses an issue in cobalt-flash.c where the return value of the mtd_device_register function,
was not being checked. This omission could lead to unhandled errors if the registration fails.
The patch adds error handling by checking the return value and logging an error message if registration fails.
It ensures that the function returns the appropriate error code, improving error detection and the robustness
of the code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 85756a069c55 ("[media] cobalt: add new driver")
Signed-off-by: Mikhail Lobanov <m.lobanov@...alinux.ru>
---
drivers/media/pci/cobalt/cobalt-flash.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/media/pci/cobalt/cobalt-flash.c b/drivers/media/pci/cobalt/cobalt-flash.c
index 1d3c64b4cf6d..06ad9aaeff1b 100644
--- a/drivers/media/pci/cobalt/cobalt-flash.c
+++ b/drivers/media/pci/cobalt/cobalt-flash.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0-only
+/// SPDX-License-Identifier: GPL-2.0-only
/*
* Cobalt NOR flash functions
*
@@ -104,6 +104,10 @@ int cobalt_flash_probe(struct cobalt *cobalt)
mtd->owner = THIS_MODULE;
mtd->dev.parent = &cobalt->pci_dev->dev;
mtd_device_register(mtd, NULL, 0);
+ if (ret) {
+ cobalt_err("Registering MTD device failed with error %d\n", ret);
+ return ret;
+ }
return 0;
}
--
2.43.0
Powered by blists - more mailing lists