Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7467465ybp; Wed, 16 Oct 2019 09:05:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHwS3scFs5zjTm5wGUkQtYXr8ekXVeQJkalNrNQBgJheKB+hts4mFacvHQFu2S1vFypsbb X-Received: by 2002:a50:fa8e:: with SMTP id w14mr40540842edr.285.1571241926503; Wed, 16 Oct 2019 09:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571241926; cv=none; d=google.com; s=arc-20160816; b=DV6nEOzXry76Iva0rOpJRVMqrmaESum9TD6sQFBmYQ++S8PIn0+3++5ctWuTuqo4jj iXYqX2Uds8cR/k5nvqAQTQK9pHsvgS3iG8PiPTlJKeR9NHMYO710tSjPK96/8KN7+blI +daSduM/ePNOANW8uA8bE0cehepx988qGQMUhcoQIPQ0TkaG983Pu/0Rpl6Wevew3Lok l1H1k4asbcCpsIzt5Iu4Q5ktkdIBW6yk5U1FdO3TMMAlvKeXtGb0mcZe5qQ9pqPVpt06 2/afEoF5Rb4l36pJbF5WkF0T2pRU0SLut8WJZr7QQixSMqsPf5ODLE4efkKkxqaADhIM 2ckw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :subject:autocrypt:openpgp:from:references:cc:to; bh=iI57lM+BUwFljEYrjgWSFJJDnGGBObbiBKooISHRIzg=; b=Hb2X7gOfVzKDq24YlwH9dDeVMqQgBjfK514IgpJE3Sl10mk1cYv3uTFPTmQ+U6yL7K 6rmGcRmuEaW0hWyJ5a6cj0T54jmaIeB8rUA//+DsQ7pseBvQHb/r618QklxMPx/nA2tT Vi+pQ0wpQQ0oGQfsZ94tLQR6oGAW/D4CBu0GIEj2ydyDLVdg4Ja7v6LTx7Kh4pPM+U5d E28+xZBrJoVUkkTq0tsBdF/1KUnkiQf8Z6wlSYMdD2dVFfNI1VcmloZ0ue3QqdfoJy6T C38zRDarYN9iM5BfdoO5bgPNSrzAf73hyF8kNUWUQG0Jul6JJtBQ3paIQc+KPs5SZnas gXVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si14777726edu.4.2019.10.16.09.05.03; Wed, 16 Oct 2019 09:05:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405358AbfJPNbj convert rfc822-to-8bit (ORCPT + 99 others); Wed, 16 Oct 2019 09:31:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52378 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388342AbfJPNbi (ORCPT ); Wed, 16 Oct 2019 09:31:38 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9GDRs6R064135 for ; Wed, 16 Oct 2019 09:31:35 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vp1bqxdjg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 16 Oct 2019 09:31:10 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 16 Oct 2019 14:29:48 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 16 Oct 2019 14:29:46 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9GDTguJ11862140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2019 13:29:42 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A24311C052; Wed, 16 Oct 2019 13:29:42 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8DF811C050; Wed, 16 Oct 2019 13:29:41 +0000 (GMT) Received: from [9.152.214.37] (unknown [9.152.214.37]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 16 Oct 2019 13:29:41 +0000 (GMT) To: Qian Cai , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Christian Borntraeger Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org References: <1570044801.5576.262.camel@lca.pw> From: Stefan Haberland Openpgp: preference=signencrypt Autocrypt: addr=sth@linux.ibm.com; keydata= mQINBFtGVggBEADI1Lne1npTa+b5x5EJ7ka0siRMargCCo5dcOaCBBG3wT24IyyG6chdV7Yr vkeHDm/6OjMi+w8Vbx2ts0KhYWMj9SHX2E58AsyBedeCkedOKuhkNh0HNSv8WMCEi24uoYK9 3VW0bQ3KYAB5wY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9KmDAON4ldGPmA/+L3V5wkmWZJjD ZJIvio/wHMoqObEG6MxsFvGEoSDJBBGQ5oTiysACFM2vkOaOhj2Izh2L+dbuKJIT0Qus0hUJ uEjGgIAXn7hYNeM1MMqSA81NEoCeUhNHeZudf5WSoglG3rUnxIXrnxfDkn8Vd36cinGejyrI qJoydRMpX48I3wJcyvZ8+xgM/LLlvXEH4BpuJL+vQkefJrn0R2vxTnHcj5TE1tKNwhI7/343 PNzhgHGYynjCbF4u9qpSqcJl/exFnRXaTH6POIbHXIRe8n4TfdXsOcbI3j/GUF0cXinkfxdt BWH5rC3Ng+EN3jkDo8N9qF7uEqN9rRaekqsO0jYMQJlfZeJSQH9KHD+wgZly9j6DmnGexbdB aJdzCtbIR+oJy0HjfwvIQrgp1pj0yvXeDsUHykATsORx0ZitlGUuU6tlAnbH346nNSDoklLI lEDvODTgpkhWDczM69MGKrFYgDcIqXZFWzea6Xq+cuGtGO5xV/4K+efWQovlIdv4mE4j2E2G yXj14Nuyh4wqdX9/yspSZCH1TCbXD9WEB5nQCQNAKzIB7YaTQBjFi1HFzGOGYteZGC37DJ6a xEMRG8/iNZSU4dSL+XsaTnUk5wzzSnz0QVOEOqRY5tkS3zpo9OUGevyR3R6bRqH3EaA5H1cS cH4TNHyhiR0KAbxE8qKx3Jc= Subject: Re: memory leaks in dasd_eckd_check_characteristics() error paths Date: Wed, 16 Oct 2019 15:29:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <1570044801.5576.262.camel@lca.pw> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 19101613-0012-0000-0000-000003589894 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19101613-0013-0000-0000-00002193B23F Message-Id: <6f5584d5-755c-e416-52da-3cb99c69adaf@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-16_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=65 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910160120 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, thanks for reporting this. On 02.10.19 21:33, Qian Cai wrote: > For some reasons, dasd_eckd_check_characteristics() received -ENOMEM and then > dasd_generic_set_online() emits this message, > > dasd: 0.0.0122 Setting the DASD online with discipline ECKD failed with rc=-12 > > After that, there are several memory leaks below. There are "config_data" and > then stored as, > > /* store per path conf_data */ > device->path[pos].conf_data = conf_data; > > When it processes the error path in  dasd_generic_set_online(), it calls > dasd_delete_device() which nuke the whole "struct dasd_device" without freeing > the device->path[].conf_data first. Usually dasd_delete_device() calls dasd_generic_free_discipline() which takes care of the device->path[].conf_data in dasd_eckd_uncheck_device(). From a first look this looks sane. So I need to spend a closer look if this does not happen correctly here. > Is it safe to free those in > dasd_free_device() without worrying about the double-free? Or, is it better to > free those in dasd_eckd_check_characteristics()'s goto error handling, i.e., > out_err*? > > --- a/drivers/s390/block/dasd.c > +++ b/drivers/s390/block/dasd.c > @@ -153,6 +153,9 @@ struct dasd_device *dasd_alloc_device(void) >   */ >  void dasd_free_device(struct dasd_device *device) >  { > +       for (int i = 0; i < 8; i++) > +               kfree(device->path[i].conf_data); > + >         kfree(device->private); >         free_pages((unsigned long) device->ese_mem, 1); >         free_page((unsigned long) device->erp_mem); > > > unreferenced object 0x0fcee900 (size 256): >   comm "dasdconf.sh", pid 446, jiffies 4294940081 (age 170.340s) >   hex dump (first 32 bytes): >     dc 01 01 00 f0 f0 f2 f1 f0 f7 f9 f0 f0 c9 c2 d4  ................ >     f7 f5 f0 f0 f0 f0 f0 f0 f0 c6 d9 c2 f7 f1 62 33  ..............b3 >   backtrace: >     [<00000000a83b1992>] kmem_cache_alloc_trace+0x200/0x388 >     [<00000000048ef3e2>] dasd_eckd_read_conf+0x408/0x1400 [dasd_eckd_mod] >     [<00000000ce31f195>] dasd_eckd_check_characteristics+0x3cc/0x938 > [dasd_eckd_mod] >     [<00000000f6f1759b>] dasd_generic_set_online+0x150/0x4c0 >     [<00000000efca1efa>] ccw_device_set_online+0x324/0x808 >     [<00000000f9779774>] online_store_recog_and_online+0xe8/0x220 >     [<00000000349a5446>] online_store+0x2ce/0x420 >     [<000000005bd145f8>] kernfs_fop_write+0x1bc/0x270 >     [<0000000005664197>] vfs_write+0xce/0x220 >     [<0000000044a8bccb>] ksys_write+0xea/0x190 >     [<0000000037335938>] system_call+0x296/0x2b4