From: Santosh Nayak <santoshprasadnayak@xxxxxxxxx>
Add error handling after kzalloc() call to avoid null dereference.
Signed-off-by: Santosh Nayak <santoshprasadnayak@xxxxxxxxx>
---
drivers/scsi/megaraid.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 4d39a9f..41e7b42 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -4438,6 +4438,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
memset(scb, 0, sizeof(scb_t));
sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
+ if (unlikely(!sdev)) {
+ printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
+ return -ENOMEM;
+ }
scmd->device = sdev;
memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
--
1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[SCSI Target Devel]
[Linux SCSI Target Infrastructure]
[Kernel Newbies]
[Share Photos]
[IDE]
[Security]
[Git]
[Netfilter]
[Bugtraq]
[Photos]
[Yosemite]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Linux ATA RAID]
[Linux IIO]
[Samba]
[Video 4 Linux]
[Device Mapper]
[Linux Resources]