From ab6aae09024be1b039df441fa1b64dbe092d0acb Mon Sep 17 00:00:00 2001 From: Sebastian Ott Date: Fri, 11 Sep 2009 10:28:24 +0200 Subject: [S390] cio: fix memleak in subchannel validation When scanning for new subchannels we have a code path where we allocate memory for a struct subchannel, set the device name (which is dynamically allocated now) and do a check if the underlying device is blacklisted - if so we free the subchannel structure. Since we have not set up refcounting at this stage, the device name's memory is lost. Fix this by moving the dev_set_name after the blacklist test. Note: With this patch the init_name for the console subchannel becomes virtually obsolete. Signed-off-by: Sebastian Ott Signed-off-by: Martin Schwidefsky --- drivers/s390/cio/css.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/s390/cio/css.c') diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 40d4b3093b7..0dc6f6d2628 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -183,6 +183,11 @@ static int css_sch_device_register(struct subchannel *sch) int ret; mutex_lock(&sch->reg_mutex); + if (cio_is_console(sch->schid)) + sch->dev.init_name = cio_get_console_sch_name(sch->schid); + else + dev_set_name(&sch->dev, "0.%x.%04x", sch->schid.ssid, + sch->schid.sch_no); ret = device_register(&sch->dev); mutex_unlock(&sch->reg_mutex); return ret; -- cgit v1.2.3-70-g09d2