Skip to content

Commit 00b39f6

Browse files
Stefan Haberlandaxboe
authored andcommitted
s390/dasd: fix memleak in path handling error case
If for whatever reason the dasd_eckd_check_characteristics() function exits after at least some paths have their configuration data allocated those data is never freed again. In the error case the device->private pointer is set to NULL and dasd_eckd_uncheck_device() will exit without freeing the path data because of this NULL pointer. Fix by calling dasd_eckd_clear_conf_data() for error cases. Also use dasd_eckd_clear_conf_data() in dasd_eckd_uncheck_device() to avoid code duplication. Reported-by: Qian Cai <[email protected]> Reviewed-by: Jan Hoeppner <[email protected]> Signed-off-by: Stefan Haberland <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent dd4b3c8 commit 00b39f6

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

drivers/s390/block/dasd_eckd.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
20742074
dasd_free_block(device->block);
20752075
device->block = NULL;
20762076
out_err1:
2077-
kfree(private->conf_data);
2077+
dasd_eckd_clear_conf_data(device);
20782078
kfree(device->private);
20792079
device->private = NULL;
20802080
return rc;
@@ -2083,7 +2083,6 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
20832083
static void dasd_eckd_uncheck_device(struct dasd_device *device)
20842084
{
20852085
struct dasd_eckd_private *private = device->private;
2086-
int i;
20872086

20882087
if (!private)
20892088
return;
@@ -2093,21 +2092,7 @@ static void dasd_eckd_uncheck_device(struct dasd_device *device)
20932092
private->sneq = NULL;
20942093
private->vdsneq = NULL;
20952094
private->gneq = NULL;
2096-
private->conf_len = 0;
2097-
for (i = 0; i < 8; i++) {
2098-
kfree(device->path[i].conf_data);
2099-
if ((__u8 *)device->path[i].conf_data ==
2100-
private->conf_data) {
2101-
private->conf_data = NULL;
2102-
private->conf_len = 0;
2103-
}
2104-
device->path[i].conf_data = NULL;
2105-
device->path[i].cssid = 0;
2106-
device->path[i].ssid = 0;
2107-
device->path[i].chpid = 0;
2108-
}
2109-
kfree(private->conf_data);
2110-
private->conf_data = NULL;
2095+
dasd_eckd_clear_conf_data(device);
21112096
}
21122097

21132098
static struct dasd_ccw_req *

0 commit comments

Comments
 (0)