From: Laszlo Ersek Subject: [PATCH] xen-blkfront: plug device number leak in xlblk_init() error path Date: Fri, 7 Oct 2011 21:34:38 +0200 Message-ID: <1318016078-7110-1-git-send-email-lersek@redhat.com> Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com, lersek@redhat.com List-Id: xen-devel@lists.xenproject.org ... though after a failed xenbus_register_frontend() all may be lost. Signed-off-by: Laszlo Ersek --- drivers/block/xen-blkfront.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 9ea8c25..a5a9b1b 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1385,6 +1385,8 @@ static struct xenbus_driver blkfront = { static int __init xlblk_init(void) { + int ret; + if (!xen_domain()) return -ENODEV; @@ -1394,7 +1396,13 @@ static int __init xlblk_init(void) return -ENODEV; } - return xenbus_register_frontend(&blkfront); + ret = xenbus_register_frontend(&blkfront); + if (ret) { + unregister_blkdev(XENVBD_MAJOR, DEV_NAME); + return ret; + } + + return 0; } module_init(xlblk_init); -- 1.7.4.4