* [PATCH] net/smc: Fix preinitialization of buf_desc in __smc_buf_create()
@ 2017-11-16 11:22 Geert Uytterhoeven
2017-11-16 11:35 ` Arnd Bergmann
2017-11-16 18:14 ` Ursula Braun
0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2017-11-16 11:22 UTC (permalink / raw)
To: Ursula Braun, David S . Miller
Cc: Arnd Bergmann, linux-s390, netdev, linux-kernel, Geert Uytterhoeven
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>
---
I don't know if this can ever happen, but the old code handled it.
---
net/smc/smc_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 2578fbd95664af84..453c54467082d93f 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -562,7 +562,7 @@ static int __smc_buf_create(struct smc_sock *smc, bool is_rmb)
{
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;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net/smc: Fix preinitialization of buf_desc in __smc_buf_create()
2017-11-16 11:22 [PATCH] net/smc: Fix preinitialization of buf_desc in __smc_buf_create() Geert Uytterhoeven
@ 2017-11-16 11:35 ` Arnd Bergmann
2017-11-16 18:14 ` Ursula Braun
1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-11-16 11:35 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Ursula Braun, David S . Miller, linux-s390, Networking,
Linux Kernel Mailing List
On Thu, Nov 16, 2017 at 12:22 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> 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>
> ---
> I don't know if this can ever happen, but the old code handled it.
Acked-by: Arnd Bergmann <arnd@arndb.de>
This one I could reproduce with gcc-4.1 on x86, but not gcc-4.2 or higher.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/smc: Fix preinitialization of buf_desc in __smc_buf_create()
2017-11-16 11:22 [PATCH] net/smc: Fix preinitialization of buf_desc in __smc_buf_create() Geert Uytterhoeven
2017-11-16 11:35 ` Arnd Bergmann
@ 2017-11-16 18:14 ` Ursula Braun
1 sibling, 0 replies; 3+ messages in thread
From: Ursula Braun @ 2017-11-16 18:14 UTC (permalink / raw)
To: Geert Uytterhoeven, David S . Miller
Cc: Arnd Bergmann, linux-s390, netdev, linux-kernel
On 11/16/2017 12:22 PM, Geert Uytterhoeven wrote:
> 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>
> ---
> I don't know if this can ever happen, but the old code handled it.
The for-loop is at least executed once; thus there is no real problem.
Nevertheless the warning is ugly, and the current initialization with NULL
meaningless after the smc_buf cleanup. Therefore I add your patch to my list of
coming smc patches. Thanks!
> ---
> net/smc/smc_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index 2578fbd95664af84..453c54467082d93f 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c
> @@ -562,7 +562,7 @@ static int __smc_buf_create(struct smc_sock *smc, bool is_rmb)
> {
> 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;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-16 18:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16 11:22 [PATCH] net/smc: Fix preinitialization of buf_desc in __smc_buf_create() Geert Uytterhoeven
2017-11-16 11:35 ` Arnd Bergmann
2017-11-16 18:14 ` Ursula Braun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.