Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2636071pxj; Mon, 10 May 2021 07:29:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjdMZbeDcqghMVmCD1IBo9zf+f0u6V3ieQGCrxM0PbRRwbbRDoItB4aID5LD34BceG91FV X-Received: by 2002:a17:906:b191:: with SMTP id w17mr26301490ejy.200.1620656970546; Mon, 10 May 2021 07:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620656970; cv=none; d=google.com; s=arc-20160816; b=TNgeFErtvxtkCd7N7DzHr7lam7o8xvUN7HDLoaO/skL3yCs6o6zx9M+65Zv0iV4vg8 tvCWLiWt/EOrKn29He2y2/N5ZHf1b0b5bLJa63pfhVkpcJA2ctMFk850uKunUXoS2Cwb VtgDokDF95q2Zg9hK7EcrK7gi42C+b3jEC4Ei1qbGSBhPZZuvzkX3r2BSrUfuvZJNyF1 L5GQosNJcn5kslyr/VBeXoHp7yvsYhoDd0+xrP+myXV8/yMOA8lLax1I4PRfJGsCCDmZ EjAnKeAzyOHI53mmHG+htjf8JlggR7nUvlFlhooqQN4ZG47IjjC2zY464eROGx4dkl7J /4BQ== 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:from:references :cc:to:subject; bh=6n3fUFcOASAYvo6CsGAr+SCxrw/PQxhy2zE5xfjUwqY=; b=olbqOdZ33B1fDpH6IO082JxT+MpFVJM8zEkB829qLY7BPTHXu8yoZBQyuQ9OXP3EC3 ScGrGYaS3X4jIaMSmK5ZLTiVSahSg/JjucpxUsueX10iz5u5aKy8un8lvtbtbYuoNBV9 HMFoPmrSZW8IyqN5Q1WBBemCHJb0N1+l/0xcppcU6ZS+rJ64sy8vqBu9OvahnN/U+zij oWQYcWgIXIDpVYIywhS0GdFUpV9DfLNkRU/A9Og+uU3NaeR75kNhdcY0DVbx8XNdE+BM tZqaIr14rA+3YZ24KXLWM80jJufvVr4h5OJuG+4icLrZUNtVvIDCFKJ5X+enSfELYQgq ZQpA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si13871420eju.518.2021.05.10.07.29.06; Mon, 10 May 2021 07:29:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231302AbhEJO0q (ORCPT + 99 others); Mon, 10 May 2021 10:26:46 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:46684 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234212AbhEJOWv (ORCPT ); Mon, 10 May 2021 10:22:51 -0400 Received: from mail-qk1-f200.google.com ([209.85.222.200]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lg6n3-0004sp-FM for linux-kernel@vger.kernel.org; Mon, 10 May 2021 14:21:45 +0000 Received: by mail-qk1-f200.google.com with SMTP id h190-20020a3785c70000b02902e022511825so11750375qkd.7 for ; Mon, 10 May 2021 07:21:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6n3fUFcOASAYvo6CsGAr+SCxrw/PQxhy2zE5xfjUwqY=; b=kPahWccNnDjeYmds3F/j6VTDz8/6p0jnQRa8q8pBrLoobRQiO2Rnd0quViwLjxFyn6 l0Z3iBuxF/bhmnH5aZLj5CXEswM1+qro314FcZ3OLflmt3fZH9Eysxl63JwzP2inSq1h SMv0ndwXzJtjD5Y8DZZyf6yhLY0HKvF+M3O/r9bjMu1AZl24nCpVkQWw7HdnMUjFSf9j 5sFoNuIeJGAhGlAE6SfFjv5fy098MLA1xuo0HYkXA42bq+2E2GEuJTUSeXlQDa2xxs4d E3cGhmq3p1ZN0IuNTGWdZ4/Dmmej0B1adXP3YTnqOU2/iPOZ0wKQKZ0RtnkRJK7gmXxB sAnA== X-Gm-Message-State: AOAM5337RYR4k/s/xkKsryckyzIbCQvXMnU5pKSvqiRwavfgOQsvx7Cz MVl/h4cnHqc5v5tcdbafxsJmfNR2vbbH74RdQ/ChfXPUPz3UfdFgqm1m6/zBCe3MUHcD1xcJrMQ PNFNErnnYY9COBWb9alwbP8405LOxpzAc0WhpZg/sHQ== X-Received: by 2002:a05:6214:12ab:: with SMTP id w11mr23545374qvu.14.1620656504333; Mon, 10 May 2021 07:21:44 -0700 (PDT) X-Received: by 2002:a05:6214:12ab:: with SMTP id w11mr23545354qvu.14.1620656504168; Mon, 10 May 2021 07:21:44 -0700 (PDT) Received: from [192.168.1.4] ([45.237.49.2]) by smtp.gmail.com with ESMTPSA id 7sm7122602qkd.20.2021.05.10.07.21.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 May 2021 07:21:43 -0700 (PDT) Subject: Re: [PATCH 4/4] extcon: extcon-max8997: Fix IRQ freeing at error path To: Matti Vaittinen , Matti Vaittinen Cc: Chanwoo Choi , Bartlomiej Zolnierkiewicz , MyungJoo Ham , Hans de Goede , Marek Szyprowski , linux-kernel@vger.kernel.org References: <9047a741b4c4d97e721ed8b48cc4b434a46acba3.1620633360.git.matti.vaittinen@fi.rohmeurope.com> From: Krzysztof Kozlowski Message-ID: Date: Mon, 10 May 2021 10:21:41 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <9047a741b4c4d97e721ed8b48cc4b434a46acba3.1620633360.git.matti.vaittinen@fi.rohmeurope.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/05/2021 04:12, Matti Vaittinen wrote: > If reading MAX8997_MUIC_REG_STATUS1 fails at probe the driver exits > without freeing the requested IRQs. The driver frees IRQ on probe failure, so maybe you meant missing IRQ mapping dispose? > > Simplify driver and fix the IRQ problem by switching to use the > resource managed IRQ requesting and resource managed work-queue > initialization. > > Fixes: 3e34c8198960 ("extcon: max8997: Avoid forcing UART path on drive probe") > Signed-off-by: Matti Vaittinen > --- > > Please note that the change is compile-tested only. All proper testing is > highly appreciated. > --- > drivers/extcon/extcon-max8997.c | 45 +++++++++++---------------------- > 1 file changed, 15 insertions(+), 30 deletions(-) > > diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c > index e1408075ef7d..bbc592823570 100644 > --- a/drivers/extcon/extcon-max8997.c > +++ b/drivers/extcon/extcon-max8997.c > @@ -5,6 +5,7 @@ > // Copyright (C) 2012 Samsung Electronics > // Donggeun Kim > > +#include > #include > #include > #include > @@ -650,27 +651,30 @@ static int max8997_muic_probe(struct platform_device *pdev) > mutex_init(&info->mutex); > > INIT_WORK(&info->irq_work, max8997_muic_irq_work); > + ret = devm_work_autocancel(&pdev->dev, &info->irq_work, > + max8997_muic_irq_work); > + if (ret) > + return ret; > > for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { > struct max8997_muic_irq *muic_irq = &muic_irqs[i]; > unsigned int virq = 0; > > virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq); > - if (!virq) { > - ret = -EINVAL; > - goto err_irq; > - } > + if (!virq) > + return -EINVAL; > + > muic_irq->virq = virq; > > - ret = request_threaded_irq(virq, NULL, > - max8997_muic_irq_handler, > - IRQF_NO_SUSPEND, > - muic_irq->name, info); > + ret = devm_request_threaded_irq(&pdev->dev, virq, NULL, > + max8997_muic_irq_handler, > + IRQF_NO_SUSPEND, > + muic_irq->name, info); > if (ret) { > dev_err(&pdev->dev, > "failed: irq request (IRQ: %d, error :%d)\n", > muic_irq->irq, ret); > - goto err_irq; > + return ret; > } > } > > @@ -678,14 +682,13 @@ static int max8997_muic_probe(struct platform_device *pdev) > info->edev = devm_extcon_dev_allocate(&pdev->dev, max8997_extcon_cable); > if (IS_ERR(info->edev)) { > dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); > - ret = PTR_ERR(info->edev); > - goto err_irq; > + return PTR_ERR(info->edev); > } > > ret = devm_extcon_dev_register(&pdev->dev, info->edev); > if (ret) { > dev_err(&pdev->dev, "failed to register extcon device\n"); > - goto err_irq; > + return ret; > } > > if (pdata && pdata->muic_pdata) { > @@ -756,23 +759,6 @@ static int max8997_muic_probe(struct platform_device *pdev) > delay_jiffies); > > return 0; > - > -err_irq: > - while (--i >= 0) > - free_irq(muic_irqs[i].virq, info); Here it will unwind what was done. > - return ret; > -} > - Best regards, Krzysztof