summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurizio Lombardi <mlombard@redhat.com>2014-06-17 07:15:40 -0400
committerChristoph Hellwig <hch@lst.de>2014-06-25 07:29:05 -0400
commitf2c6f180c98e1a8bc84781f32894b595363d3dfb (patch)
treec8f61123f9ebfcae8e30a0b355d201af41ae99c1
parent3a980508c3fab88527998c258ddb3c12ff36fedc (diff)
pm8001: Fix potential null pointer dereference and memory leak.
The pm8001_get_phy_settings_info() function does not check the kzalloc() return value and does not free the allocated memory. Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> Acked-by: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com> Acked-by: Jack Wang <xjtuwjp@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/pm8001/pm8001_init.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index c4f31b21feb8..e90c89f1d480 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -677,7 +677,7 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
677 * pm8001_get_phy_settings_info : Read phy setting values. 677 * pm8001_get_phy_settings_info : Read phy setting values.
678 * @pm8001_ha : our hba. 678 * @pm8001_ha : our hba.
679 */ 679 */
680void pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha) 680static int pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)
681{ 681{
682 682
683#ifdef PM8001_READ_VPD 683#ifdef PM8001_READ_VPD
@@ -691,11 +691,15 @@ void pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)
691 payload.offset = 0; 691 payload.offset = 0;
692 payload.length = 4096; 692 payload.length = 4096;
693 payload.func_specific = kzalloc(4096, GFP_KERNEL); 693 payload.func_specific = kzalloc(4096, GFP_KERNEL);
694 if (!payload.func_specific)
695 return -ENOMEM;
694 /* Read phy setting values from flash */ 696 /* Read phy setting values from flash */
695 PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload); 697 PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
696 wait_for_completion(&completion); 698 wait_for_completion(&completion);
697 pm8001_set_phy_profile(pm8001_ha, sizeof(u8), payload.func_specific); 699 pm8001_set_phy_profile(pm8001_ha, sizeof(u8), payload.func_specific);
700 kfree(payload.func_specific);
698#endif 701#endif
702 return 0;
699} 703}
700 704
701#ifdef PM8001_USE_MSIX 705#ifdef PM8001_USE_MSIX
@@ -879,8 +883,11 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
879 pm8001_init_sas_add(pm8001_ha); 883 pm8001_init_sas_add(pm8001_ha);
880 /* phy setting support for motherboard controller */ 884 /* phy setting support for motherboard controller */
881 if (pdev->subsystem_vendor != PCI_VENDOR_ID_ADAPTEC2 && 885 if (pdev->subsystem_vendor != PCI_VENDOR_ID_ADAPTEC2 &&
882 pdev->subsystem_vendor != 0) 886 pdev->subsystem_vendor != 0) {
883 pm8001_get_phy_settings_info(pm8001_ha); 887 rc = pm8001_get_phy_settings_info(pm8001_ha);
888 if (rc)
889 goto err_out_shost;
890 }
884 pm8001_post_sas_ha_init(shost, chip); 891 pm8001_post_sas_ha_init(shost, chip);
885 rc = sas_register_ha(SHOST_TO_SAS_HA(shost)); 892 rc = sas_register_ha(SHOST_TO_SAS_HA(shost));
886 if (rc) 893 if (rc)