[SCSI] ibmvscsi: fix leak when failing to send srp event

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by FUJITA Tomonori and committed by James Bottomley e5dbfa66 2ea00202

+18 -12
+18 -12
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 739 { 740 struct viosrp_adapter_info *req; 741 struct srp_event_struct *evt_struct; 742 - 743 evt_struct = get_event_struct(&hostdata->pool); 744 if (!evt_struct) { 745 printk(KERN_ERR "ibmvscsi: couldn't allocate an event " ··· 758 759 req->common.type = VIOSRP_ADAPTER_INFO_TYPE; 760 req->common.length = sizeof(hostdata->madapter_info); 761 - req->buffer = dma_map_single(hostdata->dev, 762 - &hostdata->madapter_info, 763 - sizeof(hostdata->madapter_info), 764 - DMA_BIDIRECTIONAL); 765 766 if (dma_mapping_error(req->buffer)) { 767 printk(KERN_ERR ··· 771 return; 772 } 773 774 - if (ibmvscsi_send_srp_event(evt_struct, hostdata)) 775 printk(KERN_ERR "ibmvscsi: couldn't send ADAPTER_INFO_REQ!\n"); 776 }; 777 778 /** ··· 1265 { 1266 struct viosrp_host_config *host_config; 1267 struct srp_event_struct *evt_struct; 1268 int rc; 1269 1270 evt_struct = get_event_struct(&hostdata->pool); ··· 1286 memset(host_config, 0x00, sizeof(*host_config)); 1287 host_config->common.type = VIOSRP_HOST_CONFIG_TYPE; 1288 host_config->common.length = length; 1289 - host_config->buffer = dma_map_single(hostdata->dev, buffer, length, 1290 - DMA_BIDIRECTIONAL); 1291 1292 if (dma_mapping_error(host_config->buffer)) { 1293 printk(KERN_ERR ··· 1299 1300 init_completion(&evt_struct->comp); 1301 rc = ibmvscsi_send_srp_event(evt_struct, hostdata); 1302 - if (rc == 0) { 1303 wait_for_completion(&evt_struct->comp); 1304 - dma_unmap_single(hostdata->dev, host_config->buffer, 1305 - length, DMA_BIDIRECTIONAL); 1306 - } 1307 1308 return rc; 1309 }
··· 739 { 740 struct viosrp_adapter_info *req; 741 struct srp_event_struct *evt_struct; 742 + dma_addr_t addr; 743 + 744 evt_struct = get_event_struct(&hostdata->pool); 745 if (!evt_struct) { 746 printk(KERN_ERR "ibmvscsi: couldn't allocate an event " ··· 757 758 req->common.type = VIOSRP_ADAPTER_INFO_TYPE; 759 req->common.length = sizeof(hostdata->madapter_info); 760 + req->buffer = addr = dma_map_single(hostdata->dev, 761 + &hostdata->madapter_info, 762 + sizeof(hostdata->madapter_info), 763 + DMA_BIDIRECTIONAL); 764 765 if (dma_mapping_error(req->buffer)) { 766 printk(KERN_ERR ··· 770 return; 771 } 772 773 + if (ibmvscsi_send_srp_event(evt_struct, hostdata)) { 774 printk(KERN_ERR "ibmvscsi: couldn't send ADAPTER_INFO_REQ!\n"); 775 + dma_unmap_single(hostdata->dev, 776 + addr, 777 + sizeof(hostdata->madapter_info), 778 + DMA_BIDIRECTIONAL); 779 + } 780 }; 781 782 /** ··· 1259 { 1260 struct viosrp_host_config *host_config; 1261 struct srp_event_struct *evt_struct; 1262 + dma_addr_t addr; 1263 int rc; 1264 1265 evt_struct = get_event_struct(&hostdata->pool); ··· 1279 memset(host_config, 0x00, sizeof(*host_config)); 1280 host_config->common.type = VIOSRP_HOST_CONFIG_TYPE; 1281 host_config->common.length = length; 1282 + host_config->buffer = addr = dma_map_single(hostdata->dev, buffer, 1283 + length, 1284 + DMA_BIDIRECTIONAL); 1285 1286 if (dma_mapping_error(host_config->buffer)) { 1287 printk(KERN_ERR ··· 1291 1292 init_completion(&evt_struct->comp); 1293 rc = ibmvscsi_send_srp_event(evt_struct, hostdata); 1294 + if (rc == 0) 1295 wait_for_completion(&evt_struct->comp); 1296 + dma_unmap_single(hostdata->dev, addr, length, DMA_BIDIRECTIONAL); 1297 1298 return rc; 1299 }