diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-13 11:28:06 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-13 11:28:06 +0100 |
| commit | b74a449f1a312d7d30c4738ead06c5751e5160f4 (patch) | |
| tree | c364049eca1c6690bfac8197fe0f4c326a241ff0 | |
| parent | e89b7388846e2b8aa288676365671f7ab9b7cee7 (diff) | |
| download | patches-b74a449f1a312d7d30c4738ead06c5751e5160f4.tar.gz | |
updated patches
| -rw-r--r-- | 0001-Bluetooth-check-message-types-in-l2cap_get_conf_opt.patch | 95 | ||||
| -rw-r--r-- | 0002-Bluetooth-check-the-buffer-size-for-some-messages-be.patch | 60 | ||||
| -rw-r--r-- | 0003-IN_BADCLASS-fix-macro-to-actually-work.patch | 32 | ||||
| -rw-r--r-- | p00 | 44 | ||||
| -rw-r--r-- | p01 | 68 | ||||
| -rw-r--r-- | p02 | 218 | ||||
| -rw-r--r-- | p03 | 300 | ||||
| -rw-r--r-- | p04 | 598 | ||||
| -rw-r--r-- | p05 | 113 | ||||
| -rw-r--r-- | p06 | 125 | ||||
| -rw-r--r-- | p07 | 146 | ||||
| -rw-r--r-- | p08 | 140 | ||||
| -rw-r--r-- | p09 | 59 | ||||
| -rw-r--r-- | p10 | 83 | ||||
| -rw-r--r-- | p11 | 177 | ||||
| -rw-r--r-- | p12 | 53 | ||||
| -rw-r--r-- | series | 17 | ||||
| -rw-r--r-- | usb-check-usb_get_extra_descriptor-for-proper-size.patch | 101 |
18 files changed, 2327 insertions, 102 deletions
diff --git a/0001-Bluetooth-check-message-types-in-l2cap_get_conf_opt.patch b/0001-Bluetooth-check-message-types-in-l2cap_get_conf_opt.patch new file mode 100644 index 00000000000000..344d40f5398508 --- /dev/null +++ b/0001-Bluetooth-check-message-types-in-l2cap_get_conf_opt.patch @@ -0,0 +1,95 @@ +From cfcc872e012be6c4e2bea3e70b7386176bd1a6c0 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Fri, 4 Jan 2019 10:50:37 +0100 +Subject: [PATCH 1/3] Bluetooth: check message types in l2cap_get_conf_opt + +l2cap_get_conf_opt can handle a "default" message type, but it needs to +be verified that it really is the correct type (CONF_EFS or CONF_RFC) +before passing it back to the caller. To do this we need to check the +return value of this call now and handle the error correctly up the +stack. + +Based on a patch from Ran Menscher. + +Reported-by: Ran Menscher <ran.menscher@karambasecurity.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + net/bluetooth/l2cap_core.c | 25 +++++++++++++++++++------ + 1 file changed, 19 insertions(+), 6 deletions(-) + +--- a/net/bluetooth/l2cap_core.c ++++ b/net/bluetooth/l2cap_core.c +@@ -2980,6 +2980,10 @@ static inline int l2cap_get_conf_opt(voi + break; + + default: ++ /* Only CONF_EFS and CONF_RFC are allowed here */ ++ if ((opt->type != L2CAP_CONF_EFS) && ++ (opt->type != L2CAP_CONF_RFC)) ++ return -EPROTO; + *val = (unsigned long) opt->val; + break; + } +@@ -3324,7 +3328,7 @@ static int l2cap_parse_conf_req(struct l + void *endptr = data + data_size; + void *req = chan->conf_req; + int len = chan->conf_len; +- int type, hint, olen; ++ int type, hint, olen, err; + unsigned long val; + struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC }; + struct l2cap_conf_efs efs; +@@ -3336,7 +3340,10 @@ static int l2cap_parse_conf_req(struct l + BT_DBG("chan %p", chan); + + while (len >= L2CAP_CONF_OPT_SIZE) { +- len -= l2cap_get_conf_opt(&req, &type, &olen, &val); ++ err = l2cap_get_conf_opt(&req, &type, &olen, &val); ++ if (err < 0) ++ return err; ++ len -= err; + + hint = type & L2CAP_CONF_HINT; + type &= L2CAP_CONF_MASK; +@@ -3539,7 +3546,7 @@ static int l2cap_parse_conf_rsp(struct l + struct l2cap_conf_req *req = data; + void *ptr = req->data; + void *endptr = data + size; +- int type, olen; ++ int type, olen, err; + unsigned long val; + struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC }; + struct l2cap_conf_efs efs; +@@ -3547,7 +3554,10 @@ static int l2cap_parse_conf_rsp(struct l + BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data); + + while (len >= L2CAP_CONF_OPT_SIZE) { +- len -= l2cap_get_conf_opt(&rsp, &type, &olen, &val); ++ err = l2cap_get_conf_opt(&rsp, &type, &olen, &val); ++ if (err < 0) ++ return err; ++ len -= err; + + switch (type) { + case L2CAP_CONF_MTU: +@@ -3707,7 +3717,7 @@ void __l2cap_connect_rsp_defer(struct l2 + + static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len) + { +- int type, olen; ++ int type, olen, err; + unsigned long val; + /* Use sane default values in case a misbehaving remote device + * did not send an RFC or extended window size option. +@@ -3727,7 +3737,10 @@ static void l2cap_conf_rfc_get(struct l2 + return; + + while (len >= L2CAP_CONF_OPT_SIZE) { +- len -= l2cap_get_conf_opt(&rsp, &type, &olen, &val); ++ err = l2cap_get_conf_opt(&rsp, &type, &olen, &val); ++ if (err < 0) ++ return; ++ len -= err; + + switch (type) { + case L2CAP_CONF_RFC: diff --git a/0002-Bluetooth-check-the-buffer-size-for-some-messages-be.patch b/0002-Bluetooth-check-the-buffer-size-for-some-messages-be.patch new file mode 100644 index 00000000000000..8567d4277aae9d --- /dev/null +++ b/0002-Bluetooth-check-the-buffer-size-for-some-messages-be.patch @@ -0,0 +1,60 @@ +From 6d85d9b7aad36ba344f1d4ba950ffee4f25016d0 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Fri, 4 Jan 2019 10:58:12 +0100 +Subject: [PATCH 2/3] Bluetooth: check the buffer size for some messages before + parsing + +The L2CAP_CONF_EFS and L2CAP_CONF_RFC messages can be sent from +userspace so their structure sizes need to be checked before parsing +them. + +Based on a patch from Ran Menscher. + +Reported-by: Ran Menscher <ran.menscher@karambasecurity.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + net/bluetooth/l2cap_core.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/net/bluetooth/l2cap_core.c ++++ b/net/bluetooth/l2cap_core.c +@@ -3361,7 +3361,8 @@ static int l2cap_parse_conf_req(struct l + break; + + case L2CAP_CONF_RFC: +- if (olen == sizeof(rfc)) ++ if ((olen == sizeof(rfc)) && ++ (endptr - ptr >= L2CAP_CONF_OPT_SIZE + sizeof(rfc))) + memcpy(&rfc, (void *) val, olen); + break; + +@@ -3371,7 +3372,8 @@ static int l2cap_parse_conf_req(struct l + break; + + case L2CAP_CONF_EFS: +- if (olen == sizeof(efs)) { ++ if ((olen == sizeof(efs)) && ++ (endptr - ptr >= L2CAP_CONF_OPT_SIZE + sizeof(efs))) { + remote_efs = 1; + memcpy(&efs, (void *) val, olen); + } +@@ -3576,7 +3578,8 @@ static int l2cap_parse_conf_rsp(struct l + break; + + case L2CAP_CONF_RFC: +- if (olen == sizeof(rfc)) ++ if ((olen == sizeof(rfc)) && ++ (endptr - ptr >= L2CAP_CONF_OPT_SIZE + sizeof(rfc))) + memcpy(&rfc, (void *)val, olen); + + if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && +@@ -3596,7 +3599,8 @@ static int l2cap_parse_conf_rsp(struct l + break; + + case L2CAP_CONF_EFS: +- if (olen == sizeof(efs)) { ++ if ((olen == sizeof(efs)) && ++ (endptr - ptr >= L2CAP_CONF_OPT_SIZE + sizeof(efs))) { + memcpy(&efs, (void *)val, olen); + + if (chan->local_stype != L2CAP_SERV_NOTRAFIC && diff --git a/0003-IN_BADCLASS-fix-macro-to-actually-work.patch b/0003-IN_BADCLASS-fix-macro-to-actually-work.patch new file mode 100644 index 00000000000000..38161debd14d78 --- /dev/null +++ b/0003-IN_BADCLASS-fix-macro-to-actually-work.patch @@ -0,0 +1,32 @@ +From 96df48c8dd927cb3628d0364a5371ca7f5812c02 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Thu, 10 Jan 2019 21:19:44 +0100 +Subject: [PATCH 3/3] IN_BADCLASS: fix macro to actually work + +Commit 65cab850f0ee ("net: Allow class-e address assignment via ifconfig +ioctl") modified the IN_BADCLASS macro a bit, but unfortunatly one too +many '(' characters were added to the line, making any code that used +it, not build properly. + +Also, the macro now compares an unsigned with a signed value, which +isn't ok, so fix that up by making both types match properly. + +Reported-by: Christopher Ferris <cferris@google.com> +Fixes: 65cab850f0ee ("net: Allow class-e address assignment via ifconfig ioctl") +Cc: Dave Taht <dave.taht@gmail.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + include/uapi/linux/in.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -268,7 +268,7 @@ struct sockaddr_in { + #define IN_MULTICAST(a) IN_CLASSD(a) + #define IN_MULTICAST_NET 0xe0000000 + +-#define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff) ++#define IN_BADCLASS(a) (((long int) (a) ) == (long int)0xffffffff) + #define IN_EXPERIMENTAL(a) IN_BADCLASS((a)) + + #define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) diff --git a/p00 b/p00 new file mode 100644 index 00000000000000..bb502ad76b9076 --- /dev/null +++ b/p00 @@ -0,0 +1,44 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] microblaze: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Michal Simek <monstr@monstr.eu> +Cc: Rob Herring <robh@kernel.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/microblaze/kernel/setup.c | 13 ++----------- + 1 file changed, 2 insertions(+), 11 deletions(-) + +--- a/arch/microblaze/kernel/setup.c ++++ b/arch/microblaze/kernel/setup.c +@@ -192,23 +192,14 @@ struct dentry *of_debugfs_root; + static int microblaze_debugfs_init(void) + { + of_debugfs_root = debugfs_create_dir("microblaze", NULL); +- +- return of_debugfs_root == NULL; ++ return 0; + } + arch_initcall(microblaze_debugfs_init); + + # ifdef CONFIG_MMU + static int __init debugfs_tlb(void) + { +- struct dentry *d; +- +- if (!of_debugfs_root) +- return -ENODEV; +- +- d = debugfs_create_u32("tlb_skip", S_IRUGO, of_debugfs_root, &tlb_skip); +- if (!d) +- return -ENOMEM; +- ++ debugfs_create_u32("tlb_skip", S_IRUGO, of_debugfs_root, &tlb_skip); + return 0; + } + device_initcall(debugfs_tlb); diff --git a/p01 b/p01 new file mode 100644 index 00000000000000..f173ffc4e98f27 --- /dev/null +++ b/p01 @@ -0,0 +1,68 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] arm64: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Catalin Marinas <catalin.marinas@arm.com> +Cc: Will Deacon <will.deacon@arm.com> +Cc: Marc Zyngier <marc.zyngier@arm.com> +Cc: Peng Donglin <dolinux.peng@gmail.com> +Cc: <linux-arm-kernel@lists.infradead.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/arm64/include/asm/ptdump.h | 9 +++------ + arch/arm64/mm/dump.c | 4 ++-- + arch/arm64/mm/ptdump_debugfs.c | 7 ++----- + 3 files changed, 7 insertions(+), 13 deletions(-) + + +--- a/arch/arm64/include/asm/ptdump.h ++++ b/arch/arm64/include/asm/ptdump.h +@@ -34,13 +34,10 @@ struct ptdump_info { + + void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info); + #ifdef CONFIG_ARM64_PTDUMP_DEBUGFS +-int ptdump_debugfs_register(struct ptdump_info *info, const char *name); ++void ptdump_debugfs_register(struct ptdump_info *info, const char *name); + #else +-static inline int ptdump_debugfs_register(struct ptdump_info *info, +- const char *name) +-{ +- return 0; +-} ++static inline void ptdump_debugfs_register(struct ptdump_info *info, ++ const char *name) { } + #endif + void ptdump_check_wx(void); + #endif /* CONFIG_ARM64_PTDUMP_CORE */ +--- a/arch/arm64/mm/dump.c ++++ b/arch/arm64/mm/dump.c +@@ -407,7 +407,7 @@ void ptdump_check_wx(void) + static int ptdump_init(void) + { + ptdump_initialize(); +- return ptdump_debugfs_register(&kernel_ptdump_info, +- "kernel_page_tables"); ++ ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); ++ return 0; + } + device_initcall(ptdump_init); +--- a/arch/arm64/mm/ptdump_debugfs.c ++++ b/arch/arm64/mm/ptdump_debugfs.c +@@ -12,10 +12,7 @@ static int ptdump_show(struct seq_file * + } + DEFINE_SHOW_ATTRIBUTE(ptdump); + +-int ptdump_debugfs_register(struct ptdump_info *info, const char *name) ++void ptdump_debugfs_register(struct ptdump_info *info, const char *name) + { +- struct dentry *pe; +- pe = debugfs_create_file(name, 0400, NULL, info, &ptdump_fops); +- return pe ? 0 : -ENOMEM; +- ++ debugfs_create_file(name, 0400, NULL, info, &ptdump_fops); + } diff --git a/p02 b/p02 new file mode 100644 index 00000000000000..48adb99bbf0eff --- /dev/null +++ b/p02 @@ -0,0 +1,218 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] arm: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/arm/include/asm/ptdump.h | 9 +---- + arch/arm/mach-omap1/clock.c | 67 ++++++++--------------------------------- + arch/arm/mach-omap1/pm.c | 7 +--- + arch/arm/mach-omap2/pm-debug.c | 15 +++------ + arch/arm/mm/dump.c | 4 +- + arch/arm/mm/ptdump_debugfs.c | 8 +--- + 6 files changed, 29 insertions(+), 81 deletions(-) + +--- a/arch/arm/include/asm/ptdump.h ++++ b/arch/arm/include/asm/ptdump.h +@@ -21,13 +21,10 @@ struct ptdump_info { + + void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info); + #ifdef CONFIG_ARM_PTDUMP_DEBUGFS +-int ptdump_debugfs_register(struct ptdump_info *info, const char *name); ++void ptdump_debugfs_register(struct ptdump_info *info, const char *name); + #else +-static inline int ptdump_debugfs_register(struct ptdump_info *info, +- const char *name) +-{ +- return 0; +-} ++static inline void ptdump_debugfs_register(struct ptdump_info *info, ++ const char *name) { } + #endif /* CONFIG_ARM_PTDUMP_DEBUGFS */ + + void ptdump_check_wx(void); +--- a/arch/arm/mach-omap1/clock.c ++++ b/arch/arm/mach-omap1/clock.c +@@ -990,84 +990,45 @@ static int debug_clock_show(struct seq_f + + DEFINE_SHOW_ATTRIBUTE(debug_clock); + +-static int clk_debugfs_register_one(struct clk *c) ++static void clk_debugfs_register_one(struct clk *c) + { +- int err; + struct dentry *d; + struct clk *pa = c->parent; + + d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root); +- if (!d) +- return -ENOMEM; + c->dent = d; + +- d = debugfs_create_u8("usecount", S_IRUGO, c->dent, &c->usecount); +- if (!d) { +- err = -ENOMEM; +- goto err_out; +- } +- d = debugfs_create_ulong("rate", S_IRUGO, c->dent, &c->rate); +- if (!d) { +- err = -ENOMEM; +- goto err_out; +- } +- d = debugfs_create_x8("flags", S_IRUGO, c->dent, &c->flags); +- if (!d) { +- err = -ENOMEM; +- goto err_out; +- } +- return 0; +- +-err_out: +- debugfs_remove_recursive(c->dent); +- return err; ++ debugfs_create_u8("usecount", S_IRUGO, c->dent, &c->usecount); ++ debugfs_create_ulong("rate", S_IRUGO, c->dent, &c->rate); ++ debugfs_create_x8("flags", S_IRUGO, c->dent, &c->flags); + } + +-static int clk_debugfs_register(struct clk *c) ++static void clk_debugfs_register(struct clk *c) + { + int err; + struct clk *pa = c->parent; + +- if (pa && !pa->dent) { +- err = clk_debugfs_register(pa); +- if (err) +- return err; +- } +- +- if (!c->dent) { +- err = clk_debugfs_register_one(c); +- if (err) +- return err; +- } +- return 0; ++ if (pa && !pa->dent) ++ clk_debugfs_register(pa); ++ ++ if (!c->dent) ++ clk_debugfs_register_one(c); + } + + static int __init clk_debugfs_init(void) + { + struct clk *c; + struct dentry *d; +- int err; + + d = debugfs_create_dir("clock", NULL); +- if (!d) +- return -ENOMEM; + clk_debugfs_root = d; + +- list_for_each_entry(c, &clocks, node) { +- err = clk_debugfs_register(c); +- if (err) +- goto err_out; +- } +- +- d = debugfs_create_file("summary", S_IRUGO, +- d, NULL, &debug_clock_fops); +- if (!d) +- return -ENOMEM; ++ list_for_each_entry(c, &clocks, node) ++ clk_debugfs_register(c); ++ ++ debugfs_create_file("summary", S_IRUGO, d, NULL, &debug_clock_fops); + + return 0; +-err_out: +- debugfs_remove_recursive(clk_debugfs_root); +- return err; + } + late_initcall(clk_debugfs_init); + +--- a/arch/arm/mach-omap1/pm.c ++++ b/arch/arm/mach-omap1/pm.c +@@ -539,11 +539,8 @@ static void omap_pm_init_debugfs(void) + struct dentry *d; + + d = debugfs_create_dir("pm_debug", NULL); +- if (!d) +- return; +- +- (void) debugfs_create_file("omap_pm", S_IWUSR | S_IRUGO, +- d, NULL, &omap_pm_debug_fops); ++ debugfs_create_file("omap_pm", S_IWUSR | S_IRUGO, d, NULL, ++ &omap_pm_debug_fops); + } + + #endif /* CONFIG_DEBUG_FS */ +--- a/arch/arm/mach-omap2/pm-debug.c ++++ b/arch/arm/mach-omap2/pm-debug.c +@@ -193,9 +193,8 @@ static int __init pwrdms_setup(struct po + return 0; + + d = debugfs_create_dir(pwrdm->name, (struct dentry *)dir); +- if (d) +- (void) debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d, +- (void *)pwrdm, &pwrdm_suspend_fops); ++ debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d, pwrdm, ++ &pwrdm_suspend_fops); + + return 0; + } +@@ -233,16 +232,14 @@ static int __init pm_dbg_init(void) + return 0; + + d = debugfs_create_dir("pm_debug", NULL); +- if (!d) +- return -EINVAL; + +- (void) debugfs_create_file("count", 0444, d, NULL, &pm_dbg_counters_fops); +- (void) debugfs_create_file("time", 0444, d, NULL, &pm_dbg_timers_fops); ++ debugfs_create_file("count", 0444, d, NULL, &pm_dbg_counters_fops); ++ debugfs_create_file("time", 0444, d, NULL, &pm_dbg_timers_fops); + + pwrdm_for_each(pwrdms_setup, (void *)d); + +- (void) debugfs_create_file("enable_off_mode", S_IRUGO | S_IWUSR, d, +- &enable_off_mode, &pm_dbg_option_fops); ++ debugfs_create_file("enable_off_mode", S_IRUGO | S_IWUSR, d, ++ &enable_off_mode, &pm_dbg_option_fops); + pm_dbg_init_done = 1; + + return 0; +--- a/arch/arm/mm/dump.c ++++ b/arch/arm/mm/dump.c +@@ -450,7 +450,7 @@ void ptdump_check_wx(void) + static int ptdump_init(void) + { + ptdump_initialize(); +- return ptdump_debugfs_register(&kernel_ptdump_info, +- "kernel_page_tables"); ++ ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); ++ return 0; + } + __initcall(ptdump_init); +--- a/arch/arm/mm/ptdump_debugfs.c ++++ b/arch/arm/mm/ptdump_debugfs.c +@@ -24,11 +24,7 @@ static const struct file_operations ptdu + .release = single_release, + }; + +-int ptdump_debugfs_register(struct ptdump_info *info, const char *name) ++void ptdump_debugfs_register(struct ptdump_info *info, const char *name) + { +- struct dentry *pe; +- +- pe = debugfs_create_file(name, 0400, NULL, info, &ptdump_fops); +- return pe ? 0 : -ENOMEM; +- ++ debugfs_create_file(name, 0400, NULL, info, &ptdump_fops); + } diff --git a/p03 b/p03 new file mode 100644 index 00000000000000..269a47e100063e --- /dev/null +++ b/p03 @@ -0,0 +1,300 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] mips: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/mips/cavium-octeon/oct_ilm.c | 31 ++++--------------------------- + arch/mips/kernel/mips-r2-to-r6-emul.c | 21 ++++----------------- + arch/mips/kernel/segment.c | 15 +++------------ + arch/mips/kernel/setup.c | 7 +------ + arch/mips/kernel/spinlock_test.c | 21 ++++----------------- + arch/mips/kernel/unaligned.c | 16 ++++------------ + arch/mips/math-emu/me-debugfs.c | 23 ++++------------------- + arch/mips/mm/sc-debugfs.c | 15 +++------------ + arch/mips/ralink/bootrom.c | 8 +------- + 9 files changed, 28 insertions(+), 129 deletions(-) + +--- a/arch/mips/cavium-octeon/oct_ilm.c ++++ b/arch/mips/cavium-octeon/oct_ilm.c +@@ -63,31 +63,12 @@ static int reset_statistics(void *data, + + DEFINE_SIMPLE_ATTRIBUTE(reset_statistics_ops, NULL, reset_statistics, "%llu\n"); + +-static int init_debufs(void) ++static void init_debugfs(void) + { +- struct dentry *show_dentry; + dir = debugfs_create_dir("oct_ilm", 0); +- if (!dir) { +- pr_err("oct_ilm: failed to create debugfs entry oct_ilm\n"); +- return -1; +- } +- +- show_dentry = debugfs_create_file("statistics", 0222, dir, NULL, +- &oct_ilm_ops); +- if (!show_dentry) { +- pr_err("oct_ilm: failed to create debugfs entry oct_ilm/statistics\n"); +- return -1; +- } +- +- show_dentry = debugfs_create_file("reset", 0222, dir, NULL, +- &reset_statistics_ops); +- if (!show_dentry) { +- pr_err("oct_ilm: failed to create debugfs entry oct_ilm/reset\n"); +- return -1; +- } +- ++ debugfs_create_file("statistics", 0222, dir, NULL, &oct_ilm_ops); ++ debugfs_create_file("reset", 0222, dir, NULL, &reset_statistics_ops); + return 0; +- + } + + static void init_latency_info(struct latency_info *li, int startup) +@@ -169,11 +150,7 @@ static __init int oct_ilm_module_init(vo + int rc; + int irq = OCTEON_IRQ_TIMER0 + TIMER_NUM; + +- rc = init_debufs(); +- if (rc) { +- WARN(1, "Could not create debugfs entries"); +- return rc; +- } ++ init_debugfs(); + + rc = request_irq(irq, cvm_oct_ciu_timer_interrupt, IRQF_NO_THREAD, + "oct_ilm", 0); +--- a/arch/mips/kernel/mips-r2-to-r6-emul.c ++++ b/arch/mips/kernel/mips-r2-to-r6-emul.c +@@ -2351,23 +2351,10 @@ DEFINE_SHOW_ATTRIBUTE(mipsr2_clear); + + static int __init mipsr2_init_debugfs(void) + { +- struct dentry *mipsr2_emul; +- +- if (!mips_debugfs_dir) +- return -ENODEV; +- +- mipsr2_emul = debugfs_create_file("r2_emul_stats", S_IRUGO, +- mips_debugfs_dir, NULL, +- &mipsr2_emul_fops); +- if (!mipsr2_emul) +- return -ENOMEM; +- +- mipsr2_emul = debugfs_create_file("r2_emul_stats_clear", S_IRUGO, +- mips_debugfs_dir, NULL, +- &mipsr2_clear_fops); +- if (!mipsr2_emul) +- return -ENOMEM; +- ++ debugfs_create_file("r2_emul_stats", S_IRUGO, mips_debugfs_dir, NULL, ++ &mipsr2_emul_fops); ++ debugfs_create_file("r2_emul_stats_clear", S_IRUGO, mips_debugfs_dir, ++ NULL, &mipsr2_clear_fops); + return 0; + } + +--- a/arch/mips/kernel/segment.c ++++ b/arch/mips/kernel/segment.c +@@ -95,18 +95,9 @@ static const struct file_operations segm + + static int __init segments_info(void) + { +- struct dentry *segments; +- +- if (cpu_has_segments) { +- if (!mips_debugfs_dir) +- return -ENODEV; +- +- segments = debugfs_create_file("segments", S_IRUGO, +- mips_debugfs_dir, NULL, +- &segments_fops); +- if (!segments) +- return -ENOMEM; +- } ++ if (cpu_has_segments) ++ debugfs_create_file("segments", S_IRUGO, mips_debugfs_dir, NULL, ++ &segments_fops); + return 0; + } + +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -1010,12 +1010,7 @@ unsigned long fw_passed_dtb; + struct dentry *mips_debugfs_dir; + static int __init debugfs_mips(void) + { +- struct dentry *d; +- +- d = debugfs_create_dir("mips", NULL); +- if (!d) +- return -ENOMEM; +- mips_debugfs_dir = d; ++ mips_debugfs_dir = debugfs_create_dir("mips", NULL); + return 0; + } + arch_initcall(debugfs_mips); +--- a/arch/mips/kernel/spinlock_test.c ++++ b/arch/mips/kernel/spinlock_test.c +@@ -118,23 +118,10 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_multi, mult + + static int __init spinlock_test(void) + { +- struct dentry *d; +- +- if (!mips_debugfs_dir) +- return -ENODEV; +- +- d = debugfs_create_file("spin_single", S_IRUGO, +- mips_debugfs_dir, NULL, +- &fops_ss); +- if (!d) +- return -ENOMEM; +- +- d = debugfs_create_file("spin_multi", S_IRUGO, +- mips_debugfs_dir, NULL, +- &fops_multi); +- if (!d) +- return -ENOMEM; +- ++ debugfs_create_file("spin_single", S_IRUGO, mips_debugfs_dir, NULL, ++ &fops_ss); ++ debugfs_create_file("spin_multi", S_IRUGO, mips_debugfs_dir, NULL, ++ &fops_multi); + return 0; + } + device_initcall(spinlock_test); +--- a/arch/mips/kernel/unaligned.c ++++ b/arch/mips/kernel/unaligned.c +@@ -2374,18 +2374,10 @@ sigbus: + #ifdef CONFIG_DEBUG_FS + static int __init debugfs_unaligned(void) + { +- struct dentry *d; +- +- if (!mips_debugfs_dir) +- return -ENODEV; +- d = debugfs_create_u32("unaligned_instructions", S_IRUGO, +- mips_debugfs_dir, &unaligned_instructions); +- if (!d) +- return -ENOMEM; +- d = debugfs_create_u32("unaligned_action", S_IRUGO | S_IWUSR, +- mips_debugfs_dir, &unaligned_action); +- if (!d) +- return -ENOMEM; ++ debugfs_create_u32("unaligned_instructions", S_IRUGO, mips_debugfs_dir, ++ &unaligned_instructions); ++ debugfs_create_u32("unaligned_action", S_IRUGO | S_IWUSR, ++ mips_debugfs_dir, &unaligned_action); + return 0; + } + arch_initcall(debugfs_unaligned); +--- a/arch/mips/math-emu/me-debugfs.c ++++ b/arch/mips/math-emu/me-debugfs.c +@@ -189,32 +189,21 @@ static int __init debugfs_fpuemu(void) + { + struct dentry *fpuemu_debugfs_base_dir; + struct dentry *fpuemu_debugfs_inst_dir; +- struct dentry *d, *reset_file; +- +- if (!mips_debugfs_dir) +- return -ENODEV; + + fpuemu_debugfs_base_dir = debugfs_create_dir("fpuemustats", + mips_debugfs_dir); +- if (!fpuemu_debugfs_base_dir) +- return -ENOMEM; + +- reset_file = debugfs_create_file("fpuemustats_clear", 0444, +- mips_debugfs_dir, NULL, +- &fpuemustats_clear_fops); +- if (!reset_file) +- return -ENOMEM; ++ debugfs_create_file("fpuemustats_clear", 0444, mips_debugfs_dir, NULL, ++ &fpuemustats_clear_fops); + + #define FPU_EMU_STAT_OFFSET(m) \ + offsetof(struct mips_fpu_emulator_stats, m) + + #define FPU_STAT_CREATE(m) \ + do { \ +- d = debugfs_create_file(#m, 0444, fpuemu_debugfs_base_dir, \ ++ debugfs_create_file(#m, 0444, fpuemu_debugfs_base_dir, \ + (void *)FPU_EMU_STAT_OFFSET(m), \ + &fops_fpuemu_stat); \ +- if (!d) \ +- return -ENOMEM; \ + } while (0) + + FPU_STAT_CREATE(emulated); +@@ -233,8 +222,6 @@ do { \ + + fpuemu_debugfs_inst_dir = debugfs_create_dir("instructions", + fpuemu_debugfs_base_dir); +- if (!fpuemu_debugfs_inst_dir) +- return -ENOMEM; + + #define FPU_STAT_CREATE_EX(m) \ + do { \ +@@ -242,11 +229,9 @@ do { \ + \ + adjust_instruction_counter_name(name, #m); \ + \ +- d = debugfs_create_file(name, 0444, fpuemu_debugfs_inst_dir, \ ++ debugfs_create_file(name, 0444, fpuemu_debugfs_inst_dir, \ + (void *)FPU_EMU_STAT_OFFSET(m), \ + &fops_fpuemu_stat); \ +- if (!d) \ +- return -ENOMEM; \ + } while (0) + + FPU_STAT_CREATE_EX(abs_s); +--- a/arch/mips/mm/sc-debugfs.c ++++ b/arch/mips/mm/sc-debugfs.c +@@ -55,20 +55,11 @@ static const struct file_operations sc_p + + static int __init sc_debugfs_init(void) + { +- struct dentry *dir, *file; +- +- if (!mips_debugfs_dir) +- return -ENODEV; ++ struct dentry *dir; + + dir = debugfs_create_dir("l2cache", mips_debugfs_dir); +- if (IS_ERR(dir)) +- return PTR_ERR(dir); +- +- file = debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, +- NULL, &sc_prefetch_fops); +- if (!file) +- return -ENOMEM; +- ++ debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, NULL, ++ &sc_prefetch_fops); + return 0; + } + late_initcall(sc_debugfs_init); +--- a/arch/mips/ralink/bootrom.c ++++ b/arch/mips/ralink/bootrom.c +@@ -35,13 +35,7 @@ static const struct file_operations boot + + static int bootrom_setup(void) + { +- if (!debugfs_create_file("bootrom", 0444, +- NULL, NULL, &bootrom_file_ops)) { +- pr_err("Failed to create bootrom debugfs file\n"); +- +- return -EINVAL; +- } +- ++ debugfs_create_file("bootrom", 0444, NULL, NULL, &bootrom_file_ops); + return 0; + } + diff --git a/p04 b/p04 new file mode 100644 index 00000000000000..7208a194b16a1f --- /dev/null +++ b/p04 @@ -0,0 +1,598 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] powerpc: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/powerpc/include/asm/kvm_host.h | 3 -- + arch/powerpc/kernel/fadump.c | 9 +----- + arch/powerpc/kernel/setup-common.c | 3 -- + arch/powerpc/kernel/traps.c | 27 ++++--------------- + arch/powerpc/kvm/book3s_64_mmu_hv.c | 5 +-- + arch/powerpc/kvm/book3s_64_mmu_radix.c | 5 +-- + arch/powerpc/kvm/book3s_hv.c | 9 +----- + arch/powerpc/kvm/timing.c | 11 +------- + arch/powerpc/mm/dump_hashpagetable.c | 7 +---- + arch/powerpc/mm/dump_linuxpagetables.c | 8 ++--- + arch/powerpc/mm/hash_utils_64.c | 7 +---- + arch/powerpc/platforms/4xx/ocm.c | 14 +--------- + arch/powerpc/platforms/cell/axon_msi.c | 6 ---- + arch/powerpc/platforms/powernv/memtrace.c | 7 ----- + arch/powerpc/platforms/powernv/opal-imc.c | 28 +++++--------------- + arch/powerpc/platforms/powernv/pci-ioda.c | 5 --- + arch/powerpc/platforms/powernv/vas-debug.c | 37 ++------------------------- + arch/powerpc/platforms/pseries/dtl.c | 36 +++----------------------- + arch/powerpc/platforms/pseries/hvCall_inst.c | 12 ++------ + arch/powerpc/sysdev/scom.c | 8 ----- + 20 files changed, 45 insertions(+), 202 deletions(-) + +--- a/arch/powerpc/include/asm/kvm_host.h ++++ b/arch/powerpc/include/asm/kvm_host.h +@@ -293,8 +293,6 @@ struct kvm_arch { + pgd_t *pgtable; + u64 process_table; + struct dentry *debugfs_dir; +- struct dentry *htab_dentry; +- struct dentry *radix_dentry; + struct kvm_resize_hpt *resize_hpt; /* protected by kvm->lock */ + #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ + #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE +@@ -806,7 +804,6 @@ struct kvm_vcpu_arch { + struct kvmhv_tb_accumulator cede_time; /* time napping inside guest */ + + struct dentry *debugfs_dir; +- struct dentry *debugfs_timings; + #endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ + }; + +--- a/arch/powerpc/kernel/fadump.c ++++ b/arch/powerpc/kernel/fadump.c +@@ -1649,7 +1649,6 @@ DEFINE_SHOW_ATTRIBUTE(fadump_region); + + static void fadump_init_files(void) + { +- struct dentry *debugfs_file; + int rc = 0; + + rc = sysfs_create_file(kernel_kobj, &fadump_attr.attr); +@@ -1662,12 +1661,8 @@ static void fadump_init_files(void) + printk(KERN_ERR "fadump: unable to create sysfs file" + " fadump_registered (%d)\n", rc); + +- debugfs_file = debugfs_create_file("fadump_region", 0444, +- powerpc_debugfs_root, NULL, +- &fadump_region_fops); +- if (!debugfs_file) +- printk(KERN_ERR "fadump: unable to create debugfs file" +- " fadump_region\n"); ++ debugfs_create_file("fadump_region", 0444, powerpc_debugfs_root, NULL, ++ &fadump_region_fops); + + if (fw_dump.dump_active) { + rc = sysfs_create_file(kernel_kobj, &fadump_release_attr.attr); +--- a/arch/powerpc/kernel/setup-common.c ++++ b/arch/powerpc/kernel/setup-common.c +@@ -776,8 +776,7 @@ EXPORT_SYMBOL(powerpc_debugfs_root); + static int powerpc_debugfs_init(void) + { + powerpc_debugfs_root = debugfs_create_dir("powerpc", NULL); +- +- return powerpc_debugfs_root == NULL; ++ return 0; + } + arch_initcall(powerpc_debugfs_init); + #endif +--- a/arch/powerpc/kernel/traps.c ++++ b/arch/powerpc/kernel/traps.c +@@ -2173,35 +2173,20 @@ void ppc_warn_emulated_print(const char + + static int __init ppc_warn_emulated_init(void) + { +- struct dentry *dir, *d; ++ struct dentry *dir; + unsigned int i; + struct ppc_emulated_entry *entries = (void *)&ppc_emulated; + +- if (!powerpc_debugfs_root) +- return -ENODEV; +- + dir = debugfs_create_dir("emulated_instructions", + powerpc_debugfs_root); +- if (!dir) +- return -ENOMEM; + +- d = debugfs_create_u32("do_warn", 0644, dir, +- &ppc_warn_emulated); +- if (!d) +- goto fail; +- +- for (i = 0; i < sizeof(ppc_emulated)/sizeof(*entries); i++) { +- d = debugfs_create_u32(entries[i].name, 0644, dir, +- (u32 *)&entries[i].val.counter); +- if (!d) +- goto fail; +- } ++ debugfs_create_u32("do_warn", 0644, dir, &ppc_warn_emulated); + +- return 0; ++ for (i = 0; i < sizeof(ppc_emulated)/sizeof(*entries); i++) ++ debugfs_create_u32(entries[i].name, 0644, dir, ++ (u32 *)&entries[i].val.counter); + +-fail: +- debugfs_remove_recursive(dir); +- return -ENOMEM; ++ return 0; + } + + device_initcall(ppc_warn_emulated_init); +--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c ++++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c +@@ -2142,9 +2142,8 @@ static const struct file_operations debu + + void kvmppc_mmu_debugfs_init(struct kvm *kvm) + { +- kvm->arch.htab_dentry = debugfs_create_file("htab", 0400, +- kvm->arch.debugfs_dir, kvm, +- &debugfs_htab_fops); ++ debugfs_create_file("htab", 0400, kvm->arch.debugfs_dir, kvm, ++ &debugfs_htab_fops); + } + + void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu) +--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c ++++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c +@@ -1348,9 +1348,8 @@ static const struct file_operations debu + + void kvmhv_radix_debugfs_init(struct kvm *kvm) + { +- kvm->arch.radix_dentry = debugfs_create_file("radix", 0400, +- kvm->arch.debugfs_dir, kvm, +- &debugfs_radix_fops); ++ debugfs_create_file("radix", 0400, kvm->arch.debugfs_dir, kvm, ++ &debugfs_radix_fops); + } + + int kvmppc_radix_init(void) +--- a/arch/powerpc/kvm/book3s_hv.c ++++ b/arch/powerpc/kvm/book3s_hv.c +@@ -2144,14 +2144,9 @@ static void debugfs_vcpu_init(struct kvm + struct kvm *kvm = vcpu->kvm; + + snprintf(buf, sizeof(buf), "vcpu%u", id); +- if (IS_ERR_OR_NULL(kvm->arch.debugfs_dir)) +- return; + vcpu->arch.debugfs_dir = debugfs_create_dir(buf, kvm->arch.debugfs_dir); +- if (IS_ERR_OR_NULL(vcpu->arch.debugfs_dir)) +- return; +- vcpu->arch.debugfs_timings = +- debugfs_create_file("timings", 0444, vcpu->arch.debugfs_dir, +- vcpu, &debugfs_timings_ops); ++ debugfs_create_file("timings", 0444, vcpu->arch.debugfs_dir, vcpu, ++ &debugfs_timings_ops); + } + + #else /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ +--- a/arch/powerpc/kvm/timing.c ++++ b/arch/powerpc/kvm/timing.c +@@ -218,19 +218,12 @@ static const struct file_operations kvmp + void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id) + { + static char dbg_fname[50]; +- struct dentry *debugfs_file; + + snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing", + current->pid, id); +- debugfs_file = debugfs_create_file(dbg_fname, 0666, +- kvm_debugfs_dir, vcpu, +- &kvmppc_exit_timing_fops); ++ debugfs_create_file(dbg_fname, 0666, kvm_debugfs_dir, vcpu, ++ &kvmppc_exit_timing_fops); + +- if (!debugfs_file) { +- printk(KERN_ERR"%s: error creating debugfs file %s\n", +- __func__, dbg_fname); +- return; +- } + + vcpu->arch.debugfs_exit_timing = debugfs_file; + } +--- a/arch/powerpc/mm/dump_hashpagetable.c ++++ b/arch/powerpc/mm/dump_hashpagetable.c +@@ -537,13 +537,10 @@ static const struct file_operations ptdu + + static int ptdump_init(void) + { +- struct dentry *debugfs_file; +- + if (!radix_enabled()) { + populate_markers(); +- debugfs_file = debugfs_create_file("kernel_hash_pagetable", +- 0400, NULL, NULL, &ptdump_fops); +- return debugfs_file ? 0 : -ENOMEM; ++ debugfs_create_file("kernel_hash_pagetable", 0400, NULL, NULL, ++ &ptdump_fops); + } + return 0; + } +--- a/arch/powerpc/mm/dump_linuxpagetables.c ++++ b/arch/powerpc/mm/dump_linuxpagetables.c +@@ -362,12 +362,10 @@ static void build_pgtable_complete_mask( + + static int ptdump_init(void) + { +- struct dentry *debugfs_file; +- + populate_markers(); + build_pgtable_complete_mask(); +- debugfs_file = debugfs_create_file("kernel_page_tables", 0400, NULL, +- NULL, &ptdump_fops); +- return debugfs_file ? 0 : -ENOMEM; ++ debugfs_create_file("kernel_page_tables", 0400, NULL, NULL, ++ &ptdump_fops); ++ return 0; + } + device_initcall(ptdump_init); +--- a/arch/powerpc/mm/hash_utils_64.c ++++ b/arch/powerpc/mm/hash_utils_64.c +@@ -1893,11 +1893,8 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_hpt_order, + + static int __init hash64_debugfs(void) + { +- if (!debugfs_create_file("hpt_order", 0600, powerpc_debugfs_root, +- NULL, &fops_hpt_order)) { +- pr_err("lpar: unable to create hpt_order debugsfs file\n"); +- } +- ++ debugfs_create_file("hpt_order", 0600, powerpc_debugfs_root, NULL, ++ &fops_hpt_order); + return 0; + } + machine_device_initcall(pseries, hash64_debugfs); +--- a/arch/powerpc/platforms/4xx/ocm.c ++++ b/arch/powerpc/platforms/4xx/ocm.c +@@ -280,22 +280,12 @@ static const struct file_operations ocm_ + .release = single_release, + }; + +-static int ocm_debugfs_init(void) ++static void ocm_debugfs_init(void) + { + struct dentry *junk; + + junk = debugfs_create_dir("ppc4xx_ocm", 0); +- if (!junk) { +- printk(KERN_ALERT "debugfs ppc4xx ocm: failed to create dir\n"); +- return -1; +- } +- +- if (debugfs_create_file("info", 0644, junk, NULL, &ocm_debugfs_fops)) { +- printk(KERN_ALERT "debugfs ppc4xx ocm: failed to create file\n"); +- return -1; +- } +- +- return 0; ++ debugfs_create_file("info", 0644, junk, NULL, &ocm_debugfs_fops); + } + + void *ppc4xx_ocm_alloc(phys_addr_t *phys, int size, int align, +--- a/arch/powerpc/platforms/cell/axon_msi.c ++++ b/arch/powerpc/platforms/cell/axon_msi.c +@@ -484,10 +484,6 @@ void axon_msi_debug_setup(struct device_ + + snprintf(name, sizeof(name), "msic_%d", of_node_to_nid(dn)); + +- if (!debugfs_create_file(name, 0600, powerpc_debugfs_root, +- msic, &fops_msic)) { +- pr_devel("axon_msi: debugfs_create_file failed!\n"); +- return; +- } ++ debugfs_create_file(name, 0600, powerpc_debugfs_root, msic, &fops_msic); + } + #endif /* DEBUG */ +--- a/arch/powerpc/platforms/powernv/memtrace.c ++++ b/arch/powerpc/platforms/powernv/memtrace.c +@@ -190,11 +190,6 @@ static int memtrace_init_debugfs(void) + + snprintf(ent->name, 16, "%08x", ent->nid); + dir = debugfs_create_dir(ent->name, memtrace_debugfs_dir); +- if (!dir) { +- pr_err("Failed to create debugfs directory for node %d\n", +- ent->nid); +- return -1; +- } + + ent->dir = dir; + debugfs_create_file("trace", 0400, dir, ent, &memtrace_fops); +@@ -318,8 +313,6 @@ static int memtrace_init(void) + { + memtrace_debugfs_dir = debugfs_create_dir("memtrace", + powerpc_debugfs_root); +- if (!memtrace_debugfs_dir) +- return -1; + + debugfs_create_file("enable", 0600, memtrace_debugfs_dir, + NULL, &memtrace_init_fops); +--- a/arch/powerpc/platforms/powernv/opal-imc.c ++++ b/arch/powerpc/platforms/powernv/opal-imc.c +@@ -39,11 +39,10 @@ static int imc_mem_set(void *data, u64 v + } + DEFINE_DEBUGFS_ATTRIBUTE(fops_imc_x64, imc_mem_get, imc_mem_set, "0x%016llx\n"); + +-static struct dentry *imc_debugfs_create_x64(const char *name, umode_t mode, +- struct dentry *parent, u64 *value) ++static void imc_debugfs_create_x64(const char *name, umode_t mode, ++ struct dentry *parent, u64 *value) + { +- return debugfs_create_file_unsafe(name, mode, parent, +- value, &fops_imc_x64); ++ debugfs_create_file_unsafe(name, mode, parent, value, &fops_imc_x64); + } + + /* +@@ -63,13 +62,6 @@ static void export_imc_mode_and_cmd(stru + + imc_debugfs_parent = debugfs_create_dir("imc", powerpc_debugfs_root); + +- /* +- * Return here, either because 'imc' directory already exists, +- * Or failed to create a new one. +- */ +- if (!imc_debugfs_parent) +- return; +- + if (of_property_read_u32(node, "cb_offset", &cb_offset)) + cb_offset = IMC_CNTL_BLK_OFFSET; + +@@ -77,21 +69,15 @@ static void export_imc_mode_and_cmd(stru + loc = (u64)(pmu_ptr->mem_info[chip].vbase) + cb_offset; + imc_mode_addr = (u64 *)(loc + IMC_CNTL_BLK_MODE_OFFSET); + sprintf(mode, "imc_mode_%d", nid); +- if (!imc_debugfs_create_x64(mode, 0600, imc_debugfs_parent, +- imc_mode_addr)) +- goto err; ++ imc_debugfs_create_x64(mode, 0600, imc_debugfs_parent, ++ imc_mode_addr); + + imc_cmd_addr = (u64 *)(loc + IMC_CNTL_BLK_CMD_OFFSET); + sprintf(cmd, "imc_cmd_%d", nid); +- if (!imc_debugfs_create_x64(cmd, 0600, imc_debugfs_parent, +- imc_cmd_addr)) +- goto err; ++ imc_debugfs_create_x64(cmd, 0600, imc_debugfs_parent, ++ imc_cmd_addr); + chip++; + } +- return; +- +-err: +- debugfs_remove_recursive(imc_debugfs_parent); + } + + /* +--- a/arch/powerpc/platforms/powernv/pci-ioda.c ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c +@@ -3167,11 +3167,6 @@ static void pnv_pci_ioda_create_dbgfs(vo + + sprintf(name, "PCI%04x", hose->global_number); + phb->dbgfs = debugfs_create_dir(name, powerpc_debugfs_root); +- if (!phb->dbgfs) { +- pr_warn("%s: Error on creating debugfs on PHB#%x\n", +- __func__, hose->global_number); +- continue; +- } + + debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, hose, + &pnv_pci_diag_data_fops); +--- a/arch/powerpc/platforms/powernv/vas-debug.c ++++ b/arch/powerpc/platforms/powernv/vas-debug.c +@@ -119,7 +119,7 @@ void vas_window_free_dbgdir(struct vas_w + + void vas_window_init_dbgdir(struct vas_window *window) + { +- struct dentry *f, *d; ++ struct dentry *d; + + if (!window->vinst->dbgdir) + return; +@@ -131,28 +131,10 @@ void vas_window_init_dbgdir(struct vas_w + snprintf(window->dbgname, 16, "w%d", window->winid); + + d = debugfs_create_dir(window->dbgname, window->vinst->dbgdir); +- if (IS_ERR(d)) +- goto free_name; +- + window->dbgdir = d; + +- f = debugfs_create_file("info", 0444, d, window, &info_fops); +- if (IS_ERR(f)) +- goto remove_dir; +- +- f = debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops); +- if (IS_ERR(f)) +- goto remove_dir; +- +- return; +- +-remove_dir: +- debugfs_remove_recursive(window->dbgdir); +- window->dbgdir = NULL; +- +-free_name: +- kfree(window->dbgname); +- window->dbgname = NULL; ++ debugfs_create_file("info", 0444, d, window, &info_fops); ++ debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops); + } + + void vas_instance_init_dbgdir(struct vas_instance *vinst) +@@ -160,8 +142,6 @@ void vas_instance_init_dbgdir(struct vas + struct dentry *d; + + vas_init_dbgdir(); +- if (!vas_debugfs) +- return; + + vinst->dbgname = kzalloc(16, GFP_KERNEL); + if (!vinst->dbgname) +@@ -170,16 +150,7 @@ void vas_instance_init_dbgdir(struct vas + snprintf(vinst->dbgname, 16, "v%d", vinst->vas_id); + + d = debugfs_create_dir(vinst->dbgname, vas_debugfs); +- if (IS_ERR(d)) +- goto free_name; +- + vinst->dbgdir = d; +- return; +- +-free_name: +- kfree(vinst->dbgname); +- vinst->dbgname = NULL; +- vinst->dbgdir = NULL; + } + + /* +@@ -195,6 +166,4 @@ void vas_init_dbgdir(void) + + first_time = false; + vas_debugfs = debugfs_create_dir("vas", NULL); +- if (IS_ERR(vas_debugfs)) +- vas_debugfs = NULL; + } +--- a/arch/powerpc/platforms/pseries/dtl.c ++++ b/arch/powerpc/platforms/pseries/dtl.c +@@ -32,7 +32,6 @@ + + struct dtl { + struct dtl_entry *buf; +- struct dentry *file; + int cpu; + int buf_entries; + u64 last_idx; +@@ -332,22 +331,16 @@ static const struct file_operations dtl_ + + static struct dentry *dtl_dir; + +-static int dtl_setup_file(struct dtl *dtl) ++static void dtl_setup_file(struct dtl *dtl) + { + char name[10]; + + sprintf(name, "cpu-%d", dtl->cpu); +- +- dtl->file = debugfs_create_file(name, 0400, dtl_dir, dtl, &dtl_fops); +- if (!dtl->file) +- return -ENOMEM; +- +- return 0; ++ debugfs_create_file(name, 0400, dtl_dir, dtl, &dtl_fops); + } + + static int dtl_init(void) + { +- struct dentry *event_mask_file, *buf_entries_file; + int rc, i; + + if (!firmware_has_feature(FW_FEATURE_SPLPAR)) +@@ -357,21 +350,9 @@ static int dtl_init(void) + + rc = -ENOMEM; + dtl_dir = debugfs_create_dir("dtl", powerpc_debugfs_root); +- if (!dtl_dir) { +- printk(KERN_WARNING "%s: can't create dtl root dir\n", +- __func__); +- goto err; +- } + +- event_mask_file = debugfs_create_x8("dtl_event_mask", 0600, +- dtl_dir, &dtl_event_mask); +- buf_entries_file = debugfs_create_u32("dtl_buf_entries", 0400, +- dtl_dir, &dtl_buf_entries); +- +- if (!event_mask_file || !buf_entries_file) { +- printk(KERN_WARNING "%s: can't create dtl files\n", __func__); +- goto err_remove_dir; +- } ++ debugfs_create_x8("dtl_event_mask", 0600, dtl_dir, &dtl_event_mask); ++ debugfs_create_u32("dtl_buf_entries", 0400, dtl_dir, &dtl_buf_entries); + + /* set up the per-cpu log structures */ + for_each_possible_cpu(i) { +@@ -379,16 +360,9 @@ static int dtl_init(void) + spin_lock_init(&dtl->lock); + dtl->cpu = i; + +- rc = dtl_setup_file(dtl); +- if (rc) +- goto err_remove_dir; ++ dtl_setup_file(dtl); + } + + return 0; +- +-err_remove_dir: +- debugfs_remove_recursive(dtl_dir); +-err: +- return rc; + } + machine_arch_initcall(pseries, dtl_init); +--- a/arch/powerpc/platforms/pseries/hvCall_inst.c ++++ b/arch/powerpc/platforms/pseries/hvCall_inst.c +@@ -142,7 +142,6 @@ static void probe_hcall_exit(void *ignor + static int __init hcall_inst_init(void) + { + struct dentry *hcall_root; +- struct dentry *hcall_file; + char cpu_name_buf[CPU_NAME_BUF_SIZE]; + int cpu; + +@@ -158,17 +157,12 @@ static int __init hcall_inst_init(void) + } + + hcall_root = debugfs_create_dir(HCALL_ROOT_DIR, NULL); +- if (!hcall_root) +- return -ENOMEM; + + for_each_possible_cpu(cpu) { + snprintf(cpu_name_buf, CPU_NAME_BUF_SIZE, "cpu%d", cpu); +- hcall_file = debugfs_create_file(cpu_name_buf, 0444, +- hcall_root, +- per_cpu(hcall_stats, cpu), +- &hcall_inst_seq_fops); +- if (!hcall_file) +- return -ENOMEM; ++ debugfs_create_file(cpu_name_buf, 0444, hcall_root, ++ per_cpu(hcall_stats, cpu), ++ &hcall_inst_seq_fops); + } + + return 0; +--- a/arch/powerpc/sysdev/scom.c ++++ b/arch/powerpc/sysdev/scom.c +@@ -198,12 +198,6 @@ static int scom_debug_init_one(struct de + ent->path.size = strlen((char *)ent->path.data); + + dir = debugfs_create_dir(ent->name, root); +- if (!dir) { +- of_node_put(dn); +- kfree(ent->path.data); +- kfree(ent); +- return -1; +- } + + debugfs_create_blob("devspec", 0400, dir, &ent->path); + debugfs_create_file("access", 0600, dir, ent, &scom_debug_fops); +@@ -218,8 +212,6 @@ static int scom_debug_init(void) + int i, rc; + + root = debugfs_create_dir("scom", powerpc_debugfs_root); +- if (!root) +- return -1; + + i = rc = 0; + for_each_node_with_property(dn, "scom-controller") { diff --git a/p05 b/p05 new file mode 100644 index 00000000000000..2ea5330c15d0b9 --- /dev/null +++ b/p05 @@ -0,0 +1,113 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] s390: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/s390/hypfs/hypfs_dbfs.c | 4 +--- + arch/s390/include/asm/pci.h | 1 - + arch/s390/kernel/debug.c | 6 ------ + arch/s390/kernel/kdebugfs.c | 2 -- + arch/s390/kernel/sysinfo.c | 2 -- + arch/s390/pci/pci_debug.c | 13 +++---------- + 6 files changed, 4 insertions(+), 24 deletions(-) + +--- a/arch/s390/hypfs/hypfs_dbfs.c ++++ b/arch/s390/hypfs/hypfs_dbfs.c +@@ -82,8 +82,6 @@ int hypfs_dbfs_create_file(struct hypfs_ + { + df->dentry = debugfs_create_file(df->name, 0400, dbfs_dir, df, + &dbfs_ops); +- if (IS_ERR(df->dentry)) +- return PTR_ERR(df->dentry); + mutex_init(&df->lock); + return 0; + } +@@ -96,7 +94,7 @@ void hypfs_dbfs_remove_file(struct hypfs + int hypfs_dbfs_init(void) + { + dbfs_dir = debugfs_create_dir("s390_hypfs", NULL); +- return PTR_ERR_OR_ZERO(dbfs_dir); ++ return 0; + } + + void hypfs_dbfs_exit(void) +--- a/arch/s390/include/asm/pci.h ++++ b/arch/s390/include/asm/pci.h +@@ -148,7 +148,6 @@ struct zpci_dev { + enum pci_bus_speed max_bus_speed; + + struct dentry *debugfs_dev; +- struct dentry *debugfs_perf; + + struct s390_domain *s390_domain; /* s390 IOMMU domain data */ + }; +--- a/arch/s390/kernel/debug.c ++++ b/arch/s390/kernel/debug.c +@@ -1056,12 +1056,6 @@ int debug_register_view(debug_info_t *id + mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); + pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry, + id, &debug_file_ops); +- if (!pde) { +- pr_err("Registering view %s/%s failed due to out of " +- "memory\n", id->name, view->name); +- rc = -1; +- goto out; +- } + spin_lock_irqsave(&id->lock, flags); + for (i = 0; i < DEBUG_MAX_VIEWS; i++) { + if (!id->views[i]) +--- a/arch/s390/kernel/kdebugfs.c ++++ b/arch/s390/kernel/kdebugfs.c +@@ -9,8 +9,6 @@ EXPORT_SYMBOL(arch_debugfs_dir); + static int __init arch_kdebugfs_init(void) + { + arch_debugfs_dir = debugfs_create_dir("s390", NULL); +- if (IS_ERR(arch_debugfs_dir)) +- arch_debugfs_dir = NULL; + return 0; + } + postcore_initcall(arch_kdebugfs_init); +--- a/arch/s390/kernel/sysinfo.c ++++ b/arch/s390/kernel/sysinfo.c +@@ -545,8 +545,6 @@ static __init int stsi_init_debugfs(void + int lvl, i; + + stsi_root = debugfs_create_dir("stsi", arch_debugfs_dir); +- if (IS_ERR_OR_NULL(stsi_root)) +- return 0; + lvl = stsi(NULL, 0, 0, 0); + if (lvl > 0) + stsi_0_0_0 = lvl; +--- a/arch/s390/pci/pci_debug.c ++++ b/arch/s390/pci/pci_debug.c +@@ -172,21 +172,14 @@ static const struct file_operations debu + void zpci_debug_init_device(struct zpci_dev *zdev, const char *name) + { + zdev->debugfs_dev = debugfs_create_dir(name, debugfs_root); +- if (IS_ERR(zdev->debugfs_dev)) +- zdev->debugfs_dev = NULL; + +- zdev->debugfs_perf = debugfs_create_file("statistics", +- S_IFREG | S_IRUGO | S_IWUSR, +- zdev->debugfs_dev, zdev, +- &debugfs_pci_perf_fops); +- if (IS_ERR(zdev->debugfs_perf)) +- zdev->debugfs_perf = NULL; ++ debugfs_create_file("statistics", S_IFREG | S_IRUGO | S_IWUSR, ++ zdev->debugfs_dev, zdev, &debugfs_pci_perf_fops); + } + + void zpci_debug_exit_device(struct zpci_dev *zdev) + { +- debugfs_remove(zdev->debugfs_perf); +- debugfs_remove(zdev->debugfs_dev); ++ debugfs_remove_recursive(zdev->debugfs_dev); + } + + int __init zpci_debug_init(void) diff --git a/p06 b/p06 new file mode 100644 index 00000000000000..6d7414ab58c2ff --- /dev/null +++ b/p06 @@ -0,0 +1,125 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] sh: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/sh/kernel/kdebugfs.c | 3 --- + arch/sh/mm/asids-debugfs.c | 11 +++-------- + arch/sh/mm/cache-debugfs.c | 20 ++++---------------- + arch/sh/mm/pmb.c | 9 ++------- + arch/sh/mm/tlb-debugfs.c | 20 ++++---------------- + 5 files changed, 13 insertions(+), 50 deletions(-) + +--- a/arch/sh/kernel/kdebugfs.c ++++ b/arch/sh/kernel/kdebugfs.c +@@ -9,9 +9,6 @@ EXPORT_SYMBOL(arch_debugfs_dir); + static int __init arch_kdebugfs_init(void) + { + arch_debugfs_dir = debugfs_create_dir("sh", NULL); +- if (!arch_debugfs_dir) +- return -ENOMEM; +- + return 0; + } + arch_initcall(arch_kdebugfs_init); +--- a/arch/sh/mm/asids-debugfs.c ++++ b/arch/sh/mm/asids-debugfs.c +@@ -63,13 +63,8 @@ static const struct file_operations asid + + static int __init asids_debugfs_init(void) + { +- struct dentry *asids_dentry; +- +- asids_dentry = debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir, +- NULL, &asids_debugfs_fops); +- if (!asids_dentry) +- return -ENOMEM; +- +- return PTR_ERR_OR_ZERO(asids_dentry); ++ debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir, NULL, ++ &asids_debugfs_fops); ++ return 0; + } + device_initcall(asids_debugfs_init); +--- a/arch/sh/mm/cache-debugfs.c ++++ b/arch/sh/mm/cache-debugfs.c +@@ -109,22 +109,10 @@ static const struct file_operations cach + + static int __init cache_debugfs_init(void) + { +- struct dentry *dcache_dentry, *icache_dentry; +- +- dcache_dentry = debugfs_create_file("dcache", S_IRUSR, arch_debugfs_dir, +- (unsigned int *)CACHE_TYPE_DCACHE, +- &cache_debugfs_fops); +- if (!dcache_dentry) +- return -ENOMEM; +- +- icache_dentry = debugfs_create_file("icache", S_IRUSR, arch_debugfs_dir, +- (unsigned int *)CACHE_TYPE_ICACHE, +- &cache_debugfs_fops); +- if (!icache_dentry) { +- debugfs_remove(dcache_dentry); +- return -ENOMEM; +- } +- ++ debugfs_create_file("dcache", S_IRUSR, arch_debugfs_dir, ++ (void *)CACHE_TYPE_DCACHE, &cache_debugfs_fops); ++ debugfs_create_file("icache", S_IRUSR, arch_debugfs_dir, ++ (void *)CACHE_TYPE_ICACHE, &cache_debugfs_fops); + return 0; + } + module_init(cache_debugfs_init); +--- a/arch/sh/mm/pmb.c ++++ b/arch/sh/mm/pmb.c +@@ -861,13 +861,8 @@ static const struct file_operations pmb_ + + static int __init pmb_debugfs_init(void) + { +- struct dentry *dentry; +- +- dentry = debugfs_create_file("pmb", S_IFREG | S_IRUGO, +- arch_debugfs_dir, NULL, &pmb_debugfs_fops); +- if (!dentry) +- return -ENOMEM; +- ++ debugfs_create_file("pmb", S_IFREG | S_IRUGO, arch_debugfs_dir, NULL, ++ &pmb_debugfs_fops); + return 0; + } + subsys_initcall(pmb_debugfs_init); +--- a/arch/sh/mm/tlb-debugfs.c ++++ b/arch/sh/mm/tlb-debugfs.c +@@ -149,22 +149,10 @@ static const struct file_operations tlb_ + + static int __init tlb_debugfs_init(void) + { +- struct dentry *itlb, *utlb; +- +- itlb = debugfs_create_file("itlb", S_IRUSR, arch_debugfs_dir, +- (unsigned int *)TLB_TYPE_ITLB, +- &tlb_debugfs_fops); +- if (unlikely(!itlb)) +- return -ENOMEM; +- +- utlb = debugfs_create_file("utlb", S_IRUSR, arch_debugfs_dir, +- (unsigned int *)TLB_TYPE_UTLB, +- &tlb_debugfs_fops); +- if (unlikely(!utlb)) { +- debugfs_remove(itlb); +- return -ENOMEM; +- } +- ++ debugfs_create_file("itlb", S_IRUSR, arch_debugfs_dir, ++ (void *)TLB_TYPE_ITLB, &tlb_debugfs_fops); ++ debugfs_create_file("utlb", S_IRUSR, arch_debugfs_dir, ++ (void *)TLB_TYPE_UTLB, &tlb_debugfs_fops); + return 0; + } + module_init(tlb_debugfs_init); diff --git a/p07 b/p07 new file mode 100644 index 00000000000000..80b91bbded097d --- /dev/null +++ b/p07 @@ -0,0 +1,146 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] x86: mce: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: Ingo Molnar <mingo@redhat.com> +Cc: Borislav Petkov <bp@alien8.de> +Cc: "H. Peter Anvin" <hpa@zytor.com> +Cc: <x86@kernel.org> +Cc: Tony Luck <tony.luck@intel.com> +Cc: Vishal Verma <vishal.l.verma@intel.com> +Cc: Pu Wen <puwen@hygon.cn> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/kernel/cpu/mce/core.c | 15 ++++----------- + arch/x86/kernel/cpu/mce/inject.c | 34 +++++----------------------------- + arch/x86/kernel/cpu/mce/severity.c | 14 +++----------- + 3 files changed, 12 insertions(+), 51 deletions(-) + +--- a/arch/x86/kernel/cpu/mce/core.c ++++ b/arch/x86/kernel/cpu/mce/core.c +@@ -2457,22 +2457,15 @@ static int fake_panic_set(void *data, u6 + DEFINE_SIMPLE_ATTRIBUTE(fake_panic_fops, fake_panic_get, + fake_panic_set, "%llu\n"); + +-static int __init mcheck_debugfs_init(void) ++static void __init mcheck_debugfs_init(void) + { +- struct dentry *dmce, *ffake_panic; ++ struct dentry *dmce; + + dmce = mce_get_debugfs_dir(); +- if (!dmce) +- return -ENOMEM; +- ffake_panic = debugfs_create_file("fake_panic", 0444, dmce, NULL, +- &fake_panic_fops); +- if (!ffake_panic) +- return -ENOMEM; +- +- return 0; ++ debugfs_create_file("fake_panic", 0444, dmce, NULL, &fake_panic_fops); + } + #else +-static int __init mcheck_debugfs_init(void) { return -EINVAL; } ++static void __init mcheck_debugfs_init(void) { } + #endif + + DEFINE_STATIC_KEY_FALSE(mcsafe_key); +--- a/arch/x86/kernel/cpu/mce/inject.c ++++ b/arch/x86/kernel/cpu/mce/inject.c +@@ -648,7 +648,6 @@ static const struct file_operations read + + static struct dfs_node { + char *name; +- struct dentry *d; + const struct file_operations *fops; + umode_t perm; + } dfs_fls[] = { +@@ -662,7 +661,7 @@ static struct dfs_node { + { .name = "README", .fops = &readme_fops, .perm = S_IRUSR | S_IRGRP | S_IROTH }, + }; + +-static int __init debugfs_init(void) ++static void __init debugfs_init(void) + { + unsigned int i; + u64 cap; +@@ -671,30 +670,11 @@ static int __init debugfs_init(void) + n_banks = cap & MCG_BANKCNT_MASK; + + dfs_inj = debugfs_create_dir("mce-inject", NULL); +- if (!dfs_inj) +- return -EINVAL; + +- for (i = 0; i < ARRAY_SIZE(dfs_fls); i++) { +- dfs_fls[i].d = debugfs_create_file(dfs_fls[i].name, +- dfs_fls[i].perm, +- dfs_inj, +- &i_mce, +- dfs_fls[i].fops); +- +- if (!dfs_fls[i].d) +- goto err_dfs_add; +- } +- +- return 0; +- +-err_dfs_add: +- while (i-- > 0) +- debugfs_remove(dfs_fls[i].d); ++ for (i = 0; i < ARRAY_SIZE(dfs_fls); i++) ++ debugfs_create_file(dfs_fls[i].name, dfs_fls[i].perm, dfs_inj, ++ &i_mce, dfs_fls[i].fops); + +- debugfs_remove(dfs_inj); +- dfs_inj = NULL; +- +- return -ENODEV; + } + + static int __init inject_init(void) +@@ -704,11 +684,7 @@ static int __init inject_init(void) + if (!alloc_cpumask_var(&mce_inject_cpumask, GFP_KERNEL)) + return -ENOMEM; + +- err = debugfs_init(); +- if (err) { +- free_cpumask_var(mce_inject_cpumask); +- return err; +- } ++ debugfs_init(); + + register_nmi_handler(NMI_LOCAL, mce_raise_notify, 0, "mce_notify"); + mce_register_injector_chain(&inject_nb); +--- a/arch/x86/kernel/cpu/mce/severity.c ++++ b/arch/x86/kernel/cpu/mce/severity.c +@@ -399,21 +399,13 @@ static const struct file_operations seve + + static int __init severities_debugfs_init(void) + { +- struct dentry *dmce, *fsev; ++ struct dentry *dmce; + + dmce = mce_get_debugfs_dir(); +- if (!dmce) +- goto err_out; +- +- fsev = debugfs_create_file("severities-coverage", 0444, dmce, NULL, +- &severities_coverage_fops); +- if (!fsev) +- goto err_out; + ++ debugfs_create_file("severities-coverage", 0444, dmce, NULL, ++ &severities_coverage_fops); + return 0; +- +-err_out: +- return -ENOMEM; + } + late_initcall(severities_debugfs_init); + #endif /* CONFIG_DEBUG_FS */ diff --git a/p08 b/p08 new file mode 100644 index 00000000000000..dd18811f283d0f --- /dev/null +++ b/p08 @@ -0,0 +1,140 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] x86: kdebugfs: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: Ingo Molnar <mingo@redhat.com> +Cc: Borislav Petkov <bp@alien8.de> +Cc: "H. Peter Anvin" <hpa@zytor.com> +Cc: <x86@kernel.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/kernel/kdebugfs.c | 60 ++++++++------------------------------------- + 1 file changed, 11 insertions(+), 49 deletions(-) + +--- a/arch/x86/kernel/kdebugfs.c ++++ b/arch/x86/kernel/kdebugfs.c +@@ -68,33 +68,18 @@ static const struct file_operations fops + .llseek = default_llseek, + }; + +-static int __init ++static void __init + create_setup_data_node(struct dentry *parent, int no, + struct setup_data_node *node) + { +- struct dentry *d, *type, *data; ++ struct dentry *d; + char buf[16]; + + sprintf(buf, "%d", no); + d = debugfs_create_dir(buf, parent); +- if (!d) +- return -ENOMEM; +- +- type = debugfs_create_x32("type", S_IRUGO, d, &node->type); +- if (!type) +- goto err_dir; +- +- data = debugfs_create_file("data", S_IRUGO, d, node, &fops_setup_data); +- if (!data) +- goto err_type; + +- return 0; +- +-err_type: +- debugfs_remove(type); +-err_dir: +- debugfs_remove(d); +- return -ENOMEM; ++ debugfs_create_x32("type", S_IRUGO, d, &node->type); ++ debugfs_create_file("data", S_IRUGO, d, node, &fops_setup_data); + } + + static int __init create_setup_data_nodes(struct dentry *parent) +@@ -107,8 +92,6 @@ static int __init create_setup_data_node + int no = 0; + + d = debugfs_create_dir("setup_data", parent); +- if (!d) +- return -ENOMEM; + + pa_data = boot_params.hdr.setup_data; + +@@ -129,19 +112,17 @@ static int __init create_setup_data_node + node->paddr = pa_data; + node->type = data->type; + node->len = data->len; +- error = create_setup_data_node(d, no, node); ++ create_setup_data_node(d, no, node); + pa_data = data->next; + + memunmap(data); +- if (error) +- goto err_dir; + no++; + } + + return 0; + + err_dir: +- debugfs_remove(d); ++ debugfs_remove_recursive(d); + return error; + } + +@@ -152,35 +133,18 @@ static struct debugfs_blob_wrapper boot_ + + static int __init boot_params_kdebugfs_init(void) + { +- struct dentry *dbp, *version, *data; +- int error = -ENOMEM; ++ struct dentry *dbp; ++ int error; + + dbp = debugfs_create_dir("boot_params", arch_debugfs_dir); +- if (!dbp) +- return -ENOMEM; + +- version = debugfs_create_x16("version", S_IRUGO, dbp, +- &boot_params.hdr.version); +- if (!version) +- goto err_dir; +- +- data = debugfs_create_blob("data", S_IRUGO, dbp, +- &boot_params_blob); +- if (!data) +- goto err_version; ++ debugfs_create_x16("version", S_IRUGO, dbp, &boot_params.hdr.version); ++ debugfs_create_blob("data", S_IRUGO, dbp, &boot_params_blob); + + error = create_setup_data_nodes(dbp); + if (error) +- goto err_data; ++ debugfs_remove_recursive(dbp); + +- return 0; +- +-err_data: +- debugfs_remove(data); +-err_version: +- debugfs_remove(version); +-err_dir: +- debugfs_remove(dbp); + return error; + } + #endif /* CONFIG_DEBUG_BOOT_PARAMS */ +@@ -190,8 +154,6 @@ static int __init arch_kdebugfs_init(voi + int error = 0; + + arch_debugfs_dir = debugfs_create_dir("x86", NULL); +- if (!arch_debugfs_dir) +- return -ENOMEM; + + #ifdef CONFIG_DEBUG_BOOT_PARAMS + error = boot_params_kdebugfs_init(); diff --git a/p09 b/p09 new file mode 100644 index 00000000000000..69ca9d73f7e270 --- /dev/null +++ b/p09 @@ -0,0 +1,59 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] x86: kvm: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Paolo Bonzini <pbonzini@redhat.com> +Cc: "Radim Krčmář" <rkrcmar@redhat.com> +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: Ingo Molnar <mingo@redhat.com> +Cc: Borislav Petkov <bp@alien8.de> +Cc: "H. Peter Anvin" <hpa@zytor.com> +Cc: <x86@kernel.org> +Cc: <kvm@vger.kernel.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/kvm/debugfs.c | 26 ++++++++------------------ + 1 file changed, 8 insertions(+), 18 deletions(-) + +--- a/arch/x86/kvm/debugfs.c ++++ b/arch/x86/kvm/debugfs.c +@@ -43,26 +43,16 @@ DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling + + int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu) + { +- struct dentry *ret; +- +- ret = debugfs_create_file("tsc-offset", 0444, +- vcpu->debugfs_dentry, +- vcpu, &vcpu_tsc_offset_fops); +- if (!ret) +- return -ENOMEM; ++ debugfs_create_file("tsc-offset", 0444, vcpu->debugfs_dentry, vcpu, ++ &vcpu_tsc_offset_fops); + + if (kvm_has_tsc_control) { +- ret = debugfs_create_file("tsc-scaling-ratio", 0444, +- vcpu->debugfs_dentry, +- vcpu, &vcpu_tsc_scaling_fops); +- if (!ret) +- return -ENOMEM; +- ret = debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444, +- vcpu->debugfs_dentry, +- vcpu, &vcpu_tsc_scaling_frac_fops); +- if (!ret) +- return -ENOMEM; +- ++ debugfs_create_file("tsc-scaling-ratio", 0444, ++ vcpu->debugfs_dentry, vcpu, ++ &vcpu_tsc_scaling_fops); ++ debugfs_create_file("tsc-scaling-ratio-frac-bits", 0444, ++ vcpu->debugfs_dentry, vcpu, ++ &vcpu_tsc_scaling_frac_fops); + } + + return 0; diff --git a/p10 b/p10 new file mode 100644 index 00000000000000..f6ced8bc890755 --- /dev/null +++ b/p10 @@ -0,0 +1,83 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] x86: mm: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/mm/debug_pagetables.c | 35 +++++++---------------------------- + 1 file changed, 7 insertions(+), 28 deletions(-) + +--- a/arch/x86/mm/debug_pagetables.c ++++ b/arch/x86/mm/debug_pagetables.c +@@ -25,8 +25,6 @@ static int ptdump_curknl_show(struct seq + DEFINE_SHOW_ATTRIBUTE(ptdump_curknl); + + #ifdef CONFIG_PAGE_TABLE_ISOLATION +-static struct dentry *pe_curusr; +- + static int ptdump_curusr_show(struct seq_file *m, void *v) + { + if (current->mm->pgd) { +@@ -41,8 +39,6 @@ DEFINE_SHOW_ATTRIBUTE(ptdump_curusr); + #endif + + #if defined(CONFIG_EFI) && defined(CONFIG_X86_64) +-static struct dentry *pe_efi; +- + static int ptdump_efi_show(struct seq_file *m, void *v) + { + if (efi_mm.pgd) +@@ -53,41 +49,24 @@ static int ptdump_efi_show(struct seq_fi + DEFINE_SHOW_ATTRIBUTE(ptdump_efi); + #endif + +-static struct dentry *dir, *pe_knl, *pe_curknl; ++static struct dentry *dir; + + static int __init pt_dump_debug_init(void) + { + dir = debugfs_create_dir("page_tables", NULL); +- if (!dir) +- return -ENOMEM; + +- pe_knl = debugfs_create_file("kernel", 0400, dir, NULL, +- &ptdump_fops); +- if (!pe_knl) +- goto err; +- +- pe_curknl = debugfs_create_file("current_kernel", 0400, +- dir, NULL, &ptdump_curknl_fops); +- if (!pe_curknl) +- goto err; ++ debugfs_create_file("kernel", 0400, dir, NULL, &ptdump_fops); ++ debugfs_create_file("current_kernel", 0400, dir, NULL, ++ &ptdump_curknl_fops); + + #ifdef CONFIG_PAGE_TABLE_ISOLATION +- pe_curusr = debugfs_create_file("current_user", 0400, +- dir, NULL, &ptdump_curusr_fops); +- if (!pe_curusr) +- goto err; ++ debugfs_create_file("current_user", 0400, dir, NULL, ++ &ptdump_curusr_fops); + #endif +- + #if defined(CONFIG_EFI) && defined(CONFIG_X86_64) +- pe_efi = debugfs_create_file("efi", 0400, dir, NULL, &ptdump_efi_fops); +- if (!pe_efi) +- goto err; ++ debugfs_create_file("efi", 0400, dir, NULL, &ptdump_efi_fops); + #endif +- + return 0; +-err: +- debugfs_remove_recursive(dir); +- return -ENOMEM; + } + + static void __exit pt_dump_debug_exit(void) diff --git a/p11 b/p11 new file mode 100644 index 00000000000000..852bb9323a9164 --- /dev/null +++ b/p11 @@ -0,0 +1,177 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] x86: platform: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: Ingo Molnar <mingo@redhat.com> +Cc: Borislav Petkov <bp@alien8.de> +Cc: "H. Peter Anvin" <hpa@zytor.com> +Cc: <x86@kernel.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/platform/atom/punit_atom_debug.c | 22 ++++------------------ + arch/x86/platform/intel-quark/imr.c | 14 ++++---------- + arch/x86/platform/intel/iosf_mbi.c | 21 +++------------------ + arch/x86/platform/uv/tlb_uv.c | 15 ++------------- + 4 files changed, 13 insertions(+), 59 deletions(-) + +--- a/arch/x86/platform/atom/punit_atom_debug.c ++++ b/arch/x86/platform/atom/punit_atom_debug.c +@@ -113,24 +113,12 @@ DEFINE_SHOW_ATTRIBUTE(punit_dev_state); + + static struct dentry *punit_dbg_file; + +-static int punit_dbgfs_register(struct punit_device *punit_device) ++static void punit_dbgfs_register(struct punit_device *punit_device) + { +- struct dentry *dev_state; +- + punit_dbg_file = debugfs_create_dir("punit_atom", NULL); +- if (!punit_dbg_file) +- return -ENXIO; +- +- dev_state = debugfs_create_file("dev_power_state", 0444, +- punit_dbg_file, punit_device, +- &punit_dev_state_fops); +- if (!dev_state) { +- pr_err("punit_dev_state register failed\n"); +- debugfs_remove(punit_dbg_file); +- return -ENXIO; +- } + +- return 0; ++ debugfs_create_file("dev_power_state", 0444, punit_dbg_file, ++ punit_device, &punit_dev_state_fops); + } + + static void punit_dbgfs_unregister(void) +@@ -160,9 +148,7 @@ static int __init punit_atom_debug_init( + if (!id) + return -ENODEV; + +- ret = punit_dbgfs_register((struct punit_device *)id->driver_data); +- if (ret < 0) +- return ret; ++ punit_dbgfs_register((struct punit_device *)id->driver_data); + + return 0; + } +--- a/arch/x86/platform/intel-quark/imr.c ++++ b/arch/x86/platform/intel-quark/imr.c +@@ -34,7 +34,6 @@ + #include <linux/types.h> + + struct imr_device { +- struct dentry *file; + bool init; + struct mutex lock; + int max_imr; +@@ -230,13 +229,11 @@ DEFINE_SHOW_ATTRIBUTE(imr_dbgfs_state); + * imr_debugfs_register - register debugfs hooks. + * + * @idev: pointer to imr_device structure. +- * @return: 0 on success - errno on failure. + */ +-static int imr_debugfs_register(struct imr_device *idev) ++static void imr_debugfs_register(struct imr_device *idev) + { +- idev->file = debugfs_create_file("imr_state", 0444, NULL, idev, +- &imr_dbgfs_state_fops); +- return PTR_ERR_OR_ZERO(idev->file); ++ debugfs_create_file("imr_state", 0444, NULL, idev, ++ &imr_dbgfs_state_fops); + } + + /** +@@ -581,7 +578,6 @@ static const struct x86_cpu_id imr_ids[] + static int __init imr_init(void) + { + struct imr_device *idev = &imr_dev; +- int ret; + + if (!x86_match_cpu(imr_ids) || !iosf_mbi_available()) + return -ENODEV; +@@ -591,9 +587,7 @@ static int __init imr_init(void) + idev->init = true; + + mutex_init(&idev->lock); +- ret = imr_debugfs_register(idev); +- if (ret != 0) +- pr_warn("debugfs register failed!\n"); ++ imr_debugfs_register(idev); + imr_fixup_memmap(idev); + return 0; + } +--- a/arch/x86/platform/intel/iosf_mbi.c ++++ b/arch/x86/platform/intel/iosf_mbi.c +@@ -470,31 +470,16 @@ static struct dentry *iosf_dbg; + + static void iosf_sideband_debug_init(void) + { +- struct dentry *d; +- + iosf_dbg = debugfs_create_dir("iosf_sb", NULL); +- if (IS_ERR_OR_NULL(iosf_dbg)) +- return; + + /* mdr */ +- d = debugfs_create_x32("mdr", 0660, iosf_dbg, &dbg_mdr); +- if (!d) +- goto cleanup; ++ debugfs_create_x32("mdr", 0660, iosf_dbg, &dbg_mdr); + + /* mcrx */ +- d = debugfs_create_x32("mcrx", 0660, iosf_dbg, &dbg_mcrx); +- if (!d) +- goto cleanup; ++ debugfs_create_x32("mcrx", 0660, iosf_dbg, &dbg_mcrx); + + /* mcr - initiates mailbox tranaction */ +- d = debugfs_create_file("mcr", 0660, iosf_dbg, &dbg_mcr, &iosf_mcr_fops); +- if (!d) +- goto cleanup; +- +- return; +- +-cleanup: +- debugfs_remove_recursive(d); ++ debugfs_create_file("mcr", 0660, iosf_dbg, &dbg_mcr, &iosf_mcr_fops); + } + + static void iosf_debugfs_init(void) +--- a/arch/x86/platform/uv/tlb_uv.c ++++ b/arch/x86/platform/uv/tlb_uv.c +@@ -68,7 +68,6 @@ static struct tunables tunables[] = { + }; + + static struct dentry *tunables_dir; +-static struct dentry *tunables_file; + + /* these correspond to the statistics printed by ptc_seq_show() */ + static char *stat_description[] = { +@@ -1702,18 +1701,8 @@ static int __init uv_ptc_init(void) + } + + tunables_dir = debugfs_create_dir(UV_BAU_TUNABLES_DIR, NULL); +- if (!tunables_dir) { +- pr_err("unable to create debugfs directory %s\n", +- UV_BAU_TUNABLES_DIR); +- return -EINVAL; +- } +- tunables_file = debugfs_create_file(UV_BAU_TUNABLES_FILE, 0600, +- tunables_dir, NULL, &tunables_fops); +- if (!tunables_file) { +- pr_err("unable to create debugfs file %s\n", +- UV_BAU_TUNABLES_FILE); +- return -EINVAL; +- } ++ debugfs_create_file(UV_BAU_TUNABLES_FILE, 0600, tunables_dir, NULL, ++ &tunables_fops); + return 0; + } + diff --git a/p12 b/p12 new file mode 100644 index 00000000000000..e23529bb75119c --- /dev/null +++ b/p12 @@ -0,0 +1,53 @@ +From e82f2d8eab210dc7eb0dba2bd8e3c64ad485442b Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 30 May 2018 16:15:35 +0200 +Subject: [PATCH] x86: xen: no need to check return value of debugfs_create functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> +Cc: Juergen Gross <jgross@suse.com> +Cc: Stefano Stabellini <sstabellini@kernel.org> +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: Ingo Molnar <mingo@redhat.com> +Cc: Borislav Petkov <bp@alien8.de> +Cc: "H. Peter Anvin" <hpa@zytor.com> +Cc: <x86@kernel.org> +Cc: <xen-devel@lists.xenproject.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + arch/x86/xen/debugfs.c | 7 +------ + arch/x86/xen/p2m.c | 3 --- + 2 files changed, 1 insertion(+), 9 deletions(-) + +--- a/arch/x86/xen/debugfs.c ++++ b/arch/x86/xen/debugfs.c +@@ -9,13 +9,8 @@ static struct dentry *d_xen_debug; + + struct dentry * __init xen_init_debugfs(void) + { +- if (!d_xen_debug) { ++ if (!d_xen_debug) + d_xen_debug = debugfs_create_dir("xen", NULL); +- +- if (!d_xen_debug) +- pr_warning("Could not create 'xen' debugfs directory\n"); +- } +- + return d_xen_debug; + } + +--- a/arch/x86/xen/p2m.c ++++ b/arch/x86/xen/p2m.c +@@ -810,9 +810,6 @@ static int __init xen_p2m_debugfs(void) + { + struct dentry *d_xen = xen_init_debugfs(); + +- if (d_xen == NULL) +- return -ENOMEM; +- + d_mmu_debug = debugfs_create_dir("mmu", d_xen); + + debugfs_create_file("p2m", 0600, d_mmu_debug, NULL, &p2m_dump_fops); @@ -1,6 +1,21 @@ # -usb-check-usb_get_extra_descriptor-for-proper-size.patch +0001-Bluetooth-check-message-types-in-l2cap_get_conf_opt.patch +0002-Bluetooth-check-the-buffer-size-for-some-messages-be.patch +0003-IN_BADCLASS-fix-macro-to-actually-work.patch +p00 +p01 +p02 +p03 +p04 +p05 +p06 +p07 +p08 +p09 +p10 +p11 +p12 usb_DEVICE_ATTR.patch diff --git a/usb-check-usb_get_extra_descriptor-for-proper-size.patch b/usb-check-usb_get_extra_descriptor-for-proper-size.patch deleted file mode 100644 index 4d8d72d809a614..00000000000000 --- a/usb-check-usb_get_extra_descriptor-for-proper-size.patch +++ /dev/null @@ -1,101 +0,0 @@ -From: Mathias Payer <mathias.payer@nebelwelt.net> -Subject: [PATCH] USB: check usb_get_extra_descriptor for proper size - -From: Mathias Payer <mathias.payer@nebelwelt.net> - -When reading an extra descriptor, we need to properly check the minimum -and maximum size allowed, to prevent from invalid data being sent by a -device. - -Reported-by: Hui Peng <benquike@gmail.com> -Reported-by: Mathias Payer <mathias.payer@nebelwelt.net> -Co-developed-by: Linus Torvalds <torvalds@linux-foundation.org> -Signed-off-by: Hui Peng <benquike@gmail.com> -Signed-off-by: Mathias Payer <mathias.payer@nebelwelt.net> -Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> -Cc: stable <stable@vger.kernel.org> -Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> ---- - drivers/usb/core/hub.c | 2 +- - drivers/usb/core/usb.c | 6 +++--- - drivers/usb/host/hwa-hc.c | 2 +- - include/linux/usb.h | 4 ++-- - 4 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c -index 0f9381b69a3b..d2abb754934c 100644 ---- a/drivers/usb/core/hub.c -+++ b/drivers/usb/core/hub.c -@@ -2251,7 +2251,7 @@ static int usb_enumerate_device_otg(struct usb_device *udev) - /* descriptor may appear anywhere in config */ - err = __usb_get_extra_descriptor(udev->rawdescriptors[0], - le16_to_cpu(udev->config[0].desc.wTotalLength), -- USB_DT_OTG, (void **) &desc); -+ USB_DT_OTG, (void **) &desc, sizeof(*desc)); - if (err || !(desc->bmAttributes & USB_OTG_HNP)) - return 0; - -diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c -index 79d8bd7a612e..4ebfbd737905 100644 ---- a/drivers/usb/core/usb.c -+++ b/drivers/usb/core/usb.c -@@ -832,14 +832,14 @@ EXPORT_SYMBOL_GPL(usb_get_current_frame_number); - */ - - int __usb_get_extra_descriptor(char *buffer, unsigned size, -- unsigned char type, void **ptr) -+ unsigned char type, void **ptr, size_t minsize) - { - struct usb_descriptor_header *header; - - while (size >= sizeof(struct usb_descriptor_header)) { - header = (struct usb_descriptor_header *)buffer; - -- if (header->bLength < 2) { -+ if (header->bLength < 2 || header->bLength > size) { - printk(KERN_ERR - "%s: bogus descriptor, type %d length %d\n", - usbcore_name, -@@ -848,7 +848,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, - return -1; - } - -- if (header->bDescriptorType == type) { -+ if (header->bDescriptorType == type && header->bLength >= minsize) { - *ptr = header; - return 0; - } -diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c -index 684d6f074c3a..09a8ebd95588 100644 ---- a/drivers/usb/host/hwa-hc.c -+++ b/drivers/usb/host/hwa-hc.c -@@ -640,7 +640,7 @@ static int hwahc_security_create(struct hwahc *hwahc) - top = itr + itr_size; - result = __usb_get_extra_descriptor(usb_dev->rawdescriptors[index], - le16_to_cpu(usb_dev->actconfig->desc.wTotalLength), -- USB_DT_SECURITY, (void **) &secd); -+ USB_DT_SECURITY, (void **) &secd, sizeof(*secd)); - if (result == -1) { - dev_warn(dev, "BUG? WUSB host has no security descriptors\n"); - return 0; -diff --git a/include/linux/usb.h b/include/linux/usb.h -index 4cdd515a4385..5e49e82c4368 100644 ---- a/include/linux/usb.h -+++ b/include/linux/usb.h -@@ -407,11 +407,11 @@ struct usb_host_bos { - }; - - int __usb_get_extra_descriptor(char *buffer, unsigned size, -- unsigned char type, void **ptr); -+ unsigned char type, void **ptr, size_t min); - #define usb_get_extra_descriptor(ifpoint, type, ptr) \ - __usb_get_extra_descriptor((ifpoint)->extra, \ - (ifpoint)->extralen, \ -- type, (void **)ptr) -+ type, (void **)ptr, sizeof(**(ptr))) - - /* ----------------------------------------------------------------------- */ - --- -2.19.2 - |
