Skip to contentSkip to conversation

net/smc: fixes for smc buffer handling

PATCH In review Ursula Braun 2 participants 4 messages Nov 21, 2017 – Nov 23, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net/smc: fixes for smc buffer handling

Dave,

here are 2 cleanup patches for smc buffer handling.

Thanks, Ursula

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

Ursula Braun (1):
net/smc: use sk_rcvbuf as start for rmb creation

 net/smc/smc_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.13.5
#1 lore raw

PATCH 1/2 net/smc: use sk_rcvbuf as start for rmb creation

From: Ursula Braun <[email protected]>

Commit 3e034725c0d8 ("net/smc: common functions for RMBs and send buffers") merged handling of SMC receive and send buffers. It introduced sk_buf_size as merged start value for size determination. But since sk_buf_size is not used at all, sk_sndbuf is erroneously used as start for rmb creation. This patch makes sure, sk_buf_size is really used as intended, and sk_rcvbuf is used as start value for rmb creation.

Fixes 3e034725c0d8 ("net/smc: common functions for RMBs and send buffers")
---
 net/smc/smc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_core.c +1 -1
index 2578fbd95664..3b5e5d4bc763 100644
@@ -575,7 +575,7 @@ static int __smc_buf_create(struct smc_sock *smc, bool is_rmb)
 		/* use socket send buffer size (w/o overhead) as start value */
 		sk_buf_size = smc->sk.sk_sndbuf / 2;
 
-	for (bufsize_short = smc_compress_bufsize(smc->sk.sk_sndbuf / 2);
+	for (bufsize_short = smc_compress_bufsize(sk_buf_size);
 	     bufsize_short >= 0; bufsize_short--) {
 
 		if (is_rmb) {
Signature · 1 line
2.13.5
#2 lore raw

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

In reply to Ursula Braun

From: Geert Uytterhoeven <[email protected]>

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()")
---
 net/smc/smc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_core.c +1 -1
index 3b5e5d4bc763..94f21116dac5 100644
@@ -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;
Signature · 1 line
2.13.5