public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/xen/evtchn.c: Check failure for evtchn_make_refcounted()
@ 2014-08-28 15:13 Chen Gang
  2014-08-28 15:49 ` David Vrabel
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Gang @ 2014-08-28 15:13 UTC (permalink / raw)
  To: David Vrabel, konrad.wilk, boris.ostrovsky
  Cc: xen-devel, linux-kernel@vger.kernel.org

evtchn_make_refcounted() may return failure, so need process the failure
case. In failure case, it need call unbind_from_irqhandler() just like
evtchn_unbind_from_user() has done.

irq_from_evtchn() must be OK when bind_evtchn_to_irqhandler() succeed,
so need not check it again.

Also still need remain the closing port code, because when the failure
occurs, unbind_from_irqhandler() will not close port internally.


Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 drivers/xen/evtchn.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index 00f40f0..8a629d6 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -311,6 +311,11 @@ static int evtchn_bind_to_user(struct per_user_data *u, int port)
 		goto err;
 
 	rc = evtchn_make_refcounted(port);
+	if (rc < 0) {
+		unbind_from_irqhandler(irq_from_evtchn(port), evtchn);
+		goto err;
+	}
+
 	return rc;
 
 err:
-- 
1.7.11.7

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

end of thread, other threads:[~2014-08-30  3:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-28 15:13 [PATCH] drivers/xen/evtchn.c: Check failure for evtchn_make_refcounted() Chen Gang
2014-08-28 15:49 ` David Vrabel
2014-08-29 13:34   ` Chen Gang
2014-08-29 13:43     ` David Vrabel
2014-08-30  3:39       ` Chen Gang

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