Skip to contentSkip to conversation

fmc: add error handling for kmemdup

PATCH New Zhouyang Jia 1 participant 1 message Jun 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fmc: add error handling for kmemdup

When kmemdup fails, the lack of error-handling code may cause unexpected results.

This patch adds error-handling code after calling kmemdup.

---
 drivers/fmc/fmc-fakedev.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/fmc/fmc-fakedev.c +3 -0
index 941d093..62d9046 100644
@@ -282,6 +282,9 @@ 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)
+			return ERR_PTR(-ENOMEM);
+
 		fmc->hwdev = &ff->dev;
 		fmc->carrier_data = ff;
 		fmc->nr_slots = ff_nr_dev;
Signature · 1 line
2.7.4