Received: by 10.223.185.116 with SMTP id b49csp6082209wrg; Wed, 28 Feb 2018 03:46:32 -0800 (PST) X-Google-Smtp-Source: AH8x227HqsOLNU1lt066Qvg0OlNvwBDkZbgcTg/fnfGz8cH0bqmU59PLUPrziDZ3J2o2SGRb/8Wy X-Received: by 10.99.170.73 with SMTP id x9mr14023509pgo.393.1519818392837; Wed, 28 Feb 2018 03:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519818392; cv=none; d=google.com; s=arc-20160816; b=wSU8nwDZFXXzpSIsIXBud90rfFpvAPPX0FDrHIQEqPXU+ulgOpmSjaPrFqh5SnHgVy 6r/znjP7VL2nWOV8vwLBqmu/OflRwtWmmUPhLRpAeayu04vCqTZiY3jBYP/LiVDSsjq3 9kqoHTXknuHMeUVt/qQxI7pBG/eVgCEHHPdG7g7rDaIBneYdWLXpIOPLGY7CgJLTf6se //Hik/SUqe5myuCwunB0mNhHzSSlZW5odZ31P2MZNM9kddWLWfj2kVr+RFU7s1e5AEzw 6csgJjbO/Q8+V86WFtos/SNNmbBj8EDOX8Eu4NrFH62CVPQE1HvKDZ7BOmfNOGbTF3jz Krrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:arc-authentication-results; bh=eh+C/Xl8emmqg0bq3ztEQIhzJbKYuQ/mBDgqaD9xU/k=; b=Ch55yQ3UzzXp8eCPmZ5Ar/8D1j9VFYhBOhgQHiKXmdspDRYXRMDAGMU5NgAwmp06ST TMv9yyYmIhZ1D7RorPeVloBZ7scqrlXWhJooOLEwq+fFbAjuKvKlluoE97SKx0Ay5dHy RKwBkGTuPpTnEp5mYPUWWa+Ro60ZGrCLtIpc45So4N6eQGXAZQx0xeJ7wB+E9Cv9/PZy Ko5hVkTc4WeN+jVekz15LlDMi308g+itZfY1vgRQODCUmbDq6Mh/Fu7dfTQMbgNz1GIi jAJYtloFX+UUBqWtpu52CqLD9xiUueIlmTYkgh2hDLEn01mEtwVibkJp9PhFxnJ3FpVk GyIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JAQ51hLL; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10si943335pgr.73.2018.02.28.03.46.17; Wed, 28 Feb 2018 03:46:32 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JAQ51hLL; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752439AbeB1Lpd (ORCPT + 99 others); Wed, 28 Feb 2018 06:45:33 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:54030 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752139AbeB1Lpb (ORCPT ); Wed, 28 Feb 2018 06:45:31 -0500 Received: by mail-it0-f67.google.com with SMTP id w63so3116805ita.3; Wed, 28 Feb 2018 03:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=eh+C/Xl8emmqg0bq3ztEQIhzJbKYuQ/mBDgqaD9xU/k=; b=JAQ51hLLz99iiiIkBf85GJGk4HkwsjEVhcRD9luB8fbPmqdgZiUhSkJFpdvaCLFESz 81IisAXXNkwR4VpnxhIk1GocxbneUCSVFe17gBbY0jPoczlI9Qj0Xghsbf3IHh8CRCyG jkxndiumN5FVwRwteB0vcdZPaCgKmqzPT93rzhVs1xfBkpRA+uAS3Uq9AvlyXKD57WPM ov88DtS/2CQMpo22A67CYORyJDVP00ntHOsgtwIOAGB7E1H8Ymuo++8kTWnJsp/jhlRf 9lY8Bbmy+iIaC4RjWhJeR/74yL/2+8uFnGVvNnRxX3Ku9A1AOA5RhcZQslHk1Qt5sQym iThg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=eh+C/Xl8emmqg0bq3ztEQIhzJbKYuQ/mBDgqaD9xU/k=; b=NBwpaauIppnQKzhuNmBlsHXnL/Pd//4p9gzSQpcv531sfThr/tDTsefW5RNfbyXi/Y AZJmWIk5X2qzKJtqP6bo5DHhUXriAY8JR0sTyLsXGw5CqgdpYJ+SIp2B1cTPaK2yKgnv a7IV6R4krjZLrlplo5BH+8dyzekO4+i7YFatIMXqN/6DwhBYhsfk3SzDVUkSjcXYuFeT rr1EvB5/VWvH1qULyBWr1ghlCZSCpHXYQQ9U/2ARvxJ5sKRL7iUg6V4aVAU182SWbtM2 v/5LZKF8Kc6CSza8Z/mETUNH+0wAUMBecMnYhHkzap67hFoQrR8Jq50tAn1Ub1Y6ry8W tIww== X-Gm-Message-State: APf1xPBkLpPMvu5rK8tnMIS9ZqFiMvBISU94IpQkHvby8RS//NVBiqVx asC9sM3iT95egLgV9CpV4cIUWliS X-Received: by 10.36.140.3 with SMTP id j3mr13323460itd.66.1519818330577; Wed, 28 Feb 2018 03:45:30 -0800 (PST) Received: from [10.17.129.40] ([149.23.17.254]) by smtp.gmail.com with ESMTPSA id u129sm1270893ioe.57.2018.02.28.03.45.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 03:45:30 -0800 (PST) Subject: Re: [PATCH] net: iucv: Free memory obtained by kzalloc To: Cornelia Huck References: <6fbfc0b8aa75852c4eed4d05e4c165a493304ced.1519811528.git.arvind.yadav.cs@gmail.com> <20180228113042.6a2f5177.cohuck@redhat.com> Cc: jwi@linux.vnet.ibm.com, ubraun@linux.vnet.ibm.com, davem@davemloft.net, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org From: Arvind Yadav Message-ID: Date: Wed, 28 Feb 2018 17:14:55 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20180228113042.6a2f5177.cohuck@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 28 February 2018 04:00 PM, Cornelia Huck wrote: > On Wed, 28 Feb 2018 15:24:16 +0530 > Arvind Yadav wrote: > >> Free memory, if afiucv_iucv_init is not successful and >> removing a IUCV driver. >> >> Signed-off-by: Arvind Yadav >> --- >> net/iucv/af_iucv.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c >> index 1e8cc7b..eb0995a 100644 >> --- a/net/iucv/af_iucv.c >> +++ b/net/iucv/af_iucv.c >> @@ -2433,9 +2433,11 @@ static int afiucv_iucv_init(void) >> af_iucv_dev->driver = &af_iucv_driver; >> err = device_register(af_iucv_dev); >> if (err) >> - goto out_driver; >> + goto out_iucv_dev; >> return 0; >> >> +out_iucv_dev: >> + kfree(af_iucv_dev); >> out_driver: >> driver_unregister(&af_iucv_driver); >> out_iucv: >> @@ -2496,6 +2498,7 @@ static void __exit afiucv_exit(void) >> { >> if (pr_iucv) { >> device_unregister(af_iucv_dev); >> + kfree(af_iucv_dev); >> driver_unregister(&af_iucv_driver); >> pr_iucv->iucv_unregister(&af_iucv_handler, 0); >> symbol_put(iucv_if); > No, you must not use kfree() after you called device_register() (even > if it was not successful!) -- see the comment for device_register(). Yes, Your are right. First we need to call put_device() then kfree(). I will send updated patch. ~arvind