From: Kumar Amit Mehta Date: Mon, 26 Jan 2015 15:44:53 +0000 (+0100) Subject: staging: lustre: lustre: mdc: lproc_mdc.c: Fix for potential NULL pointer dereference X-Git-Tag: firefly_0821_release~176^2~2320^2~137 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c1f79c74e222000386f3950ed98d150e6009648b;p=firefly-linux-kernel-4.4.55.git 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. Signed-off-by: Kumar Amit Mehta Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index c420219c0a14..c791941bd810 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -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;