--- /dev/null
+From 1a263ae60b04de959d9ce9caea4889385eefcc7b Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sat, 9 May 2020 15:58:04 -0700
+Subject: gcc-10: avoid shadowing standard library 'free()' in crypto
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit 1a263ae60b04de959d9ce9caea4889385eefcc7b upstream.
+
+gcc-10 has started warning about conflicting types for a few new
+built-in functions, particularly 'free()'.
+
+This results in warnings like:
+
+ crypto/xts.c:325:13: warning: conflicting types for built-in function ‘free’; expected ‘void(void *)’ [-Wbuiltin-declaration-mismatch]
+
+because the crypto layer had its local freeing functions called
+'free()'.
+
+Gcc-10 is in the wrong here, since that function is marked 'static', and
+thus there is no chance of confusion with any standard library function
+namespace.
+
+But the simplest thing to do is to just use a different name here, and
+avoid this gcc mis-feature.
+
+[ Side note: gcc knowing about 'free()' is in itself not the
+ mis-feature: the semantics of 'free()' are special enough that a
+ compiler can validly do special things when seeing it.
+
+ So the mis-feature here is that gcc thinks that 'free()' is some
+ restricted name, and you can't shadow it as a local static function.
+
+ Making the special 'free()' semantics be a function attribute rather
+ than tied to the name would be the much better model ]
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ crypto/lrw.c | 4 ++--
+ crypto/xts.c | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+--- a/crypto/lrw.c
++++ b/crypto/lrw.c
+@@ -289,7 +289,7 @@ static void exit_tfm(struct crypto_skcip
+ crypto_free_skcipher(ctx->child);
+ }
+
+-static void free(struct skcipher_instance *inst)
++static void free_inst(struct skcipher_instance *inst)
+ {
+ crypto_drop_skcipher(skcipher_instance_ctx(inst));
+ kfree(inst);
+@@ -401,7 +401,7 @@ static int create(struct crypto_template
+ inst->alg.encrypt = encrypt;
+ inst->alg.decrypt = decrypt;
+
+- inst->free = free;
++ inst->free = free_inst;
+
+ err = skcipher_register_instance(tmpl, inst);
+ if (err)
+--- a/crypto/xts.c
++++ b/crypto/xts.c
+@@ -328,7 +328,7 @@ static void exit_tfm(struct crypto_skcip
+ crypto_free_cipher(ctx->tweak);
+ }
+
+-static void free(struct skcipher_instance *inst)
++static void free_inst(struct skcipher_instance *inst)
+ {
+ crypto_drop_skcipher(skcipher_instance_ctx(inst));
+ kfree(inst);
+@@ -439,7 +439,7 @@ static int create(struct crypto_template
+ inst->alg.encrypt = encrypt;
+ inst->alg.decrypt = decrypt;
+
+- inst->free = free;
++ inst->free = free_inst;
+
+ err = skcipher_register_instance(tmpl, inst);
+ if (err)
--- /dev/null
+From 44720996e2d79e47d508b0abe99b931a726a3197 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sat, 9 May 2020 14:52:44 -0700
+Subject: gcc-10: disable 'array-bounds' warning for now
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit 44720996e2d79e47d508b0abe99b931a726a3197 upstream.
+
+This is another fine warning, related to the 'zero-length-bounds' one,
+but hitting the same historical code in the kernel.
+
+Because C didn't historically support flexible array members, we have
+code that instead uses a one-sized array, the same way we have cases of
+zero-sized arrays.
+
+The one-sized arrays come from either not wanting to use the gcc
+zero-sized array extension, or from a slight convenience-feature, where
+particularly for strings, the size of the structure now includes the
+allocation for the final NUL character.
+
+So with a "char name[1];" at the end of a structure, you can do things
+like
+
+ v = my_malloc(sizeof(struct vendor) + strlen(name));
+
+and avoid the "+1" for the terminator.
+
+Yes, the modern way to do that is with a flexible array, and using
+'offsetof()' instead of 'sizeof()', and adding the "+1" by hand. That
+also technically gets the size "more correct" in that it avoids any
+alignment (and thus padding) issues, but this is another long-term
+cleanup thing that will not happen for 5.7.
+
+So disable the warning for now, even though it's potentially quite
+useful. Having a slew of warnings that then hide more urgent new issues
+is not an improvement.
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Makefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -858,6 +858,7 @@ KBUILD_CFLAGS += $(call cc-disable-warni
+
+ # We'll want to enable this eventually, but it's not going away for 5.7 at least
+ KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
++KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
+
+ # Enabled with W=2, disabled by default as noisy
+ KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
--- /dev/null
+From adc71920969870dfa54e8f40dac8616284832d02 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sat, 9 May 2020 15:45:21 -0700
+Subject: gcc-10: disable 'restrict' warning for now
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit adc71920969870dfa54e8f40dac8616284832d02 upstream.
+
+gcc-10 now warns about passing aliasing pointers to functions that take
+restricted pointers.
+
+That's actually a great warning, and if we ever start using 'restrict'
+in the kernel, it might be quite useful. But right now we don't, and it
+turns out that the only thing this warns about is an idiom where we have
+declared a few functions to be "printf-like" (which seems to make gcc
+pick up the restricted pointer thing), and then we print to the same
+buffer that we also use as an input.
+
+And people do that as an odd concatenation pattern, with code like this:
+
+ #define sysfs_show_gen_prop(buffer, fmt, ...) \
+ snprintf(buffer, PAGE_SIZE, "%s"fmt, buffer, __VA_ARGS__)
+
+where we have 'buffer' as both the destination of the final result, and
+as the initial argument.
+
+Yes, it's a bit questionable. And outside of the kernel, people do have
+standard declarations like
+
+ int snprintf( char *restrict buffer, size_t bufsz,
+ const char *restrict format, ... );
+
+where that output buffer is marked as a restrict pointer that cannot
+alias with any other arguments.
+
+But in the context of the kernel, that 'use snprintf() to concatenate to
+the end result' does work, and the pattern shows up in multiple places.
+And we have not marked our own version of snprintf() as taking restrict
+pointers, so the warning is incorrect for now, and gcc picks it up on
+its own.
+
+If we do start using 'restrict' in the kernel (and it might be a good
+idea if people find places where it matters), we'll need to figure out
+how to avoid this issue for snprintf and friends. But in the meantime,
+this warning is not useful.
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Makefile | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -861,6 +861,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni
+ KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
+ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
+
++# Another good warning that we'll want to enable eventually
++KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
++
+ # Enabled with W=2, disabled by default as noisy
+ KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
+
--- /dev/null
+From 5a76021c2eff7fcf2f0918a08fd8a37ce7922921 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sat, 9 May 2020 15:40:52 -0700
+Subject: gcc-10: disable 'stringop-overflow' warning for now
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit 5a76021c2eff7fcf2f0918a08fd8a37ce7922921 upstream.
+
+This is the final array bounds warning removal for gcc-10 for now.
+
+Again, the warning is good, and we should re-enable all these warnings
+when we have converted all the legacy array declaration cases to
+flexible arrays. But in the meantime, it's just noise.
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Makefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -859,6 +859,7 @@ KBUILD_CFLAGS += $(call cc-disable-warni
+ # We'll want to enable this eventually, but it's not going away for 5.7 at least
+ KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
+ KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
++KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
+
+ # Enabled with W=2, disabled by default as noisy
+ KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
--- /dev/null
+From 5c45de21a2223fe46cf9488c99a7fbcf01527670 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sat, 9 May 2020 14:30:29 -0700
+Subject: gcc-10: disable 'zero-length-bounds' warning for now
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit 5c45de21a2223fe46cf9488c99a7fbcf01527670 upstream.
+
+This is a fine warning, but we still have a number of zero-length arrays
+in the kernel that come from the traditional gcc extension. Yes, they
+are getting converted to flexible arrays, but in the meantime the gcc-10
+warning about zero-length bounds is very verbose, and is hiding other
+issues.
+
+I missed one actual build failure because it was hidden among hundreds
+of lines of warning. Thankfully I caught it on the second go before
+pushing things out, but it convinced me that I really need to disable
+the new warnings for now.
+
+We'll hopefully be all done with our conversion to flexible arrays in
+the not too distant future, and we can then re-enable this warning.
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Makefile | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -856,6 +856,9 @@ KBUILD_CFLAGS += -Wno-pointer-sign
+ # disable stringop warnings in gcc 8+
+ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
+
++# We'll want to enable this eventually, but it's not going away for 5.7 at least
++KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
++
+ # Enabled with W=2, disabled by default as noisy
+ KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
+
--- /dev/null
+From e99332e7b4cda6e60f5b5916cf9943a79dbef902 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sat, 9 May 2020 17:50:03 -0700
+Subject: gcc-10: mark more functions __init to avoid section mismatch warnings
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit e99332e7b4cda6e60f5b5916cf9943a79dbef902 upstream.
+
+It seems that for whatever reason, gcc-10 ends up not inlining a couple
+of functions that used to be inlined before. Even if they only have one
+single callsite - it looks like gcc may have decided that the code was
+unlikely, and not worth inlining.
+
+The code generation difference is harmless, but caused a few new section
+mismatch errors, since the (now no longer inlined) function wasn't in
+the __init section, but called other init functions:
+
+ Section mismatch in reference from the function kexec_free_initrd() to the function .init.text:free_initrd_mem()
+ Section mismatch in reference from the function tpm2_calc_event_log_size() to the function .init.text:early_memremap()
+ Section mismatch in reference from the function tpm2_calc_event_log_size() to the function .init.text:early_memunmap()
+
+So add the appropriate __init annotation to make modpost not complain.
+In both cases there were trivially just a single callsite from another
+__init function.
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/firmware/efi/tpm.c | 2 +-
+ init/initramfs.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/firmware/efi/tpm.c
++++ b/drivers/firmware/efi/tpm.c
+@@ -16,7 +16,7 @@
+ int efi_tpm_final_log_size;
+ EXPORT_SYMBOL(efi_tpm_final_log_size);
+
+-static int tpm2_calc_event_log_size(void *data, int count, void *size_info)
++static int __init tpm2_calc_event_log_size(void *data, int count, void *size_info)
+ {
+ struct tcg_pcr_event2_head *header;
+ int event_size, size = 0;
+--- a/init/initramfs.c
++++ b/init/initramfs.c
+@@ -534,7 +534,7 @@ void __weak free_initrd_mem(unsigned lon
+ }
+
+ #ifdef CONFIG_KEXEC_CORE
+-static bool kexec_free_initrd(void)
++static bool __init kexec_free_initrd(void)
+ {
+ unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
+ unsigned long crashk_end = (unsigned long)__va(crashk_res.end);
--- /dev/null
+From 9d82973e032e246ff5663c9805fbb5407ae932e3 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Mon, 4 May 2020 09:16:37 -0700
+Subject: gcc-10 warnings: fix low-hanging fruit
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit 9d82973e032e246ff5663c9805fbb5407ae932e3 upstream.
+
+Due to a bug-report that was compiler-dependent, I updated one of my
+machines to gcc-10. That shows a lot of new warnings. Happily they
+seem to be mostly the valid kind, but it's going to cause a round of
+churn for getting rid of them..
+
+This is the really low-hanging fruit of removing a couple of zero-sized
+arrays in some core code. We have had a round of these patches before,
+and we'll have many more coming, and there is nothing special about
+these except that they were particularly trivial, and triggered more
+warnings than most.
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/fs.h | 2 +-
+ include/linux/tty.h | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/include/linux/fs.h
++++ b/include/linux/fs.h
+@@ -978,7 +978,7 @@ struct file_handle {
+ __u32 handle_bytes;
+ int handle_type;
+ /* file identifier */
+- unsigned char f_handle[0];
++ unsigned char f_handle[];
+ };
+
+ static inline struct file *get_file(struct file *f)
+--- a/include/linux/tty.h
++++ b/include/linux/tty.h
+@@ -66,7 +66,7 @@ struct tty_buffer {
+ int read;
+ int flags;
+ /* Data points here */
+- unsigned long data[0];
++ unsigned long data[];
+ };
+
+ /* Values for .flags field of tty_buffer */
--- /dev/null
+From 7dba92037baf3fa00b4880a31fd532542264994c Mon Sep 17 00:00:00 2001
+From: Jason Gunthorpe <jgg@ziepe.ca>
+Date: Tue, 14 Apr 2020 20:02:07 -0300
+Subject: net/rds: Use ERR_PTR for rds_message_alloc_sgs()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Jason Gunthorpe <jgg@mellanox.com>
+
+commit 7dba92037baf3fa00b4880a31fd532542264994c upstream.
+
+Returning the error code via a 'int *ret' when the function returns a
+pointer is very un-kernely and causes gcc 10's static analysis to choke:
+
+net/rds/message.c: In function ‘rds_message_map_pages’:
+net/rds/message.c:358:10: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
+ 358 | return ERR_PTR(ret);
+
+Use a typical ERR_PTR return instead.
+
+Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
+Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/rds/message.c | 19 ++++++-------------
+ net/rds/rdma.c | 12 ++++++++----
+ net/rds/rds.h | 3 +--
+ net/rds/send.c | 6 ++++--
+ 4 files changed, 19 insertions(+), 21 deletions(-)
+
+--- a/net/rds/message.c
++++ b/net/rds/message.c
+@@ -308,26 +308,20 @@ out:
+ /*
+ * RDS ops use this to grab SG entries from the rm's sg pool.
+ */
+-struct scatterlist *rds_message_alloc_sgs(struct rds_message *rm, int nents,
+- int *ret)
++struct scatterlist *rds_message_alloc_sgs(struct rds_message *rm, int nents)
+ {
+ struct scatterlist *sg_first = (struct scatterlist *) &rm[1];
+ struct scatterlist *sg_ret;
+
+- if (WARN_ON(!ret))
+- return NULL;
+-
+ if (nents <= 0) {
+ pr_warn("rds: alloc sgs failed! nents <= 0\n");
+- *ret = -EINVAL;
+- return NULL;
++ return ERR_PTR(-EINVAL);
+ }
+
+ if (rm->m_used_sgs + nents > rm->m_total_sgs) {
+ pr_warn("rds: alloc sgs failed! total %d used %d nents %d\n",
+ rm->m_total_sgs, rm->m_used_sgs, nents);
+- *ret = -ENOMEM;
+- return NULL;
++ return ERR_PTR(-ENOMEM);
+ }
+
+ sg_ret = &sg_first[rm->m_used_sgs];
+@@ -343,7 +337,6 @@ struct rds_message *rds_message_map_page
+ unsigned int i;
+ int num_sgs = DIV_ROUND_UP(total_len, PAGE_SIZE);
+ int extra_bytes = num_sgs * sizeof(struct scatterlist);
+- int ret;
+
+ rm = rds_message_alloc(extra_bytes, GFP_NOWAIT);
+ if (!rm)
+@@ -352,10 +345,10 @@ struct rds_message *rds_message_map_page
+ set_bit(RDS_MSG_PAGEVEC, &rm->m_flags);
+ rm->m_inc.i_hdr.h_len = cpu_to_be32(total_len);
+ rm->data.op_nents = DIV_ROUND_UP(total_len, PAGE_SIZE);
+- rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs, &ret);
+- if (!rm->data.op_sg) {
++ rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs);
++ if (IS_ERR(rm->data.op_sg)) {
+ rds_message_put(rm);
+- return ERR_PTR(ret);
++ return ERR_CAST(rm->data.op_sg);
+ }
+
+ for (i = 0; i < rm->data.op_nents; ++i) {
+--- a/net/rds/rdma.c
++++ b/net/rds/rdma.c
+@@ -624,9 +624,11 @@ int rds_cmsg_rdma_args(struct rds_sock *
+ op->op_active = 1;
+ op->op_recverr = rs->rs_recverr;
+ WARN_ON(!nr_pages);
+- op->op_sg = rds_message_alloc_sgs(rm, nr_pages, &ret);
+- if (!op->op_sg)
++ op->op_sg = rds_message_alloc_sgs(rm, nr_pages);
++ if (IS_ERR(op->op_sg)) {
++ ret = PTR_ERR(op->op_sg);
+ goto out_pages;
++ }
+
+ if (op->op_notify || op->op_recverr) {
+ /* We allocate an uninitialized notifier here, because
+@@ -828,9 +830,11 @@ int rds_cmsg_atomic(struct rds_sock *rs,
+ rm->atomic.op_silent = !!(args->flags & RDS_RDMA_SILENT);
+ rm->atomic.op_active = 1;
+ rm->atomic.op_recverr = rs->rs_recverr;
+- rm->atomic.op_sg = rds_message_alloc_sgs(rm, 1, &ret);
+- if (!rm->atomic.op_sg)
++ rm->atomic.op_sg = rds_message_alloc_sgs(rm, 1);
++ if (IS_ERR(rm->atomic.op_sg)) {
++ ret = PTR_ERR(rm->atomic.op_sg);
+ goto err;
++ }
+
+ /* verify 8 byte-aligned */
+ if (args->local_addr & 0x7) {
+--- a/net/rds/rds.h
++++ b/net/rds/rds.h
+@@ -849,8 +849,7 @@ rds_conn_connecting(struct rds_connectio
+
+ /* message.c */
+ struct rds_message *rds_message_alloc(unsigned int nents, gfp_t gfp);
+-struct scatterlist *rds_message_alloc_sgs(struct rds_message *rm, int nents,
+- int *ret);
++struct scatterlist *rds_message_alloc_sgs(struct rds_message *rm, int nents);
+ int rds_message_copy_from_user(struct rds_message *rm, struct iov_iter *from,
+ bool zcopy);
+ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned int total_len);
+--- a/net/rds/send.c
++++ b/net/rds/send.c
+@@ -1274,9 +1274,11 @@ int rds_sendmsg(struct socket *sock, str
+
+ /* Attach data to the rm */
+ if (payload_len) {
+- rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs, &ret);
+- if (!rm->data.op_sg)
++ rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs);
++ if (IS_ERR(rm->data.op_sg)) {
++ ret = PTR_ERR(rm->data.op_sg);
+ goto out;
++ }
+ ret = rds_message_copy_from_user(rm, &msg->msg_iter, zcopy);
+ if (ret)
+ goto out;
--- /dev/null
+From 01b2bafe57b19d9119413f138765ef57990921ce Mon Sep 17 00:00:00 2001
+From: Jason Gunthorpe <jgg@ziepe.ca>
+Date: Tue, 14 Apr 2020 12:10:50 -0300
+Subject: pnp: Use list_for_each_entry() instead of open coding
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Jason Gunthorpe <jgg@mellanox.com>
+
+commit 01b2bafe57b19d9119413f138765ef57990921ce upstream.
+
+Aside from good practice, this avoids a warning from gcc 10:
+
+./include/linux/kernel.h:997:3: warning: array subscript -31 is outside array bounds of ‘struct list_head[1]’ [-Warray-bounds]
+ 997 | ((type *)(__mptr - offsetof(type, member))); })
+ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+./include/linux/list.h:493:2: note: in expansion of macro ‘container_of’
+ 493 | container_of(ptr, type, member)
+ | ^~~~~~~~~~~~
+./include/linux/pnp.h:275:30: note: in expansion of macro ‘list_entry’
+ 275 | #define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
+ | ^~~~~~~~~~
+./include/linux/pnp.h:281:11: note: in expansion of macro ‘global_to_pnp_dev’
+ 281 | (dev) != global_to_pnp_dev(&pnp_global); \
+ | ^~~~~~~~~~~~~~~~~
+arch/x86/kernel/rtc.c:189:2: note: in expansion of macro ‘pnp_for_each_dev’
+ 189 | pnp_for_each_dev(dev) {
+
+Because the common code doesn't cast the starting list_head to the
+containing struct.
+
+Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
+[ rjw: Whitespace adjustments ]
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/pnp.h | 29 +++++++++--------------------
+ 1 file changed, 9 insertions(+), 20 deletions(-)
+
+--- a/include/linux/pnp.h
++++ b/include/linux/pnp.h
+@@ -220,10 +220,8 @@ struct pnp_card {
+ #define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
+ #define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
+ #define to_pnp_card(n) container_of(n, struct pnp_card, dev)
+-#define pnp_for_each_card(card) \
+- for((card) = global_to_pnp_card(pnp_cards.next); \
+- (card) != global_to_pnp_card(&pnp_cards); \
+- (card) = global_to_pnp_card((card)->global_list.next))
++#define pnp_for_each_card(card) \
++ list_for_each_entry(card, &pnp_cards, global_list)
+
+ struct pnp_card_link {
+ struct pnp_card *card;
+@@ -276,14 +274,9 @@ struct pnp_dev {
+ #define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list)
+ #define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list)
+ #define to_pnp_dev(n) container_of(n, struct pnp_dev, dev)
+-#define pnp_for_each_dev(dev) \
+- for((dev) = global_to_pnp_dev(pnp_global.next); \
+- (dev) != global_to_pnp_dev(&pnp_global); \
+- (dev) = global_to_pnp_dev((dev)->global_list.next))
+-#define card_for_each_dev(card,dev) \
+- for((dev) = card_to_pnp_dev((card)->devices.next); \
+- (dev) != card_to_pnp_dev(&(card)->devices); \
+- (dev) = card_to_pnp_dev((dev)->card_list.next))
++#define pnp_for_each_dev(dev) list_for_each_entry(dev, &pnp_global, global_list)
++#define card_for_each_dev(card, dev) \
++ list_for_each_entry(dev, &(card)->devices, card_list)
+ #define pnp_dev_name(dev) (dev)->name
+
+ static inline void *pnp_get_drvdata(struct pnp_dev *pdev)
+@@ -437,14 +430,10 @@ struct pnp_protocol {
+ };
+
+ #define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
+-#define protocol_for_each_card(protocol,card) \
+- for((card) = protocol_to_pnp_card((protocol)->cards.next); \
+- (card) != protocol_to_pnp_card(&(protocol)->cards); \
+- (card) = protocol_to_pnp_card((card)->protocol_list.next))
+-#define protocol_for_each_dev(protocol,dev) \
+- for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \
+- (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
+- (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
++#define protocol_for_each_card(protocol, card) \
++ list_for_each_entry(card, &(protocol)->cards, protocol_list)
++#define protocol_for_each_dev(protocol, dev) \
++ list_for_each_entry(dev, &(protocol)->devices, protocol_list)
+
+ extern struct bus_type pnp_bus_type;
+
s390-ism-fix-error-return-code-in-ism_probe.patch
mm-memcg-fix-inconsistent-oom-event-behavior.patch
nfsv3-fix-rpc-receive-buffer-size-for-mount-call.patch
+pnp-use-list_for_each_entry-instead-of-open-coding.patch
+net-rds-use-err_ptr-for-rds_message_alloc_sgs.patch
+stop-the-ad-hoc-games-with-wno-maybe-initialized.patch
+gcc-10-disable-zero-length-bounds-warning-for-now.patch
+gcc-10-disable-array-bounds-warning-for-now.patch
+gcc-10-disable-stringop-overflow-warning-for-now.patch
+gcc-10-disable-restrict-warning-for-now.patch
+gcc-10-warnings-fix-low-hanging-fruit.patch
+gcc-10-mark-more-functions-__init-to-avoid-section-mismatch-warnings.patch
+gcc-10-avoid-shadowing-standard-library-free-in-crypto.patch
--- /dev/null
+From 78a5255ffb6a1af189a83e493d916ba1c54d8c75 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sat, 9 May 2020 13:57:10 -0700
+Subject: Stop the ad-hoc games with -Wno-maybe-initialized
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit 78a5255ffb6a1af189a83e493d916ba1c54d8c75 upstream.
+
+We have some rather random rules about when we accept the
+"maybe-initialized" warnings, and when we don't.
+
+For example, we consider it unreliable for gcc versions < 4.9, but also
+if -O3 is enabled, or if optimizing for size. And then various kernel
+config options disabled it, because they know that they trigger that
+warning by confusing gcc sufficiently (ie PROFILE_ALL_BRANCHES).
+
+And now gcc-10 seems to be introducing a lot of those warnings too, so
+it falls under the same heading as 4.9 did.
+
+At the same time, we have a very straightforward way to _enable_ that
+warning when wanted: use "W=2" to enable more warnings.
+
+So stop playing these ad-hoc games, and just disable that warning by
+default, with the known and straight-forward "if you want to work on the
+extra compiler warnings, use W=123".
+
+Would it be great to have code that is always so obvious that it never
+confuses the compiler whether a variable is used initialized or not?
+Yes, it would. In a perfect world, the compilers would be smarter, and
+our source code would be simpler.
+
+That's currently not the world we live in, though.
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Makefile | 7 +++----
+ init/Kconfig | 18 ------------------
+ kernel/trace/Kconfig | 1 -
+ 3 files changed, 3 insertions(+), 23 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -707,10 +707,6 @@ else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+ KBUILD_CFLAGS += -Os
+ endif
+
+-ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
+-KBUILD_CFLAGS += -Wno-maybe-uninitialized
+-endif
+-
+ # Tell gcc to never replace conditional load with a non-conditional one
+ KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
+
+@@ -860,6 +856,9 @@ KBUILD_CFLAGS += -Wno-pointer-sign
+ # disable stringop warnings in gcc 8+
+ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
+
++# Enabled with W=2, disabled by default as noisy
++KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
++
+ # disable invalid "can't wrap" optimizations for signed / pointers
+ KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
+
+--- a/init/Kconfig
++++ b/init/Kconfig
+@@ -36,22 +36,6 @@ config TOOLS_SUPPORT_RELR
+ config CC_HAS_ASM_INLINE
+ def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null)
+
+-config CC_HAS_WARN_MAYBE_UNINITIALIZED
+- def_bool $(cc-option,-Wmaybe-uninitialized)
+- help
+- GCC >= 4.7 supports this option.
+-
+-config CC_DISABLE_WARN_MAYBE_UNINITIALIZED
+- bool
+- depends on CC_HAS_WARN_MAYBE_UNINITIALIZED
+- default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9
+- help
+- GCC's -Wmaybe-uninitialized is not reliable by definition.
+- Lots of false positive warnings are produced in some cases.
+-
+- If this option is enabled, -Wno-maybe-uninitialzed is passed
+- to the compiler to suppress maybe-uninitialized warnings.
+-
+ config CONSTRUCTORS
+ bool
+ depends on !UML
+@@ -1226,14 +1210,12 @@ config CC_OPTIMIZE_FOR_PERFORMANCE
+ config CC_OPTIMIZE_FOR_PERFORMANCE_O3
+ bool "Optimize more for performance (-O3)"
+ depends on ARC
+- imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
+ help
+ Choosing this option will pass "-O3" to your compiler to optimize
+ the kernel yet more for performance.
+
+ config CC_OPTIMIZE_FOR_SIZE
+ bool "Optimize for size (-Os)"
+- imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
+ help
+ Choosing this option will pass "-Os" to your compiler resulting
+ in a smaller kernel.
+--- a/kernel/trace/Kconfig
++++ b/kernel/trace/Kconfig
+@@ -371,7 +371,6 @@ config PROFILE_ANNOTATED_BRANCHES
+ config PROFILE_ALL_BRANCHES
+ bool "Profile all if conditionals" if !FORTIFY_SOURCE
+ select TRACE_BRANCH_PROFILING
+- imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
+ help
+ This tracer profiles all branch conditions. Every if ()
+ taken in the kernel is recorded whether it hit or miss.