Blob Blame History Raw
From: Stefan Raspl <raspl@linux.ibm.com>
Subject: net/smc: Fix preinitialization of buf_desc in __smc_buf_create()
Patch-mainline: v4.15-rc1
Git-commit: 688703702584dd513b50001bd1eb068655631e9b
References: FATE#325694, LTC#167874, bsc#1113480

Summary:     net/smc: SMC-R MVP
Description: Add latest upstream patches to push SMC-R to the MVP level

Upstream-Description:

             net/smc: Fix preinitialization of buf_desc in __smc_buf_create()

             With gcc-4.1.2:

                 net/smc/smc_core.c: In function ‘__smc_buf_create’:
                 net/smc/smc_core.c:567: warning: ‘bufsize’ may be used uninitialized in this function

             Indeed, if the for-loop is never executed, bufsize is used
             uninitialized.  In addition, buf_desc is stored for later use, while it
             is still a NULL pointer.

             Before, error handling was done by checking if buf_desc is non-NULL.
             The cleanup changed this to an error check, but forgot to update the
             preinitialization of buf_desc to an error pointer.

             Update the preinitializatin of buf_desc to fix this.

             Fixes: b33982c3a6838d13 ("net/smc: cleanup function __smc_buf_create()")
             Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
             Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
             Acked-by: Arnd Bergmann <arnd@arndb.de>
             Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 net/smc/smc_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -561,7 +561,7 @@ static int __smc_buf_create(struct smc_s
 {
 	struct smc_connection *conn = &smc->conn;
 	struct smc_link_group *lgr = conn->lgr;
-	struct smc_buf_desc *buf_desc = NULL;
+	struct smc_buf_desc *buf_desc = ERR_PTR(-ENOMEM);
 	struct list_head *buf_list;
 	int bufsize, bufsize_short;
 	int sk_buf_size;