mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] comedi: drivers: pcl730: Fix potential memory leak in pcl730_attach()
@ 2022-11-22 12:04 Shang XiaoJing
  2022-11-22 12:18 ` Ian Abbott
  0 siblings, 1 reply; 3+ messages in thread
From: Shang XiaoJing @ 2022-11-22 12:04 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh, linux-kernel; +Cc: shangxiaojing

pcl730_attach() calls comedi_request_region() and won't release the
resource allocated by alloc_resource() when pcl730_attach() failed latter.
Add release_region() to prevent memory leak.

Fixes: 6f9aa29b47f6 ("staging: comedi: pcl730: use comedi_request_region()")
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
---
 drivers/comedi/drivers/pcl730.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/comedi/drivers/pcl730.c b/drivers/comedi/drivers/pcl730.c
index d2733cd5383d..c463de8a14e1 100644
--- a/drivers/comedi/drivers/pcl730.c
+++ b/drivers/comedi/drivers/pcl730.c
@@ -274,8 +274,14 @@ static int pcl730_attach(struct comedi_device *dev,
 		return ret;
 
 	ret = comedi_alloc_subdevices(dev, board->n_subdevs);
-	if (ret)
+	if (ret) {
+		if (dev->iobase && dev->iolen) {
+			release_region(dev->iobase, dev->iolen);
+			dev->iobase = 0;
+			dev->iolen = 0;
+		}
 		return ret;
+	}
 
 	subdev = 0;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-22 12:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 12:04 [PATCH] comedi: drivers: pcl730: Fix potential memory leak in pcl730_attach() Shang XiaoJing
2022-11-22 12:18 ` Ian Abbott
2022-11-22 12:24   ` shangxiaojing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®