Home Home > GIT Browse > SLE15
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-06-24 12:09:04 +0200
committerTakashi Iwai <tiwai@suse.de>2019-06-24 12:09:06 +0200
commit552e279a32de025f0e1384b77e2c9ac4d2c465cb (patch)
tree0130892dd66a65de3f1301c92366923933e3baf2
parentf1e8781cd9113244fc47e0ea78667ecbffed39c8 (diff)
can: af_can: Fix error path of can_init() (bsc#1051510).
-rw-r--r--patches.fixes/can-af_can-Fix-error-path-of-can_init.patch72
-rw-r--r--series.conf1
2 files changed, 73 insertions, 0 deletions
diff --git a/patches.fixes/can-af_can-Fix-error-path-of-can_init.patch b/patches.fixes/can-af_can-Fix-error-path-of-can_init.patch
new file mode 100644
index 0000000000..8213e83a0e
--- /dev/null
+++ b/patches.fixes/can-af_can-Fix-error-path-of-can_init.patch
@@ -0,0 +1,72 @@
+From c5a3aed1cd3152429348ee1fe5cdcca65fe901ce Mon Sep 17 00:00:00 2001
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Thu, 16 May 2019 22:36:26 +0800
+Subject: [PATCH] can: af_can: Fix error path of can_init()
+Git-commit: c5a3aed1cd3152429348ee1fe5cdcca65fe901ce
+Patch-mainline: v5.2-rc6
+References: bsc#1051510
+
+This patch add error path for can_init() to avoid possible crash if some
+error occurs.
+
+Fixes: 0d66548a10cb ("[CAN]: Add PF_CAN core module")
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
+Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ net/can/af_can.c | 24 +++++++++++++++++++++---
+ 1 file changed, 21 insertions(+), 3 deletions(-)
+
+diff --git a/net/can/af_can.c b/net/can/af_can.c
+index e8fd5dc1780a..743470680127 100644
+--- a/net/can/af_can.c
++++ b/net/can/af_can.c
+@@ -952,6 +952,8 @@ static struct pernet_operations can_pernet_ops __read_mostly = {
+
+ static __init int can_init(void)
+ {
++ int err;
++
+ /* check for correct padding to be able to use the structs similarly */
+ BUILD_BUG_ON(offsetof(struct can_frame, can_dlc) !=
+ offsetof(struct canfd_frame, len) ||
+@@ -965,15 +967,31 @@ static __init int can_init(void)
+ if (!rcv_cache)
+ return -ENOMEM;
+
+- register_pernet_subsys(&can_pernet_ops);
++ err = register_pernet_subsys(&can_pernet_ops);
++ if (err)
++ goto out_pernet;
+
+ /* protocol register */
+- sock_register(&can_family_ops);
+- register_netdevice_notifier(&can_netdev_notifier);
++ err = sock_register(&can_family_ops);
++ if (err)
++ goto out_sock;
++ err = register_netdevice_notifier(&can_netdev_notifier);
++ if (err)
++ goto out_notifier;
++
+ dev_add_pack(&can_packet);
+ dev_add_pack(&canfd_packet);
+
+ return 0;
++
++out_notifier:
++ sock_unregister(PF_CAN);
++out_sock:
++ unregister_pernet_subsys(&can_pernet_ops);
++out_pernet:
++ kmem_cache_destroy(rcv_cache);
++
++ return err;
+ }
+
+ static __exit void can_exit(void)
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 86ed7b2448..f6aca2c364 100644
--- a/series.conf
+++ b/series.conf
@@ -22611,6 +22611,7 @@
patches.fixes/0001-mwifiex-Fix-possible-buffer-overflows-at-parsing-bss.patch
patches.fixes/0001-mwifiex-Abort-at-too-short-BSS-descriptor-element.patch
patches.fixes/0001-mwifiex-Fix-heap-overflow-in-mwifiex_uap_parse_tail_.patch
+ patches.fixes/can-af_can-Fix-error-path-of-can_init.patch
patches.fixes/cfg80211-fix-memory-leak-of-wiphy-device-name.patch
patches.drivers/qmi_wwan-add-support-for-QMAP-padding-in-the-RX-path.patch
patches.drivers/qmi_wwan-add-network-device-usage-statistics-for-qmi.patch