Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp427156pxj; Thu, 27 May 2021 03:41:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWn5N19/BkxxOnXMq2tcAxduGH/mRj+/pxCPKe0ec2EjTd/cj7p0gp9BDZlKJHgvDjO1cG X-Received: by 2002:a05:6638:2594:: with SMTP id s20mr2843711jat.140.1622112069805; Thu, 27 May 2021 03:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622112069; cv=none; d=google.com; s=arc-20160816; b=0c4wK1xJqDP78tJ0IDga6vb/QR+uUKIdDAmFoEtfxyfGHxvy0CTwOJo78CQJDL8JQp Ovh/x+QLiOAHWNm97qL4XDNsK2iyeYQtcrY2q2yMS8uOZmHvPsol+m3gn8Krbr7dRnbd QQ0ugdgBgnuvbLNow72LQOPBr4aU4Pj2IuS/OQLA2CqbZYy5bYXKYGISkLqu0Y07DEf3 /8FOrJVkyZQrU7+CjKM5nX6dWUgYuULnC4iJTc1mrd7jx7CNeMc8O6U7Se+cH4XJM70a QTDSP++Lv2sRFNpVYCTOD3QriNp1YkGKfQYNGZFoUDCfffrwvdo2WIL0ftX18TC4WTDr I4tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=80S8cMT7bKdLi9y0x2gMMKJOdqWMukWva0P9NsqCifs=; b=PZy58eh+r4KxcNc8S1PW+w7Yu7sdjveMS2wrBaboFCMFJfkM7y5cEacI2kucwN7sb/ 7piRSaMvvzk+3w2Dpg5jSB5UNAzncy5Hi5n3S3jn15LnxLyMZZmJJO+3nzpK3uaQ8jjj rlEVIMtCh/WbtmG/aZOzGHTcCPgJyV5b4eGF22C/DkpNXjfNwEG2g1P3DjYiRBvztzMQ jNIjTD4t2JIUZGM6Gg58JwB29E8TxoX36GaC+oE8Jm78JrgPTzNJjBg0SzRs24W8mV4W 5fRF1MSsAn8ZsDstSkPlS+IGpg0/2pOv6Y/fF40eKtWU1jdWfKP4Ak4OlB9cv7f+5Wci yTOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=QYMQaj10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f14si2322237jav.44.2021.05.27.03.40.56; Thu, 27 May 2021 03:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=QYMQaj10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236187AbhE0Kic (ORCPT + 99 others); Thu, 27 May 2021 06:38:32 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:52292 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236103AbhE0Kia (ORCPT ); Thu, 27 May 2021 06:38:30 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14RAYhTT178963; Thu, 27 May 2021 10:36:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=80S8cMT7bKdLi9y0x2gMMKJOdqWMukWva0P9NsqCifs=; b=QYMQaj10mKZyWZcVAHzHtCX5IDbcCvyDQnXQQYgNZ75tgXjtVkpDpNzXYJIn/p4P+4Ld yY6xXN3Wcd8rC5uaX9Ip0GcdQwf3M1dCDSIR0PHud2GJ6mB26SuZCqcfLmoIKpwKRvnB wQMe+ah3nayLcXukUISpOBCwKkvFl6sIYy2ijqtU/gM9Ofcd7GVke3lyDmJrqqvFgmIU VPgs+IpUExiXCxKLCmnXabI/fXsB6t9n34a5p3Wudiozk42QrEgHdcKxaOVbuKsYpEVk g3wMX9jeAVlxdVGeNL5+STqZfXtHZm79SmHhqwPJY6wHLT3qqvFoTZjIzePo2DlrlPcn FQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 38pqfcktj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 May 2021 10:36:52 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14RAZVIB046312; Thu, 27 May 2021 10:36:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3030.oracle.com with ESMTP id 38pq2w9dv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 May 2021 10:36:52 +0000 Received: from userp3030.oracle.com (userp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 14RAapv1048160; Thu, 27 May 2021 10:36:51 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 38pq2w9dus-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 May 2021 10:36:51 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 14RAan4w032245; Thu, 27 May 2021 10:36:49 GMT Received: from kadam (/41.212.42.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 27 May 2021 03:36:48 -0700 Date: Thu, 27 May 2021 13:36:41 +0300 From: Dan Carpenter To: Richard Gong Cc: Christophe JAILLET , gregkh@linuxfoundation.org, atull@kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] firmware: stratix10-svc: Fix a resource leak in an error handling path Message-ID: <20210527103641.GS1955@kadam> References: <0ca3f3ab139c53e846804455a1e7599ee8ae896a.1621621271.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-ORIG-GUID: 5i188k-zGJ1R86dMPKsfMfYhL4OVBBv1 X-Proofpoint-GUID: 5i188k-zGJ1R86dMPKsfMfYhL4OVBBv1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9996 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 clxscore=1011 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105270069 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021 at 02:13:12PM -0500, Richard Gong wrote: > > dev_set_drvdata(dev, svc); > > pr_info("Intel Service Layer Driver Initialized\n"); > > + return 0; > > + > > +err_put_device: > > + platform_device_put(svc->stratix10_svc_rsu); > > +err_free_kfifo: > > + kfifo_free(&controller->svc_fifo); > > Need for the allocated memory pool as well, > if (ctrl->genpool) > gen_pool_destroy(ctrl->genpool); > Good point, but there is no need to check, the genpool is not optional and the "if (ctrl->genpool)" condition could be deleted from the remove function as well. err_put_device: platform_device_put(svc->stratix10_svc_rsu); err_free_kfifo: kfifo_free(&controller->svc_fifo); err_destroy_pool: gen_pool_destroy(genpool); return ret; But the other question is what's on with the &svc_ctrl list? I would have thought that we needed to remove freed controller from the list as well, but looking at it now I think the list itself should be removed. I think there can only be one item in the list at a time. So we could just make the controller pointer a file scope global or we could find some other way to go from the client pointer to the controller pointer. regards, dan carpenter