LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH -next] net: ax25: Fix error path of ax25_init()
@ 2021-07-31  7:27 Zheng Yongjun
  2021-07-31  9:25 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yongjun @ 2021-07-31  7:27 UTC (permalink / raw)
  To: jreuter, ralf, davem, kuba, linux-hams, netdev, linux-kernel

This patch add error path for ax25_init() to avoid possible crash if some
error occurs.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/ax25/af_ax25.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 2631efc..4edc322 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1977,17 +1977,32 @@ static int __init ax25_init(void)
 {
 	int rc = proto_register(&ax25_proto, 0);
 
-	if (rc != 0)
+	if (rc)
 		goto out;
 
-	sock_register(&ax25_family_ops);
-	dev_add_pack(&ax25_packet_type);
-	register_netdevice_notifier(&ax25_dev_notifier);
+	rc = sock_register(&ax25_family_ops);
+	if (rc)
+		goto out_proto;
+	rc = dev_add_pack(&ax25_packet_type);
+	if (rc)
+		goto out_sock;
+	rc = register_netdevice_notifier(&ax25_dev_notifier);
+	if (rc)
+		goto out_dev;
 
 	proc_create_seq("ax25_route", 0444, init_net.proc_net, &ax25_rt_seqops);
 	proc_create_seq("ax25", 0444, init_net.proc_net, &ax25_info_seqops);
 	proc_create_seq("ax25_calls", 0444, init_net.proc_net,
 			&ax25_uid_seqops);
+
+	return 0;
+
+out_dev:
+	dev_remove_pack(&ax25_packet_type);
+out_sock:
+	sock_unregister(PF_AX25);
+out_proto:
+	proto_unregister(&ax25_proto);
 out:
 	return rc;
 }
-- 
2.9.4


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

* Re: [PATCH -next] net: ax25: Fix error path of ax25_init()
  2021-07-31  7:27 [PATCH -next] net: ax25: Fix error path of ax25_init() Zheng Yongjun
@ 2021-07-31  9:25 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-07-31  9:25 UTC (permalink / raw)
  To: Zheng Yongjun, jreuter, ralf, davem, kuba, linux-hams, netdev,
	linux-kernel
  Cc: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2545 bytes --]

Hi Zheng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210730]

url:    https://github.com/0day-ci/linux/commits/Zheng-Yongjun/net-ax25-Fix-error-path-of-ax25_init/20210731-153149
base:    8d4b477da1a807199ca60e0829357ce7aa6758d5
config: riscv-randconfig-r022-20210730 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/add0b8cab6f698386d51feb5d99180059fad64e3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Zheng-Yongjun/net-ax25-Fix-error-path-of-ax25_init/20210731-153149
        git checkout add0b8cab6f698386d51feb5d99180059fad64e3
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=riscv SHELL=/bin/bash net/ax25/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   net/ax25/af_ax25.c: In function 'ax25_init':
>> net/ax25/af_ax25.c:1986:5: error: void value not ignored as it ought to be
    1986 |  rc = dev_add_pack(&ax25_packet_type);
         |     ^


vim +1986 net/ax25/af_ax25.c

  1975	
  1976	static int __init ax25_init(void)
  1977	{
  1978		int rc = proto_register(&ax25_proto, 0);
  1979	
  1980		if (rc)
  1981			goto out;
  1982	
  1983		rc = sock_register(&ax25_family_ops);
  1984		if (rc)
  1985			goto out_proto;
> 1986		rc = dev_add_pack(&ax25_packet_type);
  1987		if (rc)
  1988			goto out_sock;
  1989		rc = register_netdevice_notifier(&ax25_dev_notifier);
  1990		if (rc)
  1991			goto out_dev;
  1992	
  1993		proc_create_seq("ax25_route", 0444, init_net.proc_net, &ax25_rt_seqops);
  1994		proc_create_seq("ax25", 0444, init_net.proc_net, &ax25_info_seqops);
  1995		proc_create_seq("ax25_calls", 0444, init_net.proc_net,
  1996				&ax25_uid_seqops);
  1997	
  1998		return 0;
  1999	
  2000	out_dev:
  2001		dev_remove_pack(&ax25_packet_type);
  2002	out_sock:
  2003		sock_unregister(PF_AX25);
  2004	out_proto:
  2005		proto_unregister(&ax25_proto);
  2006	out:
  2007		return rc;
  2008	}
  2009	module_init(ax25_init);
  2010	
  2011	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35141 bytes --]

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

end of thread, other threads:[~2021-07-31  9:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31  7:27 [PATCH -next] net: ax25: Fix error path of ax25_init() Zheng Yongjun
2021-07-31  9:25 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).