scsi: megaraid_sas: zero out IOC INIT and stream detection memory
authorShivasharan S <shivasharan.srikanteshwara@broadcom.com>
Fri, 5 Jan 2018 13:27:36 +0000 (05:27 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 11 Jan 2018 04:25:13 +0000 (23:25 -0500)
Memory allocated for IOC_INIT command and stream detection array are not
zero'd before using. Use kzalloc instead of kmalloc to zero out the
memory allocated.

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c

index cc54bdb5c712a9adccacdcc9152087ad8220f8b3..ed106cbd4440e85b31ca100112beeeabe0eb8f9d 100644 (file)
@@ -5387,7 +5387,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
                }
                for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) {
                        fusion->stream_detect_by_ld[i] =
-                               kmalloc(sizeof(struct LD_STREAM_DETECT),
+                               kzalloc(sizeof(struct LD_STREAM_DETECT),
                                GFP_KERNEL);
                        if (!fusion->stream_detect_by_ld[i]) {
                                dev_err(&instance->pdev->dev,
index 65dc4fea6352a3d6b12ed5add5aafe7c85d866e4..0d6d4dedad62aba92d63ff1c82d499446b53dc70 100644 (file)
@@ -1603,7 +1603,7 @@ static int megasas_alloc_ioc_init_frame(struct megasas_instance *instance)
 
        fusion = instance->ctrl_context;
 
-       cmd = kmalloc(sizeof(struct megasas_cmd), GFP_KERNEL);
+       cmd = kzalloc(sizeof(struct megasas_cmd), GFP_KERNEL);
 
        if (!cmd) {
                dev_err(&instance->pdev->dev, "Failed from func: %s line: %d\n",