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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190319192859.15290-1-pakki001@umn.edu>
Date:   Tue, 19 Mar 2019 14:28:59 -0500
From:   Aditya Pakki <pakki001@....edu>
To:     pakki001@....edu
Cc:     kjlu@....edu, Alessandro Rubini <rubini@...dd.com>,
        linux-kernel@...r.kernel.org
Subject: [PATCH] fmc: fix to avoid NULL pointer dereference

kmemdup can fail to allocate memory and result in a NULL pointer
dereference. The patches avoids such a scenario.

Signed-off-by: Aditya Pakki <pakki001@....edu>
---
 drivers/fmc/fmc-fakedev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/fmc/fmc-fakedev.c b/drivers/fmc/fmc-fakedev.c
index 941d0930969a..d634c901b4f3 100644
--- a/drivers/fmc/fmc-fakedev.c
+++ b/drivers/fmc/fmc-fakedev.c
@@ -282,6 +282,8 @@ static struct ff_dev *ff_dev_create(void)
 	for (i = 0; i < ff_nr_dev; i++) {
 		fmc = kmemdup(&ff_template_fmc, sizeof(ff_template_fmc),
 			      GFP_KERNEL);
+		if (!fmc)
+			goto rollback;
 		fmc->hwdev = &ff->dev;
 		fmc->carrier_data = ff;
 		fmc->nr_slots = ff_nr_dev;
@@ -294,6 +296,12 @@ static struct ff_dev *ff_dev_create(void)
 		ff_template_fmc.device_id++;
 	}
 	return ff;
+
+rollback:
+	for (i--; i >= 0; i--)
+		kfree(ff->fmc[i]);
+	kfree(ff);
+	return ERR_PTR(-ENOMEM);
 }
 
 /* init and exit */
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ