diff mbox series

[v4] Input: i8042 add i8042_is_mr_coffee() helper to avoid refconut leak

Message ID 20181212163548.23723-1-tiny.windzz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v4] Input: i8042 add i8042_is_mr_coffee() helper to avoid refconut leak | expand

Commit Message

Yangtao Li Dec. 12, 2018, 4:35 p.m. UTC
of_find_node_by_path() acquires a reference to the node returned by
it and that reference needs to be dropped by its caller. Add
i8042_is_mr_coffee() helper to avoid refconut leak.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
changes in v4:
-fix typo

changes in v3:
-add i8042_is_mr_coffee
---
 drivers/input/serio/i8042-sparcio.h | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

Comments

kernel test robot Dec. 14, 2018, 2:27 a.m. UTC | #1
Hi Yangtao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on input/next]
[also build test ERROR on v4.20-rc6 next-20181213]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Yangtao-Li/Input-i8042-add-i8042_is_mr_coffee-helper-to-avoid-refconut-leak/20181214-043211
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

   In file included from drivers/input/serio/i8042.h:26:0,
                    from drivers/input/serio/i8042.c:132:
   drivers/input/serio/i8042-sparcio.h: In function 'i8042_is_mr_coffee':
>> drivers/input/serio/i8042-sparcio.h:115:2: error: 'is_mr_coffree' undeclared (first use in this function); did you mean 'is_mr_coffee'?
     is_mr_coffree = !strcmp(root->name, "SUNW,JavaStation-1");
     ^~~~~~~~~~~~~
     is_mr_coffee
   drivers/input/serio/i8042-sparcio.h:115:2: note: each undeclared identifier is reported only once for each function it appears in

vim +115 drivers/input/serio/i8042-sparcio.h

   108	
   109	static inline bool i8042_is_mr_coffee(void)
   110	{
   111		struct device_node *root;
   112		bool is_mr_coffee;
   113	
   114		root = of_find_node_by_path("/");
 > 115		is_mr_coffree = !strcmp(root->name, "SUNW,JavaStation-1");
   116		of_node_put(root);
   117	
   118		return is_mr_coffee;
   119	}
   120	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
index 796289846204..28aa154d9c81 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -106,11 +106,23 @@  static struct platform_driver sparc_i8042_driver = {
 	.remove		= sparc_i8042_remove,
 };
 
+static inline bool i8042_is_mr_coffee(void)
+{
+	struct device_node *root;
+	bool is_mr_coffee;
+
+	root = of_find_node_by_path("/");
+	is_mr_coffree = !strcmp(root->name, "SUNW,JavaStation-1");
+	of_node_put(root);
+
+	return is_mr_coffee;
+}
+
 static int __init i8042_platform_init(void)
 {
-	struct device_node *root = of_find_node_by_path("/");
+	bool match = i8042_is_mr_coffee();
 
-	if (!strcmp(root->name, "SUNW,JavaStation-1")) {
+	if (match) {
 		/* Hardcoded values for MrCoffee.  */
 		i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
 		kbd_iobase = ioremap(0x71300060, 8);
@@ -138,9 +150,9 @@  static int __init i8042_platform_init(void)
 
 static inline void i8042_platform_exit(void)
 {
-	struct device_node *root = of_find_node_by_path("/");
+	bool match = i8042_is_mr_coffee();
 
-	if (strcmp(root->name, "SUNW,JavaStation-1"))
+	if (!match)
 		platform_driver_unregister(&sparc_i8042_driver);
 }