Skip to contentSkip to conversation

staging: lustre: lustre: mdc: lproc_mdc.c: Fix for potential NULL pointer dereference

PATCH New Kumar Amit Mehta 1 participant 1 message Jan 26, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: lustre: mdc: lproc_mdc.c: Fix for potential NULL pointer dereference

In mdc_kuc_write(), OBD_ALLOC(lh, len) may leave 'lh' to NULL as kmalloc may fail to allocate memory. This fix adds a check to avoid, dereferencing a NULL pointer.

---
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/lustre/lustre/mdc/lproc_mdc.c +2 -0
index c420219..c791941 100644
@@ -106,6 +106,8 @@ static ssize_t mdc_kuc_write(struct file *file,
 		/* for mockup below */ 2 * cfs_size_round(sizeof(*hai));
 
 	OBD_ALLOC(lh, len);
+	if (!lh)
+		return -ENOMEM;
 
 	lh->kuc_magic = KUC_MAGIC;
 	lh->kuc_transport = KUC_TRANSPORT_HSM;
Signature · 1 line
2.1.0