Received: by 10.192.165.148 with SMTP id m20csp861195imm; Wed, 25 Apr 2018 08:46:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/o9m78GOp4lzejhBtOhcmGlX5tqhoRJrLAEi/Wd9l1rSbM9V7RtglXie85ecKXWtFgCYOF X-Received: by 2002:a17:902:1744:: with SMTP id i62-v6mr25742130pli.267.1524671211873; Wed, 25 Apr 2018 08:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524671211; cv=none; d=google.com; s=arc-20160816; b=MKYWGVSIvPVrmv4kjDlcnczzFL3jil6vTJJ9Wejrqhc1liGeJJ2NdpzxtMBycKBGT7 d7wK/FBgyhOf/Eipx7wz8j4oOyzTGYdgUkF7SPFKb8kosO9Dy178fcYkhh8REmyZnEeQ x8KsfNQyqzhsIOLgkNhgDHfyAxpcfiq6cQVx0jnPdDFpmEAOUChHifbrYq8TkMyQbju+ 5K3s2lCmLUd3ykTE+UP3PqzXKzOoQJ81zBNJHFNydzi+5OeWde5NxFSgDJwUqMk7tp33 WBm3TG8865NUOB12Iy/T2Y1LiCJQvYtqRHUrUvRI309YPNAT6dSxZXeiElu7srWGB2nm cYHw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=Cy4MTykE8VQVsc8QfppwQHKEp62YRRl+wIKZNUpOb+4=; b=CVgxTm3je7J7b30zYfjPhRqmxyn8osPGxchXtzC0VNGYiCkZOzOwpH8yZzWBgg7Xro N8CcmHBulUsGf0yxezADDytSF4FQppLiK5OY+2rizqrBEwWPhztzFbSypdHwmwk/R6BR IfdWwjESAQWUVD0ybijq9aWQmN15zUtecaTB5uG9I7An7NxiYwv69ehbdgJObEXn0Qkz IFv/mGq1dEmg2wA/Fov9aGZoQbX1qvG9HIt7tIb2YHHIWHzKwA+dk8nQADwNIO5t0H89 3JDKsAUyxTFxztsHYAyHTXuF6K7R4twsfyhuD/roLFAqAFnMhH67AsTfzMpgCUKM0VOF T7wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=rN3dEDyn; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1-v6si17311440plr.410.2018.04.25.08.46.37; Wed, 25 Apr 2018 08:46:51 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=rN3dEDyn; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754946AbeDYPov (ORCPT + 99 others); Wed, 25 Apr 2018 11:44:51 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47504 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754820AbeDYPoq (ORCPT ); Wed, 25 Apr 2018 11:44:46 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3PFa9qE145844; Wed, 25 Apr 2018 15:44:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=Cy4MTykE8VQVsc8QfppwQHKEp62YRRl+wIKZNUpOb+4=; b=rN3dEDynTduslfzZjOhz/AtTVSINOntMxuzKY6W7rmBcF9h/xFCMsF+htFkUcVTyxZeh /2PxMdVPTswwx5kIplfVQOkz567CtL2QQo6uiWo1bRjMtkATnpS1Gb4VGfra9NA0Mbvs r8MyuFYC3enaD/Y9cJbsJw3CplY72J/O6gsYXvbY8rKwteSopO5SmWglr8C53tqEkx51 pS/gwXtPrGdVfLvJh5BpVfUYFoSyqwuEUmV8uPqZXafB7hTWMXt6NTxObPQPpaUlfpnh 5LRz12xFerKeBXyS38907GShkTD1MYSSQ6UeFuBQkNppYbQn22bQ3RIIzu6Ietnx5CV1 5Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2hfw9afc0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Apr 2018 15:44:42 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w3PFifrh000628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Apr 2018 15:44:41 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3PFif9g013699; Wed, 25 Apr 2018 15:44:41 GMT Received: from [10.159.241.100] (/10.159.241.100) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Apr 2018 08:44:40 -0700 Subject: Re: [PATCH] sparc: vio: use put_device() instead of kfree() To: Arvind Yadav , davem@davemloft.net, jag.raman@oracle.com, liam.merwick@oracle.com Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org References: From: Shannon Nelson Organization: Oracle Corporation Message-ID: Date: Wed, 25 Apr 2018 08:44:39 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8874 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804250146 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/25/2018 7:56 AM, Arvind Yadav wrote: > Never directly free @dev after calling device_register(), even > if it returned an error. Always use put_device() to give up the > reference initialized. > > Signed-off-by: Arvind Yadav > --- > arch/sparc/kernel/vio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c > index 1a0fa10..32bae68 100644 > --- a/arch/sparc/kernel/vio.c > +++ b/arch/sparc/kernel/vio.c > @@ -403,7 +403,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, > if (err) { > printk(KERN_ERR "VIO: Could not register device %s, err=%d\n", > dev_name(&vdev->dev), err); > - kfree(vdev); > + put_device(&vdev->dev); Hmmm... I can see why the put_device() might be a good idea, but I think we still need the kfree() so as to not leak the memory that was kzalloc'd above for vdev. sln > return NULL; > } > if (vdev->dp) >