[<prev] [next>] [day] [month] [year] [list]
Message-ID: <9e067488d8935b8cf00959764a1fa5de85d65725.1730926254.git.mchehab+huawei@kernel.org>
Date: Wed, 6 Nov 2024 21:50:55 +0100
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To:
Cc: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Dan Carpenter <dan.carpenter@...aro.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Ricardo Ribalda <ribalda@...omium.org>,
Zhipeng Lu <alexious@....edu.cn>,
linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org,
kernel test robot <lkp@...el.com>
Subject: [PATCH] dvbdev: fix the logic when DVB_DYNAMIC_MINORS is not set
When CONFIG_DVB_DYNAMIC_MINORS, ret is not initialized, and a
semaphore is left at the wrong state, in case of errors.
Make the code simpler and avoid mistakes by having just one error
check logic used weather DVB_DYNAMIC_MINORS is used or not.
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
Closes: https://lore.kernel.org/r/202410201717.ULWWdJv8-lkp@intel.com/
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
---
drivers/media/dvb-core/dvbdev.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 14f323fbada7..9df7c213716a 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -530,30 +530,23 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
for (minor = 0; minor < MAX_DVB_MINORS; minor++)
if (!dvb_minors[minor])
break;
- if (minor >= MAX_DVB_MINORS) {
- if (new_node) {
- list_del(&new_node->list_head);
- kfree(dvbdevfops);
- kfree(new_node);
- }
- list_del(&dvbdev->list_head);
- kfree(dvbdev);
- *pdvbdev = NULL;
- up_write(&minor_rwsem);
- mutex_unlock(&dvbdev_register_lock);
- return -EINVAL;
- }
#else
minor = nums2minor(adap->num, type, id);
+#endif
if (minor >= MAX_DVB_MINORS) {
- dvb_media_device_free(dvbdev);
+ if (new_node) {
+ list_del(&new_node->list_head);
+ kfree(dvbdevfops);
+ kfree(new_node);
+ }
list_del(&dvbdev->list_head);
kfree(dvbdev);
*pdvbdev = NULL;
+ up_write(&minor_rwsem);
mutex_unlock(&dvbdev_register_lock);
- return ret;
+ return -EINVAL;
}
-#endif
+
dvbdev->minor = minor;
dvb_minors[minor] = dvb_device_get(dvbdev);
up_write(&minor_rwsem);
--
2.47.0
Powered by blists - more mailing lists