aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-11-11 13:03:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-11-11 13:03:01 -0500
commit015ed9433be2b476ec7e2e6a9a411a56e3b5b035 (patch)
tree2e9943e5e548f8adc9001a485482a7fcaaa4c067
parent968ef8de555bf3ff6dda467e53660b4144ba0ee1 (diff)
parent4324cb23f4569edcf76e637cdb3c1dfe8e8a85e4 (diff)
Merge branch 'maybe-uninitialized' (patches from Arnd)
Merge fixes for -Wmaybe-uninitialized from Arnd Bergmann: "It took a while for some patches to make it into mainline through maintainer trees, but the 28-patch series is now reduced to 10, with one tiny patch added at the end. Aside from patches that are no longer required, I did these changes compared to version 1: - Dropped "iio: maxim_thermocouple: detect invalid storage size in read()", which is currently in linux-next as commit 32cb7d27e65d. This is the only remaining warning I see for a couple of corner cases (kbuild bot reports it on blackfin, kernelci bot and arm-soc bot both report it on arm64) - Dropped "brcmfmac: avoid maybe-uninitialized warning in brcmf_cfg80211_start_ap", which is currently in net/master merge pending. - Dropped two x86 patches, "x86: math-emu: possible uninitialized variable use" and "x86: mark target address as output in 'insb' asm" as they do not seem to trigger for a default build, and I got no feedback on them. Both of these are ancient issues and seem harmless, I will send them again to the x86 maintainers once the rest is merged. - Dropped "rbd: false-postive gcc-4.9 -Wmaybe-uninitialized" based on feedback from Ilya Dryomov, who already has a different fix queued up for v4.10. The kbuild bot reports this as a warning for xtensa. - Replaced "crypto: aesni: avoid -Wmaybe-uninitialized warning" with a simpler patch, this one always triggers but my first solution would not be safe for linux-4.9 any more at this point. I'll follow up with the larger patch as a cleanup for 4.10. - Replaced "dib0700: fix nec repeat handling" with a better one, contributed by Sean Young" * -Wmaybe-uninitialized fixes: Kbuild: enable -Wmaybe-uninitialized warnings by default pcmcia: fix return value of soc_pcmcia_regulator_set infiniband: shut up a maybe-uninitialized warning crypto: aesni: shut up -Wmaybe-uninitialized warning rc: print correct variable for z8f0811 dib0700: fix nec repeat handling s390: pci: don't print uninitialized data for debugging nios2: fix timer initcall return value x86: apm: avoid uninitialized data NFSv4.1: work around -Wmaybe-uninitialized warning Kbuild: enable -Wmaybe-uninitialized warning for "make W=1"
-rw-r--r--Makefile10
-rw-r--r--arch/arc/Makefile4
-rw-r--r--arch/nios2/kernel/time.c1
-rw-r--r--arch/s390/pci/pci_dma.c2
-rw-r--r--arch/x86/crypto/aesni-intel_glue.c4
-rw-r--r--arch/x86/kernel/apm_32.c5
-rw-r--r--drivers/infiniband/core/cma.c54
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c2
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_core.c5
-rw-r--r--drivers/pcmcia/soc_common.c2
-rw-r--r--scripts/Makefile.extrawarn1
-rw-r--r--scripts/Makefile.ubsan4
12 files changed, 55 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index f97f786de58d..06e2b73978e8 100644
--- a/Makefile
+++ b/Makefile
@@ -370,7 +370,7 @@ LDFLAGS_MODULE =
370CFLAGS_KERNEL = 370CFLAGS_KERNEL =
371AFLAGS_KERNEL = 371AFLAGS_KERNEL =
372LDFLAGS_vmlinux = 372LDFLAGS_vmlinux =
373CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im 373CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized
374CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) 374CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
375 375
376 376
@@ -620,7 +620,6 @@ ARCH_CFLAGS :=
620include arch/$(SRCARCH)/Makefile 620include arch/$(SRCARCH)/Makefile
621 621
622KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) 622KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
623KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
624KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) 623KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
625 624
626ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION 625ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
@@ -629,15 +628,18 @@ KBUILD_CFLAGS += $(call cc-option,-fdata-sections,)
629endif 628endif
630 629
631ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 630ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
632KBUILD_CFLAGS += -Os 631KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
633else 632else
634ifdef CONFIG_PROFILE_ALL_BRANCHES 633ifdef CONFIG_PROFILE_ALL_BRANCHES
635KBUILD_CFLAGS += -O2 634KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
636else 635else
637KBUILD_CFLAGS += -O2 636KBUILD_CFLAGS += -O2
638endif 637endif
639endif 638endif
640 639
640KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
641 $(call cc-disable-warning,maybe-uninitialized,))
642
641# Tell gcc to never replace conditional load with a non-conditional one 643# Tell gcc to never replace conditional load with a non-conditional one
642KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) 644KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
643 645
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 864adad52280..25f81a1db9f9 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -68,7 +68,9 @@ cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi)
68ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE 68ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
69# Generic build system uses -O2, we want -O3 69# Generic build system uses -O2, we want -O3
70# Note: No need to add to cflags-y as that happens anyways 70# Note: No need to add to cflags-y as that happens anyways
71ARCH_CFLAGS += -O3 71#
72# Disable the false maybe-uninitialized warings gcc spits out at -O3
73ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
72endif 74endif
73 75
74# small data is default for elf32 tool-chain. If not usable, disable it 76# small data is default for elf32 tool-chain. If not usable, disable it
diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c
index d9563ddb337e..746bf5caaffc 100644
--- a/arch/nios2/kernel/time.c
+++ b/arch/nios2/kernel/time.c
@@ -324,6 +324,7 @@ static int __init nios2_time_init(struct device_node *timer)
324 ret = nios2_clocksource_init(timer); 324 ret = nios2_clocksource_init(timer);
325 break; 325 break;
326 default: 326 default:
327 ret = 0;
327 break; 328 break;
328 } 329 }
329 330
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 7350c8bc13a2..6b2f72f523b9 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -423,7 +423,7 @@ static int __s390_dma_map_sg(struct device *dev, struct scatterlist *sg,
423 dma_addr_t dma_addr_base, dma_addr; 423 dma_addr_t dma_addr_base, dma_addr;
424 int flags = ZPCI_PTE_VALID; 424 int flags = ZPCI_PTE_VALID;
425 struct scatterlist *s; 425 struct scatterlist *s;
426 unsigned long pa; 426 unsigned long pa = 0;
427 int ret; 427 int ret;
428 428
429 size = PAGE_ALIGN(size); 429 size = PAGE_ALIGN(size);
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 0ab5ee1c26af..aa8b0672f87a 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -888,7 +888,7 @@ static int helper_rfc4106_encrypt(struct aead_request *req)
888 unsigned long auth_tag_len = crypto_aead_authsize(tfm); 888 unsigned long auth_tag_len = crypto_aead_authsize(tfm);
889 u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); 889 u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN)));
890 struct scatter_walk src_sg_walk; 890 struct scatter_walk src_sg_walk;
891 struct scatter_walk dst_sg_walk; 891 struct scatter_walk dst_sg_walk = {};
892 unsigned int i; 892 unsigned int i;
893 893
894 /* Assuming we are supporting rfc4106 64-bit extended */ 894 /* Assuming we are supporting rfc4106 64-bit extended */
@@ -968,7 +968,7 @@ static int helper_rfc4106_decrypt(struct aead_request *req)
968 u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); 968 u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN)));
969 u8 authTag[16]; 969 u8 authTag[16];
970 struct scatter_walk src_sg_walk; 970 struct scatter_walk src_sg_walk;
971 struct scatter_walk dst_sg_walk; 971 struct scatter_walk dst_sg_walk = {};
972 unsigned int i; 972 unsigned int i;
973 973
974 if (unlikely(req->assoclen != 16 && req->assoclen != 20)) 974 if (unlikely(req->assoclen != 16 && req->assoclen != 20))
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index c7364bd633e1..51287cd90bf6 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -1042,8 +1042,11 @@ static int apm_get_power_status(u_short *status, u_short *bat, u_short *life)
1042 1042
1043 if (apm_info.get_power_status_broken) 1043 if (apm_info.get_power_status_broken)
1044 return APM_32_UNSUPPORTED; 1044 return APM_32_UNSUPPORTED;
1045 if (apm_bios_call(&call)) 1045 if (apm_bios_call(&call)) {
1046 if (!call.err)
1047 return APM_NO_ERROR;
1046 return call.err; 1048 return call.err;
1049 }
1047 *status = call.ebx; 1050 *status = call.ebx;
1048 *bat = call.ecx; 1051 *bat = call.ecx;
1049 if (apm_info.get_power_status_swabinminutes) { 1052 if (apm_info.get_power_status_swabinminutes) {
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 36bf50ebb187..89a6b0546804 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1094,47 +1094,47 @@ static void cma_save_ib_info(struct sockaddr *src_addr,
1094 } 1094 }
1095} 1095}
1096 1096
1097static void cma_save_ip4_info(struct sockaddr *src_addr, 1097static void cma_save_ip4_info(struct sockaddr_in *src_addr,
1098 struct sockaddr *dst_addr, 1098 struct sockaddr_in *dst_addr,
1099 struct cma_hdr *hdr, 1099 struct cma_hdr *hdr,
1100 __be16 local_port) 1100 __be16 local_port)
1101{ 1101{
1102 struct sockaddr_in *ip4;
1103
1104 if (src_addr) { 1102 if (src_addr) {
1105 ip4 = (struct sockaddr_in *)src_addr; 1103 *src_addr = (struct sockaddr_in) {
1106 ip4->sin_family = AF_INET; 1104 .sin_family = AF_INET,
1107 ip4->sin_addr.s_addr = hdr->dst_addr.ip4.addr; 1105 .sin_addr.s_addr = hdr->dst_addr.ip4.addr,
1108 ip4->sin_port = local_port; 1106 .sin_port = local_port,
1107 };
1109 } 1108 }
1110 1109
1111 if (dst_addr) { 1110 if (dst_addr) {
1112 ip4 = (struct sockaddr_in *)dst_addr; 1111 *dst_addr = (struct sockaddr_in) {
1113 ip4->sin_family = AF_INET; 1112 .sin_family = AF_INET,
1114 ip4->sin_addr.s_addr = hdr->src_addr.ip4.addr; 1113 .sin_addr.s_addr = hdr->src_addr.ip4.addr,
1115 ip4->sin_port = hdr->port; 1114 .sin_port = hdr->port,
1115 };
1116 } 1116 }
1117} 1117}
1118 1118
1119static void cma_save_ip6_info(struct sockaddr *src_addr, 1119static void cma_save_ip6_info(struct sockaddr_in6 *src_addr,
1120 struct sockaddr *dst_addr, 1120 struct sockaddr_in6 *dst_addr,
1121 struct cma_hdr *hdr, 1121 struct cma_hdr *hdr,
1122 __be16 local_port) 1122 __be16 local_port)
1123{ 1123{
1124 struct sockaddr_in6 *ip6;
1125
1126 if (src_addr) { 1124 if (src_addr) {
1127 ip6 = (struct sockaddr_in6 *)src_addr; 1125 *src_addr = (struct sockaddr_in6) {
1128 ip6->sin6_family = AF_INET6; 1126 .sin6_family = AF_INET6,
1129 ip6->sin6_addr = hdr->dst_addr.ip6; 1127 .sin6_addr = hdr->dst_addr.ip6,
1130 ip6->sin6_port = local_port; 1128 .sin6_port = local_port,
1129 };
1131 } 1130 }
1132 1131
1133 if (dst_addr) { 1132 if (dst_addr) {
1134 ip6 = (struct sockaddr_in6 *)dst_addr; 1133 *dst_addr = (struct sockaddr_in6) {
1135 ip6->sin6_family = AF_INET6; 1134 .sin6_family = AF_INET6,
1136 ip6->sin6_addr = hdr->src_addr.ip6; 1135 .sin6_addr = hdr->src_addr.ip6,
1137 ip6->sin6_port = hdr->port; 1136 .sin6_port = hdr->port,
1137 };
1138 } 1138 }
1139} 1139}
1140 1140
@@ -1159,10 +1159,12 @@ static int cma_save_ip_info(struct sockaddr *src_addr,
1159 1159
1160 switch (cma_get_ip_ver(hdr)) { 1160 switch (cma_get_ip_ver(hdr)) {
1161 case 4: 1161 case 4:
1162 cma_save_ip4_info(src_addr, dst_addr, hdr, port); 1162 cma_save_ip4_info((struct sockaddr_in *)src_addr,
1163 (struct sockaddr_in *)dst_addr, hdr, port);
1163 break; 1164 break;
1164 case 6: 1165 case 6:
1165 cma_save_ip6_info(src_addr, dst_addr, hdr, port); 1166 cma_save_ip6_info((struct sockaddr_in6 *)src_addr,
1167 (struct sockaddr_in6 *)dst_addr, hdr, port);
1166 break; 1168 break;
1167 default: 1169 default:
1168 return -EAFNOSUPPORT; 1170 return -EAFNOSUPPORT;
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index f95a6bc839d5..cede3975d04b 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -118,7 +118,7 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
118 *protocol = RC_TYPE_RC6_MCE; 118 *protocol = RC_TYPE_RC6_MCE;
119 dev &= 0x7f; 119 dev &= 0x7f;
120 dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n", 120 dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n",
121 toggle, vendor, dev, code); 121 *ptoggle, vendor, dev, code);
122 } else { 122 } else {
123 *ptoggle = 0; 123 *ptoggle = 0;
124 *protocol = RC_TYPE_RC6_6A_32; 124 *protocol = RC_TYPE_RC6_6A_32;
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index 92d5408684ac..47ce9d5de4c6 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -704,7 +704,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
704 struct dvb_usb_device *d = purb->context; 704 struct dvb_usb_device *d = purb->context;
705 struct dib0700_rc_response *poll_reply; 705 struct dib0700_rc_response *poll_reply;
706 enum rc_type protocol; 706 enum rc_type protocol;
707 u32 uninitialized_var(keycode); 707 u32 keycode;
708 u8 toggle; 708 u8 toggle;
709 709
710 deb_info("%s()\n", __func__); 710 deb_info("%s()\n", __func__);
@@ -745,7 +745,8 @@ static void dib0700_rc_urb_completion(struct urb *purb)
745 poll_reply->nec.data == 0x00 && 745 poll_reply->nec.data == 0x00 &&
746 poll_reply->nec.not_data == 0xff) { 746 poll_reply->nec.not_data == 0xff) {
747 poll_reply->data_state = 2; 747 poll_reply->data_state = 2;
748 break; 748 rc_repeat(d->rc_dev);
749 goto resubmit;
749 } 750 }
750 751
751 if ((poll_reply->nec.data ^ poll_reply->nec.not_data) != 0xff) { 752 if ((poll_reply->nec.data ^ poll_reply->nec.not_data) != 0xff) {
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 153f3122283d..b6b316de055c 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -107,7 +107,7 @@ int soc_pcmcia_regulator_set(struct soc_pcmcia_socket *skt,
107 107
108 ret = regulator_enable(r->reg); 108 ret = regulator_enable(r->reg);
109 } else { 109 } else {
110 regulator_disable(r->reg); 110 ret = regulator_disable(r->reg);
111 } 111 }
112 if (ret == 0) 112 if (ret == 0)
113 r->on = on; 113 r->on = on;
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 53449a6ff6aa..7c321a603b07 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -36,6 +36,7 @@ warning-2 += -Wshadow
36warning-2 += $(call cc-option, -Wlogical-op) 36warning-2 += $(call cc-option, -Wlogical-op)
37warning-2 += $(call cc-option, -Wmissing-field-initializers) 37warning-2 += $(call cc-option, -Wmissing-field-initializers)
38warning-2 += $(call cc-option, -Wsign-compare) 38warning-2 += $(call cc-option, -Wsign-compare)
39warning-2 += $(call cc-option, -Wmaybe-uninitialized)
39 40
40warning-3 := -Wbad-function-cast 41warning-3 := -Wbad-function-cast
41warning-3 += -Wcast-qual 42warning-3 += -Wcast-qual
diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
index dd779c40c8e6..3b1b13818d59 100644
--- a/scripts/Makefile.ubsan
+++ b/scripts/Makefile.ubsan
@@ -17,4 +17,8 @@ endif
17ifdef CONFIG_UBSAN_NULL 17ifdef CONFIG_UBSAN_NULL
18 CFLAGS_UBSAN += $(call cc-option, -fsanitize=null) 18 CFLAGS_UBSAN += $(call cc-option, -fsanitize=null)
19endif 19endif
20
21 # -fsanitize=* options makes GCC less smart than usual and
22 # increase number of 'maybe-uninitialized false-positives
23 CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)
20endif 24endif