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