public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipmi: code cleanup and prevent potential issue.
@ 2020-06-09  6:04 wu000273
  2020-06-09 12:18 ` Corey Minyard
  0 siblings, 1 reply; 2+ messages in thread
From: wu000273 @ 2020-06-09  6:04 UTC (permalink / raw)
  To: kjlu
  Cc: wu000273, Corey Minyard, Arnd Bergmann, Greg Kroah-Hartman,
	openipmi-developer, linux-kernel

From: Qiushi Wu <wu000273@umn.edu>

All the previous get/put operations against intf->refcount are
inside the mutex. Thus, put the last kref_put() also inside mutex
to make sure get/put functions execute in order and prevent the
potential race condition.

Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 drivers/char/ipmi/ipmi_msghandler.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index e1b22fe0916c..d34343e34272 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2583,10 +2583,11 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
 			*guid =  bmc->guid;
 	}
 
+	kref_put(&intf->refcount, intf_free);
+
 	mutex_unlock(&bmc->dyn_mutex);
 	mutex_unlock(&intf->bmc_reg_mutex);
 
-	kref_put(&intf->refcount, intf_free);
 	return rv;
 }
 
-- 
2.17.1


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

end of thread, other threads:[~2020-06-09 12:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-09  6:04 [PATCH] ipmi: code cleanup and prevent potential issue wu000273
2020-06-09 12:18 ` Corey Minyard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox