Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pm8001: fix a memory leak in nvmd_resp

Instead of copying information to fw_control_context free it.

The task is forgotten thus also the reference to fw_control_context
and the completion thread takes the info from virt_ptr again.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Acked-by: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

Tomas Henzl and committed by
Christoph Hellwig
f3a0655f 31d05e5b

+2 -6
+2 -6
drivers/scsi/pm8001/pm8001_hwi.c
··· 3132 3132 void 3133 3133 pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) 3134 3134 { 3135 - struct fw_control_ex *fw_control_context; 3136 3135 struct get_nvm_data_resp *pPayload = 3137 3136 (struct get_nvm_data_resp *)(piomb + 4); 3138 3137 u32 tag = le32_to_cpu(pPayload->tag); ··· 3140 3141 u32 ir_tds_bn_dps_das_nvm = 3141 3142 le32_to_cpu(pPayload->ir_tda_bn_dps_das_nvm); 3142 3143 void *virt_addr = pm8001_ha->memoryMap.region[NVMD].virt_ptr; 3143 - fw_control_context = ccb->fw_control_context; 3144 3144 3145 3145 PM8001_MSG_DBG(pm8001_ha, pm8001_printk("Get nvm data complete!\n")); 3146 3146 if ((dlen_status & NVMD_STAT) != 0) { ··· 3180 3182 pm8001_printk("Get NVMD success, IR=0, dataLen=%d\n", 3181 3183 (dlen_status & NVMD_LEN) >> 24)); 3182 3184 } 3183 - memcpy(fw_control_context->usrAddr, 3184 - pm8001_ha->memoryMap.region[NVMD].virt_ptr, 3185 - fw_control_context->len); 3186 - complete(pm8001_ha->nvmd_completion); 3185 + kfree(ccb->fw_control_context); 3187 3186 ccb->task = NULL; 3188 3187 ccb->ccb_tag = 0xFFFFFFFF; 3189 3188 pm8001_tag_free(pm8001_ha, tag); 3189 + complete(pm8001_ha->nvmd_completion); 3190 3190 } 3191 3191 3192 3192 int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb)