All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Cocci] [PATCH v1] console: fix an issue about ioremap leak.
@ 2020-04-23 11:10 ` Markus Elfring
  0 siblings, 0 replies; 36+ messages in thread
From: Markus Elfring @ 2020-04-23 11:10 UTC (permalink / raw)
  To: Dejin Zheng, Bartlomiej Zolnierkiewicz, dri-devel, linux-fbdev,
	Coccinelle
  Cc: Thomas Bogendörfer, Florian Tobias Schandinat,
	Greg Kroah-Hartman, kernel-janitors, linux-kernel,
	Ralf Bächle, Andy Shevchenko, Thomas Gleixner

> if do_take_over_console() return an error in the newport_probe(),
> due to the io virtual address is not released, it will cause a leak.

How do you think about a wording variant like the following?

   Subject:
   [PATCH v2] console: Complete exception handling in newport_probe()

   Change description:
   A call of the function “do_take_over_console” can fail here.
   The corresponding system resources were not released then.
   Thus add a call of the function “iounmap” together with the check
   of a failure predicate.


I would like to point out that there is a script for the semantic
patch language which would detect other questionable source code.
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/scripts/coccinelle/free/iounmap.cocci

How do you think about to extend presented software analysis approaches?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 36+ messages in thread
* [PATCH v1] console: fix an issue about ioremap leak.
@ 2020-04-22 15:53 ` Dejin Zheng
  0 siblings, 0 replies; 36+ messages in thread
From: Dejin Zheng @ 2020-04-22 15:53 UTC (permalink / raw)
  To: b.zolnierkie, tglx, gregkh, tsbogend, FlorianSchandinat, ralf,
	dri-devel, linux-fbdev
  Cc: Dejin Zheng, Andy Shevchenko, linux-kernel

if do_take_over_console() return an error in the newport_probe(),
due to the io virtual address is not released, it will cause a leak.

Fixes: e84de0c6190503 ("MIPS: GIO bus support for SGI IP22/28")
CC: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
 drivers/video/console/newport_con.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index 00dddf6e08b0..6bfc8e3ffd4a 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -720,6 +720,9 @@ static int newport_probe(struct gio_device *dev,
 	console_lock();
 	err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
 	console_unlock();
+
+	if (err)
+		iounmap((void *)npregs);
 	return err;
 }
 
-- 
2.25.0

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

end of thread, other threads:[~2020-04-28 17:41 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-23 11:10 [Cocci] [PATCH v1] console: fix an issue about ioremap leak Markus Elfring
2020-04-23 11:10 ` Markus Elfring
2020-04-23 11:10 ` Markus Elfring
2020-04-23 11:10 ` Markus Elfring
2020-04-23 11:10 ` Markus Elfring
2020-04-23 14:29 ` [Cocci] " Dejin Zheng
2020-04-23 14:29   ` Dejin Zheng
2020-04-23 14:29   ` Dejin Zheng
2020-04-23 14:29   ` Dejin Zheng
2020-04-23 15:23   ` [Cocci] console: Complete exception handling in newport_probe() Markus Elfring
2020-04-23 15:23     ` Markus Elfring
2020-04-23 15:23     ` Markus Elfring
2020-04-23 15:23     ` Markus Elfring
2020-04-23 17:02     ` [Cocci] " Dejin Zheng
2020-04-23 17:02       ` Dejin Zheng
2020-04-23 17:02       ` Dejin Zheng
2020-04-23 17:02       ` Dejin Zheng
2020-04-23 17:22       ` [Cocci] " Markus Elfring
2020-04-23 17:22         ` Markus Elfring
2020-04-23 17:22         ` Markus Elfring
2020-04-23 17:22         ` Markus Elfring
2020-04-23 17:32       ` [Cocci] " Greg Kroah-Hartman
2020-04-23 17:32         ` Greg Kroah-Hartman
2020-04-23 17:32         ` Greg Kroah-Hartman
2020-04-23 17:32         ` Greg Kroah-Hartman
2020-04-23 17:43         ` [Cocci] " Markus Elfring
2020-04-23 17:43           ` Markus Elfring
2020-04-23 17:43           ` Markus Elfring
2020-04-23 17:43           ` Markus Elfring
2020-04-24  7:46       ` [Cocci] " Markus Elfring
2020-04-24  7:46         ` Markus Elfring
2020-04-24  7:46         ` Markus Elfring
2020-04-24  7:46         ` Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-04-22 15:53 [PATCH v1] console: fix an issue about ioremap leak Dejin Zheng
2020-04-22 15:53 ` Dejin Zheng
2020-04-22 15:53 ` Dejin Zheng

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.