lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1513711816-2618-59-git-send-email-dongwon.kim@intel.com>
Date:   Tue, 19 Dec 2017 11:30:15 -0800
From:   Dongwon Kim <dongwon.kim@...el.com>
To:     linux-kernel@...r.kernel.org
Cc:     dri-devel@...ts.freedesktop.org, xen-devel@...ts.xenproject.org,
        mateuszx.potrola@...el.com, dongwon.kim@...el.com,
        Kai Chen <kai.chen@...el.com>
Subject: [RFC PATCH 59/60] hyper_dmabuf: freeing hy_drv_priv when drv init fails (v2)

From: Kai Chen <kai.chen@...el.com>

Make sure hy_drv_priv is freed before exiting in several places
in hyper_dmabuf_drv_init.

v2: unlocking mutex before freeing hy_drv_priv when bknd_ops->init
fails

Signed-off-by: Kai Chen <kai.chen@...el.com>
Signed-off-by: Dongwon Kim <dongwon.kim@...el.com>
---
 drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c
index bbb3414..eead4c0 100644
--- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c
+++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c
@@ -271,8 +271,10 @@ static int __init hyper_dmabuf_drv_init(void)
 		return -ENOMEM;
 
 	ret = register_device();
-	if (ret < 0)
+	if (ret < 0) {
+		kfree(hy_drv_priv);
 		return ret;
+	}
 
 /* currently only supports XEN hypervisor */
 #ifdef CONFIG_HYPER_DMABUF_XEN
@@ -284,6 +286,7 @@ static int __init hyper_dmabuf_drv_init(void)
 
 	if (hy_drv_priv->bknd_ops == NULL) {
 		printk(KERN_ERR "Hyper_dmabuf: no backend found\n");
+		kfree(hy_drv_priv);
 		return -1;
 	}
 
@@ -336,6 +339,8 @@ static int __init hyper_dmabuf_drv_init(void)
 		if (ret < 0) {
 			dev_dbg(hy_drv_priv->dev,
 				"failed to initialize backend.\n");
+			mutex_unlock(&hy_drv_priv->lock);
+			kfree(hy_drv_priv);
 			return ret;
 		}
 	}
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ