linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vmw_balloon: release lock on error in vmballoon_reset()
@ 2019-02-11 18:45 Dan Carpenter
  2019-02-11 19:12 ` Nadav Amit
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-02-11 18:45 UTC (permalink / raw)
  To: Julien Freche, Xavier Deguillard, Nadav Amit
  Cc: VMware, Inc.,
	Arnd Bergmann, Greg Kroah-Hartman, linux-kernel, kernel-janitors

We added some locking to this function but forgot to drop the lock on
these two error paths.  This bug would lead to an immediate deadlock.

Fixes: c7b3690fb152 ("vmw_balloon: stats rework")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/misc/vmw_balloon.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 6542a7711cac..ad807d5a3141 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -1330,7 +1330,7 @@ static void vmballoon_reset(struct vmballoon *b)
 	vmballoon_pop(b);
 
 	if (vmballoon_send_start(b, VMW_BALLOON_CAPABILITIES))
-		return;
+		goto unlock;
 
 	if ((b->capabilities & VMW_BALLOON_BATCHED_CMDS) != 0) {
 		if (vmballoon_init_batching(b)) {
@@ -1341,7 +1341,7 @@ static void vmballoon_reset(struct vmballoon *b)
 			 * The guest will retry in one second.
 			 */
 			vmballoon_send_start(b, 0);
-			return;
+			goto unlock;
 		}
 	} else if ((b->capabilities & VMW_BALLOON_BASIC_CMDS) != 0) {
 		vmballoon_deinit_batching(b);
@@ -1357,6 +1357,7 @@ static void vmballoon_reset(struct vmballoon *b)
 	if (vmballoon_send_guest_id(b))
 		pr_err("failed to send guest ID to the host\n");
 
+unlock:
 	up_write(&b->conf_sem);
 }
 
-- 
2.17.1


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

* Re: [PATCH] vmw_balloon: release lock on error in vmballoon_reset()
  2019-02-11 18:45 [PATCH] vmw_balloon: release lock on error in vmballoon_reset() Dan Carpenter
@ 2019-02-11 19:12 ` Nadav Amit
  0 siblings, 0 replies; 2+ messages in thread
From: Nadav Amit @ 2019-02-11 19:12 UTC (permalink / raw)
  To: Dan Carpenter, Greg Kroah-Hartman
  Cc: Julien Freche, Xavier Deguillard, Pv-drivers, Arnd Bergmann,
	LKML, kernel-janitors

> On Feb 11, 2019, at 10:45 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> We added some locking to this function but forgot to drop the lock on
> these two error paths.  This bug would lead to an immediate deadlock.
> 
> Fixes: c7b3690fb152 ("vmw_balloon: stats rework")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Cc: stable@vger.kernel.org
Reviewed-by: Nadav Amit <namit@vmware.com>

--

Yes, I screwed up. Thanks for catching it!

I’ll go to check why my error injection tests didn’t catch it.


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

end of thread, other threads:[~2019-02-11 19:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-11 18:45 [PATCH] vmw_balloon: release lock on error in vmballoon_reset() Dan Carpenter
2019-02-11 19:12 ` Nadav Amit

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).