* [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol()
@ 2019-11-07 7:48 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2019-11-07 7:48 UTC (permalink / raw)
To: Philipp Reisner
Cc: Lars Ellenberg, Jens Axboe, drbd-dev, linux-block, linux-kernel,
kernel-janitors
There are two callers of this function and they both unlock the mutex so
this ends up being a double unlock.
Fixes: 44ed167da748 ("drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static analisys. Not tested. There is a comment about the lock next to
the caller in drbd_nl.c that I didn't understand:
drivers/block/drbd/drbd_nl.c
2509 crypto_free_shash(connection->integrity_tfm);
2510 connection->integrity_tfm = crypto.integrity_tfm;
2511 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100)
2512 /* Do this without trying to take connection->data.mutex again. */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What does this mean? We're already holding that lock. We took it near
the start of the function.
2513 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE);
2514
2515 crypto_free_shash(connection->cram_hmac_tfm);
2516 connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
2517
2518 mutex_unlock(&connection->resource->conf_update);
2519 mutex_unlock(&connection->data.mutex);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unlocked here.
drivers/block/drbd/drbd_main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 5b248763a672..a18155cdce41 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -786,7 +786,6 @@ int __drbd_send_protocol(struct drbd_connection *connection, enum drbd_packet cm
if (nc->tentative && connection->agreed_pro_version < 92) {
rcu_read_unlock();
- mutex_unlock(&sock->mutex);
drbd_err(connection, "--dry-run is not supported by peer");
return -EOPNOTSUPP;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() @ 2019-11-07 7:48 ` Dan Carpenter 0 siblings, 0 replies; 12+ messages in thread From: Dan Carpenter @ 2019-11-07 7:48 UTC (permalink / raw) To: Philipp Reisner Cc: Lars Ellenberg, Jens Axboe, drbd-dev, linux-block, linux-kernel, kernel-janitors There are two callers of this function and they both unlock the mutex so this ends up being a double unlock. Fixes: 44ed167da748 ("drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- Static analisys. Not tested. There is a comment about the lock next to the caller in drbd_nl.c that I didn't understand: drivers/block/drbd/drbd_nl.c 2509 crypto_free_shash(connection->integrity_tfm); 2510 connection->integrity_tfm = crypto.integrity_tfm; 2511 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100) 2512 /* Do this without trying to take connection->data.mutex again. */ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What does this mean? We're already holding that lock. We took it near the start of the function. 2513 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); 2514 2515 crypto_free_shash(connection->cram_hmac_tfm); 2516 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; 2517 2518 mutex_unlock(&connection->resource->conf_update); 2519 mutex_unlock(&connection->data.mutex); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unlocked here. drivers/block/drbd/drbd_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 5b248763a672..a18155cdce41 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -786,7 +786,6 @@ int __drbd_send_protocol(struct drbd_connection *connection, enum drbd_packet cm if (nc->tentative && connection->agreed_pro_version < 92) { rcu_read_unlock(); - mutex_unlock(&sock->mutex); drbd_err(connection, "--dry-run is not supported by peer"); return -EOPNOTSUPP; } -- 2.20.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() 2019-11-07 7:48 ` Dan Carpenter (?) @ 2019-11-08 10:46 ` Philipp Reisner -1 siblings, 0 replies; 12+ messages in thread From: Philipp Reisner @ 2019-11-08 10:46 UTC (permalink / raw) To: Dan Carpenter, Jens Axboe Cc: Lars Ellenberg, drbd-dev, linux-block, linux-kernel, kernel-janitors Hi Dan, yes, your patch it obviously correct. The comment you are referring to is badly worded. We will remove it. Jens, are you taking this patch as it is? best regards, Phil Am Donnerstag, 7. November 2019, 08:48:47 CET schrieb Dan Carpenter: > There are two callers of this function and they both unlock the mutex so > this ends up being a double unlock. > > Fixes: 44ed167da748 ("drbd: rcu_read_lock() and rcu_dereference() for > tconn->net_conf") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > Static analisys. Not tested. There is a comment about the lock next to > the caller in drbd_nl.c that I didn't understand: > > drivers/block/drbd/drbd_nl.c > 2509 crypto_free_shash(connection->integrity_tfm); > 2510 connection->integrity_tfm = crypto.integrity_tfm; > 2511 if (connection->cstate >= C_WF_REPORT_PARAMS && > connection->agreed_pro_version >= 100) 2512 /* Do this > without trying to take connection->data.mutex again. */ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What does this > mean? We're already holding that lock. We took it near the start of the > function. > > 2513 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); > 2514 > 2515 crypto_free_shash(connection->cram_hmac_tfm); > 2516 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; > 2517 > 2518 mutex_unlock(&connection->resource->conf_update); > 2519 mutex_unlock(&connection->data.mutex); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Unlocked here. > > drivers/block/drbd/drbd_main.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c > index 5b248763a672..a18155cdce41 100644 > --- a/drivers/block/drbd/drbd_main.c > +++ b/drivers/block/drbd/drbd_main.c > @@ -786,7 +786,6 @@ int __drbd_send_protocol(struct drbd_connection > *connection, enum drbd_packet cm > > if (nc->tentative && connection->agreed_pro_version < 92) { > rcu_read_unlock(); > - mutex_unlock(&sock->mutex); > drbd_err(connection, "--dry-run is not supported by peer"); > return -EOPNOTSUPP; > } -- LINBIT | Keeping The Digital World Running DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Drbd-dev] [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() @ 2019-11-08 10:46 ` Philipp Reisner 0 siblings, 0 replies; 12+ messages in thread From: Philipp Reisner @ 2019-11-08 10:46 UTC (permalink / raw) To: Dan Carpenter, Jens Axboe Cc: linux-block, Lars Ellenberg, kernel-janitors, linux-kernel, drbd-dev Hi Dan, yes, your patch it obviously correct. The comment you are referring to is badly worded. We will remove it. Jens, are you taking this patch as it is? best regards, Phil Am Donnerstag, 7. November 2019, 08:48:47 CET schrieb Dan Carpenter: > There are two callers of this function and they both unlock the mutex so > this ends up being a double unlock. > > Fixes: 44ed167da748 ("drbd: rcu_read_lock() and rcu_dereference() for > tconn->net_conf") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > Static analisys. Not tested. There is a comment about the lock next to > the caller in drbd_nl.c that I didn't understand: > > drivers/block/drbd/drbd_nl.c > 2509 crypto_free_shash(connection->integrity_tfm); > 2510 connection->integrity_tfm = crypto.integrity_tfm; > 2511 if (connection->cstate >= C_WF_REPORT_PARAMS && > connection->agreed_pro_version >= 100) 2512 /* Do this > without trying to take connection->data.mutex again. */ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What does this > mean? We're already holding that lock. We took it near the start of the > function. > > 2513 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); > 2514 > 2515 crypto_free_shash(connection->cram_hmac_tfm); > 2516 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; > 2517 > 2518 mutex_unlock(&connection->resource->conf_update); > 2519 mutex_unlock(&connection->data.mutex); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Unlocked here. > > drivers/block/drbd/drbd_main.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c > index 5b248763a672..a18155cdce41 100644 > --- a/drivers/block/drbd/drbd_main.c > +++ b/drivers/block/drbd/drbd_main.c > @@ -786,7 +786,6 @@ int __drbd_send_protocol(struct drbd_connection > *connection, enum drbd_packet cm > > if (nc->tentative && connection->agreed_pro_version < 92) { > rcu_read_unlock(); > - mutex_unlock(&sock->mutex); > drbd_err(connection, "--dry-run is not supported by peer"); > return -EOPNOTSUPP; > } -- LINBIT | Keeping The Digital World Running DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() @ 2019-11-08 10:46 ` Philipp Reisner 0 siblings, 0 replies; 12+ messages in thread From: Philipp Reisner @ 2019-11-08 10:46 UTC (permalink / raw) To: Dan Carpenter, Jens Axboe Cc: Lars Ellenberg, drbd-dev, linux-block, linux-kernel, kernel-janitors Hi Dan, yes, your patch it obviously correct. The comment you are referring to is badly worded. We will remove it. Jens, are you taking this patch as it is? best regards, Phil Am Donnerstag, 7. November 2019, 08:48:47 CET schrieb Dan Carpenter: > There are two callers of this function and they both unlock the mutex so > this ends up being a double unlock. > > Fixes: 44ed167da748 ("drbd: rcu_read_lock() and rcu_dereference() for > tconn->net_conf") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > Static analisys. Not tested. There is a comment about the lock next to > the caller in drbd_nl.c that I didn't understand: > > drivers/block/drbd/drbd_nl.c > 2509 crypto_free_shash(connection->integrity_tfm); > 2510 connection->integrity_tfm = crypto.integrity_tfm; > 2511 if (connection->cstate >= C_WF_REPORT_PARAMS && > connection->agreed_pro_version >= 100) 2512 /* Do this > without trying to take connection->data.mutex again. */ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What does this > mean? We're already holding that lock. We took it near the start of the > function. > > 2513 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); > 2514 > 2515 crypto_free_shash(connection->cram_hmac_tfm); > 2516 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; > 2517 > 2518 mutex_unlock(&connection->resource->conf_update); > 2519 mutex_unlock(&connection->data.mutex); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Unlocked here. > > drivers/block/drbd/drbd_main.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c > index 5b248763a672..a18155cdce41 100644 > --- a/drivers/block/drbd/drbd_main.c > +++ b/drivers/block/drbd/drbd_main.c > @@ -786,7 +786,6 @@ int __drbd_send_protocol(struct drbd_connection > *connection, enum drbd_packet cm > > if (nc->tentative && connection->agreed_pro_version < 92) { > rcu_read_unlock(); > - mutex_unlock(&sock->mutex); > drbd_err(connection, "--dry-run is not supported by peer"); > return -EOPNOTSUPP; > } -- LINBIT | Keeping The Digital World Running DRBD® and LINBIT® are registered trademarks of LINBIT, Austria. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() 2019-11-08 10:46 ` Philipp Reisner (?) @ 2019-11-08 13:54 ` Jens Axboe -1 siblings, 0 replies; 12+ messages in thread From: Jens Axboe @ 2019-11-08 13:54 UTC (permalink / raw) To: Philipp Reisner, Dan Carpenter Cc: Lars Ellenberg, drbd-dev, linux-block, linux-kernel, kernel-janitors On 11/8/19 3:46 AM, Philipp Reisner wrote: > Hi Dan, > > yes, your patch it obviously correct. The comment you are > referring to is badly worded. We will remove it. > > Jens, > > are you taking this patch as it is? Yep, I'll queue it up. -- Jens Axboe ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Drbd-dev] [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() @ 2019-11-08 13:54 ` Jens Axboe 0 siblings, 0 replies; 12+ messages in thread From: Jens Axboe @ 2019-11-08 13:54 UTC (permalink / raw) To: Philipp Reisner, Dan Carpenter Cc: linux-block, Lars Ellenberg, kernel-janitors, linux-kernel, drbd-dev On 11/8/19 3:46 AM, Philipp Reisner wrote: > Hi Dan, > > yes, your patch it obviously correct. The comment you are > referring to is badly worded. We will remove it. > > Jens, > > are you taking this patch as it is? Yep, I'll queue it up. -- Jens Axboe ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() @ 2019-11-08 13:54 ` Jens Axboe 0 siblings, 0 replies; 12+ messages in thread From: Jens Axboe @ 2019-11-08 13:54 UTC (permalink / raw) To: Philipp Reisner, Dan Carpenter Cc: Lars Ellenberg, drbd-dev, linux-block, linux-kernel, kernel-janitors On 11/8/19 3:46 AM, Philipp Reisner wrote: > Hi Dan, > > yes, your patch it obviously correct. The comment you are > referring to is badly worded. We will remove it. > > Jens, > > are you taking this patch as it is? Yep, I'll queue it up. -- Jens Axboe ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() 2019-11-07 7:48 ` Dan Carpenter @ 2019-11-08 16:26 ` Bart Van Assche -1 siblings, 0 replies; 12+ messages in thread From: Bart Van Assche @ 2019-11-08 16:26 UTC (permalink / raw) To: Dan Carpenter, Philipp Reisner Cc: Lars Ellenberg, Jens Axboe, drbd-dev, linux-block, linux-kernel, kernel-janitors On 11/6/19 11:48 PM, Dan Carpenter wrote: > There are two callers of this function and they both unlock the mutex so > this ends up being a double unlock. Is there a typo in the patch subject (stay -> stray)? Thanks, Bart. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() @ 2019-11-08 16:26 ` Bart Van Assche 0 siblings, 0 replies; 12+ messages in thread From: Bart Van Assche @ 2019-11-08 16:26 UTC (permalink / raw) To: Dan Carpenter, Philipp Reisner Cc: Lars Ellenberg, Jens Axboe, drbd-dev, linux-block, linux-kernel, kernel-janitors On 11/6/19 11:48 PM, Dan Carpenter wrote: > There are two callers of this function and they both unlock the mutex so > this ends up being a double unlock. Is there a typo in the patch subject (stay -> stray)? Thanks, Bart. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() 2019-11-08 16:26 ` Bart Van Assche @ 2019-11-08 16:27 ` Jens Axboe -1 siblings, 0 replies; 12+ messages in thread From: Jens Axboe @ 2019-11-08 16:27 UTC (permalink / raw) To: Bart Van Assche, Dan Carpenter, Philipp Reisner Cc: Lars Ellenberg, drbd-dev, linux-block, linux-kernel, kernel-janitors On 11/8/19 9:26 AM, Bart Van Assche wrote: > On 11/6/19 11:48 PM, Dan Carpenter wrote: >> There are two callers of this function and they both unlock the mutex so >> this ends up being a double unlock. > > Is there a typo in the patch subject (stay -> stray)? I fixed that up while applying, fwiw. -- Jens Axboe ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() @ 2019-11-08 16:27 ` Jens Axboe 0 siblings, 0 replies; 12+ messages in thread From: Jens Axboe @ 2019-11-08 16:27 UTC (permalink / raw) To: Bart Van Assche, Dan Carpenter, Philipp Reisner Cc: Lars Ellenberg, drbd-dev, linux-block, linux-kernel, kernel-janitors On 11/8/19 9:26 AM, Bart Van Assche wrote: > On 11/6/19 11:48 PM, Dan Carpenter wrote: >> There are two callers of this function and they both unlock the mutex so >> this ends up being a double unlock. > > Is there a typo in the patch subject (stay -> stray)? I fixed that up while applying, fwiw. -- Jens Axboe ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-11-08 16:27 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-11-07 7:48 [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() Dan Carpenter 2019-11-07 7:48 ` Dan Carpenter 2019-11-08 10:46 ` Philipp Reisner 2019-11-08 10:46 ` [Drbd-dev] " Philipp Reisner 2019-11-08 10:46 ` Philipp Reisner 2019-11-08 13:54 ` Jens Axboe 2019-11-08 13:54 ` [Drbd-dev] " Jens Axboe 2019-11-08 13:54 ` Jens Axboe 2019-11-08 16:26 ` Bart Van Assche 2019-11-08 16:26 ` Bart Van Assche 2019-11-08 16:27 ` Jens Axboe 2019-11-08 16:27 ` Jens Axboe
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.