netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/1] net/smc: save link group ptr before calling smc_buf_unuse
@ 2018-10-23 13:48 Ursula Braun
  2018-10-23 18:00 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Ursula Braun @ 2018-10-23 13:48 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun

From: Karsten Graul <kgraul@linux.ibm.com>

The pointer to the link group is unset in the smc connection structure
right before the call to smc_buf_unuse. Save the pointer and provide it
to smc_buf_unuse.

Fixes: a6920d1d130c ("net/smc: handle unregistered buffers")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
 net/smc/smc_core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index e871368500e3..12d8493f72f4 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -291,7 +291,8 @@ static int smc_lgr_create(struct smc_sock *smc, bool is_smcd,
 	return rc;
 }
 
-static void smc_buf_unuse(struct smc_connection *conn)
+static void smc_buf_unuse(struct smc_connection *conn,
+			  struct smc_link_group *lgr)
 {
 	if (conn->sndbuf_desc)
 		conn->sndbuf_desc->used = 0;
@@ -301,8 +302,6 @@ static void smc_buf_unuse(struct smc_connection *conn)
 			conn->rmb_desc->used = 0;
 		} else {
 			/* buf registration failed, reuse not possible */
-			struct smc_link_group *lgr = conn->lgr;
-
 			write_lock_bh(&lgr->rmbs_lock);
 			list_del(&conn->rmb_desc->list);
 			write_unlock_bh(&lgr->rmbs_lock);
@@ -315,6 +314,8 @@ static void smc_buf_unuse(struct smc_connection *conn)
 /* remove a finished connection from its link group */
 void smc_conn_free(struct smc_connection *conn)
 {
+	struct smc_link_group *lgr;
+
 	if (!conn->lgr)
 		return;
 	if (conn->lgr->is_smcd) {
@@ -323,8 +324,9 @@ void smc_conn_free(struct smc_connection *conn)
 	} else {
 		smc_cdc_tx_dismiss_slots(conn);
 	}
+	lgr = conn->lgr; /* smc_lgr_unregister_conn() unsets lgr */
 	smc_lgr_unregister_conn(conn);
-	smc_buf_unuse(conn);
+	smc_buf_unuse(conn, lgr);
 }
 
 static void smc_link_clear(struct smc_link *lnk)
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net 1/1] net/smc: save link group ptr before calling smc_buf_unuse
  2018-10-23 13:48 [PATCH net 1/1] net/smc: save link group ptr before calling smc_buf_unuse Ursula Braun
@ 2018-10-23 18:00 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-10-23 18:00 UTC (permalink / raw)
  To: ubraun; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl

From: Ursula Braun <ubraun@linux.ibm.com>
Date: Tue, 23 Oct 2018 15:48:05 +0200

> @@ -315,6 +314,8 @@ static void smc_buf_unuse(struct smc_connection *conn)
>  /* remove a finished connection from its link group */
>  void smc_conn_free(struct smc_connection *conn)
>  {
> +	struct smc_link_group *lgr;
> +
>  	if (!conn->lgr)
>  		return;
>  	if (conn->lgr->is_smcd) {
> @@ -323,8 +324,9 @@ void smc_conn_free(struct smc_connection *conn)
>  	} else {
>  		smc_cdc_tx_dismiss_slots(conn);
>  	}
> +	lgr = conn->lgr; /* smc_lgr_unregister_conn() unsets lgr */
>  	smc_lgr_unregister_conn(conn);
> -	smc_buf_unuse(conn);
> +	smc_buf_unuse(conn, lgr);
>  }

This doesn't make any sense.

smc_lgr_unregister_conn() can free the memory and release the object,
albeit sometimes asynchronously via a workqueue.

It is not safe, therefore, to refrence the lgr object after that
function call.

I'm not applying this, sorry.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-24  2:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 13:48 [PATCH net 1/1] net/smc: save link group ptr before calling smc_buf_unuse Ursula Braun
2018-10-23 18:00 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).