All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: linuxarm@huawei.com, mauro.chehab@huawei.com,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Dinghao Liu <dinghao.liu@zju.edu.cn>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Peilin Ye <yepeilin.cs@gmail.com>, Sean Young <sean@mess.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 03/11] media: dvbdev: fix error logic at dvb_register_device()
Date: Wed, 16 Jun 2021 14:28:29 +0200	[thread overview]
Message-ID: <56a94235a78b2313661154d6802dd8d3b9864de7.1623846327.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1623846327.git.mchehab+huawei@kernel.org>

As reported by smatch:

	drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:510 dvb_register_device() warn: '&dvbdev->list_head' not removed from list
	drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:530 dvb_register_device() warn: '&dvbdev->list_head' not removed from list
	drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:545 dvb_register_device() warn: '&dvbdev->list_head' not removed from list

The error logic inside dvb_register_device() doesn't remove
devices from the dvb_adapter_list in case of errors.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/dvb-core/dvbdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 3862ddc86ec4..795d9bfaba5c 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -506,6 +506,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 			break;
 
 	if (minor == MAX_DVB_MINORS) {
+		list_del (&dvbdev->list_head);
 		kfree(dvbdevfops);
 		kfree(dvbdev);
 		up_write(&minor_rwsem);
@@ -526,6 +527,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 		      __func__);
 
 		dvb_media_device_free(dvbdev);
+		list_del (&dvbdev->list_head);
 		kfree(dvbdevfops);
 		kfree(dvbdev);
 		mutex_unlock(&dvbdev_register_lock);
@@ -541,6 +543,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 		pr_err("%s: failed to create device dvb%d.%s%d (%ld)\n",
 		       __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
 		dvb_media_device_free(dvbdev);
+		list_del (&dvbdev->list_head);
 		kfree(dvbdevfops);
 		kfree(dvbdev);
 		return PTR_ERR(clsdev);
-- 
2.31.1


  parent reply	other threads:[~2021-06-16 12:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 12:28 [PATCH 00/11] Address some smatch warnings Mauro Carvalho Chehab
2021-06-16 12:28 ` Mauro Carvalho Chehab
2021-06-16 12:28 ` Mauro Carvalho Chehab
2021-06-16 12:28 ` [PATCH 01/11] media: dvb_ca_en50221: avoid speculation from CA slot Mauro Carvalho Chehab
2021-06-16 12:28 ` [PATCH 02/11] media: dvb_net: avoid speculation from net slot Mauro Carvalho Chehab
2021-06-16 12:28 ` Mauro Carvalho Chehab [this message]
2021-06-16 12:28 ` [PATCH 04/11] media: sun6i-csi: add a missing return code Mauro Carvalho Chehab
2021-06-16 12:28   ` Mauro Carvalho Chehab
2021-06-16 12:28   ` Mauro Carvalho Chehab
2021-06-17  5:37   ` yong
2021-06-17  5:37     ` yong
2021-06-16 12:28 ` [PATCH 05/11] media: saa7134: use more meaninful goto labels Mauro Carvalho Chehab
2021-06-16 12:28 ` [PATCH 06/11] media: saa7134: fix saa7134_initdev error handling logic Mauro Carvalho Chehab
2021-06-16 12:28 ` [PATCH 07/11] media: siano: fix device register error path Mauro Carvalho Chehab
2021-06-16 12:28 ` [PATCH 08/11] media: adv7842: better document EDID block size Mauro Carvalho Chehab
2021-06-16 12:32   ` Hans Verkuil
2021-06-17  6:26   ` kernel test robot
2021-06-17  6:26     ` kernel test robot
2021-06-17  8:15   ` kernel test robot
2021-06-17  8:15     ` kernel test robot
2021-06-16 12:28 ` [PATCH 09/11] media: ttusb-dec: cleanup an error handling logic Mauro Carvalho Chehab
2021-06-16 12:28 ` [PATCH 10/11] media: dvb-core: frontend: make GET/SET safer Mauro Carvalho Chehab
2021-06-16 12:28 ` [PATCH 11/11] media: xilinx: simplify get fourcc logic Mauro Carvalho Chehab
2021-06-16 12:28   ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56a94235a78b2313661154d6802dd8d3b9864de7.1623846327.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=dinghao.liu@zju.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mauro.chehab@huawei.com \
    --cc=mchehab@kernel.org \
    --cc=sean@mess.org \
    --cc=yepeilin.cs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.