Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5632177pxb; Sun, 7 Nov 2021 16:49:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmKekYZl/ASoCG5+KsUWtx+YoG/O00ObQOSwleu0+Ssma+mS7uWxhEOuBjdVGAWCXxgrFg X-Received: by 2002:a05:6402:d0b:: with SMTP id eb11mr37560850edb.388.1636332589792; Sun, 07 Nov 2021 16:49:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636332589; cv=none; d=google.com; s=arc-20160816; b=hcC0ewjy0yrz+0sxjxiAOxgVV7XdlSDZaa//GNfXSnLIPxzPyxwHeKXAFWK1se2xrv VrXgDSI4AtIKR/gBeXSUlIqvqlc57D358mP+SyYKwj75xu98zIh/TuMVTfpO/geS+IV2 fDDHX4gsX4V+pdUvQcFad9vyAIjAaFwh1yhsf8hGKqvJz53Z34vkzqUouu4yyypHV5MM vuzjloPH10CeBDquOzMFJncaz3HbTXXgDuEaPpHSHmmNY9lbML3JzLqYRMLaR8wLGEk9 f8QmVgUmYo9dWTn+eRRkJbtPkdkLxpwvHrjVwfIPA6kGcKg74UHJ7DjciSITIDbnUxEa uPOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=uCxeeI/YQJQX5zYmGV9BnRKhkQoS8mCba50foOHWNNw=; b=cplBlavWd7yqIYp0VVKzbRfsC/ugq5N/6LA4QEJ/6cmU2oBvNEZyR0MbN/epjxmhPL zRnnmthxuNBXu+4DkRCLvzhBKi4xqJ9ZVpGwsD5k9Jmjc3wtNeF7ayvWJxsJ10x4tFeD kPEFtkaAo93gJ/qTxwDj+7Do3Wn+8ZQ4eu6EO7hbDygTn0X3lMTYIAPkP0YUKJ+/5uTg nbN3MbL+BvLcbx+lRi3RhnF/kbF36Hgn31zSw9aT58mdFZorWVooaD6KlYOgb0DjwM1a IxZLLDdbzHvb+uPm+7AgB7NY/rQ1bsCeItA7eIARxIbmVIvPNJAi/Qn0E+oBaSGJBMVC nyOQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt30si26523389ejc.298.2021.11.07.16.49.15; Sun, 07 Nov 2021 16:49:49 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235331AbhKGSRX (ORCPT + 99 others); Sun, 7 Nov 2021 13:17:23 -0500 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:64285 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235319AbhKGSRX (ORCPT ); Sun, 7 Nov 2021 13:17:23 -0500 Received: from [192.168.1.18] ([86.243.171.122]) by smtp.orange.fr with ESMTPA id jmggmUEOWf6fnjmggmDhcI; Sun, 07 Nov 2021 19:14:39 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 07 Nov 2021 19:14:39 +0100 X-ME-IP: 86.243.171.122 Subject: Re: [PATCH] nvdimm/pmem: Fix an error handling path in 'pmem_attach_disk()' From: Marion & Christophe JAILLET To: Ira Weiny Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20211107171157.GC3538886@iweiny-DESK2.sc.intel.com> <050385c3-7707-76cb-c580-c64d43456462@wanadoo.fr> <22d5172f-2d13-0ce2-2029-9cf46f203792@wanadoo.fr> Message-ID: Date: Sun, 7 Nov 2021 19:14:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <22d5172f-2d13-0ce2-2029-9cf46f203792@wanadoo.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 07/11/2021 à 18:25, Marion & Christophe JAILLET a écrit : > > > Le 07/11/2021 à 18:20, Christophe JAILLET a écrit : >> Le 07/11/2021 à 18:11, Ira Weiny a écrit : >>> On Sat, Nov 06, 2021 at 06:27:11PM +0100, Christophe JAILLET wrote: >>>> If 'devm_init_badblocks()' fails, a previous 'blk_alloc_disk()' call >>>> must >>>> be undone. >>> >>> I think this is a problem... >>> >>>> >>>> Signed-off-by: Christophe JAILLET >>>> --- >>>> This patch is speculative. Several fixes on error handling paths >>>> have been >>>> done recently, but this one has been left as-is. There was maybe a good >>>> reason that I have missed for that. So review with care! >>>> >>>> I've not been able to identify a Fixes tag that please me :( >>>> --- >>>>   drivers/nvdimm/pmem.c | 5 +++-- >>>>   1 file changed, 3 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c >>>> index fe7ece1534e1..c37a1e6750b3 100644 >>>> --- a/drivers/nvdimm/pmem.c >>>> +++ b/drivers/nvdimm/pmem.c >>>> @@ -490,8 +490,9 @@ static int pmem_attach_disk(struct device *dev, >>>>       nvdimm_namespace_disk_name(ndns, disk->disk_name); >>>>       set_capacity(disk, (pmem->size - pmem->pfn_pad - >>>> pmem->data_offset) >>>>               / 512); >>>> -    if (devm_init_badblocks(dev, &pmem->bb)) >>>> -        return -ENOMEM; >>>> +    rc = devm_init_badblocks(dev, &pmem->bb); >>>> +    if (rc) >>>> +        goto out; >>> >>> But I don't see this 'out' label in the function currently?  Was that >>> part of >>> your patch missing? >> >> Hi, >> the patch is based on the latest linux-next. >> See [1]. The 'out' label exists there and is already used. >> >> In fact, I run an own-made coccinelle script which tries to spot >> mix-up between return and goto. >> In this case, we have a 'return -ENOMEM' after a 'goto out' which >> looks spurious. Hence, my patch. >> >> [1]:https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/nvdimm/pmem.c#n512 >> > > Lol, the #n512 above is in fact another place that should be updated as > well. I missed it and only fixed #n494! In fact, no, line 512 should be left as-is. The clean-up wilol be made by 'pmem_release_disk()'. The patch attached at the very first mail of this thread looks good to me. CJ > > CJ > >> >> CJ >> >>> >>> Ira >>> >>>>       nvdimm_badblocks_populate(nd_region, &pmem->bb, &bb_range); >>>>       disk->bb = &pmem->bb; >>>> -- >>>> 2.30.2 >>>> >>> >> >> >