Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2433846pxj; Mon, 10 May 2021 02:54:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8owNgkQHfL0lbXP+/y+4K3efUNg5ibn/boWG4Z2cRG74nkYfCdZidy6EYhrOtm5qpFouw X-Received: by 2002:a6b:d213:: with SMTP id q19mr17042211iob.203.1620640480868; Mon, 10 May 2021 02:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620640480; cv=none; d=google.com; s=arc-20160816; b=LfUAdnZRCogPED5ETn2jD4zg16CW2hBj0T+X8Mq2DkQnj6ie610O+NhW5K+/IX+X4d UgoS6zI1lASaZhHgMx6V5QPuLcvKo7WAszQdl6zo7esK4PAR+VuA837jdtWvDft+8HUF wtWkq6IF83vARswTOFK9VmvzwJ1VsH6w2aqZI1czCSQ1hKQlQIacp3DkH7QpMW3je23r iA0xeN9/WpjRPrdErR17B+BqT/XOsQQ451/WYLauckZUPbEkNzWgFMLQn7whTgTY3dlE G8CLC4ZSO6R55HcdE5POBskdkcA6F7juiwc7SG63U6uPQjSyW/DcSpt/95CE/70VchSB IEhQ== 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=sqrzfth2vQXxqsJTeCMpMZf0Wa6kexMFJ4z/H3+4Fqg=; b=BtWpRB7UYx3DCKrNfmALW7yFifdS90tqlxPyISDAMK5SWcnQt+wl6pkjcyQllTUn0R Qosm2M5jXYOdZ0deLvLOdvI/GICYzJOG2iUHZD2MI20Jbufym29wet9l3Ksd4TKOiz63 1R1hsqEzrtrXdNlF8gbP9vS3fFqCz0aSXrDT2zJawPLbsf4Yo7zx56E3tn0pJCIngggf CbKVnLnmNkK0OlpBz+B0EIf5u6WV8CuqUtZUZLd3ujLhU0LzX4Ge5sITzyFEILyFWkDi EXEVRqfOoOAobMA/KqWkloEiHxdXHNNPMnD3ufTptGUBZNowOyBbwLXbbyFKhgyOTWBs jltA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si3866596jam.93.2021.05.10.02.54.29; Mon, 10 May 2021 02:54:40 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231233AbhEJJyj (ORCPT + 99 others); Mon, 10 May 2021 05:54:39 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]:37716 "EHLO mail-wm1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbhEJJwh (ORCPT ); Mon, 10 May 2021 05:52:37 -0400 Received: by mail-wm1-f54.google.com with SMTP id b11-20020a7bc24b0000b0290148da0694ffso10779481wmj.2; Mon, 10 May 2021 02:51:19 -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=sqrzfth2vQXxqsJTeCMpMZf0Wa6kexMFJ4z/H3+4Fqg=; b=aWyQCW8msaJ5rOiZ2PJlpLQOVWhEY0jJvXYsllmJzAUdyg2EmyHM7Zb3ORy09uFhJJ 9VOvi653snqbQU6PmKbA80iljCM3LHJe+Zyh4ltfdAAEyDsQpYM5qSiTKRe1XCSqI7Y+ jYKE64qatvIkdWcf44WC9Uq0Y/FhZ0qsrHwKWPBWI/PjU7hU3cl16cqvWik5225eMf1S dN6U1jwWi8V2CZaiFnQHPQ+lEWBeF8d4zkINVqhwQcttD8gFX3QNluYpHCr3hAymnNIp 5bcmiikLLRZ1WuXlLTYIvqkgpnmM5DBlVesurBRMy2JXrtnS91bQPxPwU/XcPZakTafP 5y2g== X-Gm-Message-State: AOAM5323pJTEO2NFBOLj8mylEpRpUxb9GOpX1t9YDUwmL9Xi4YVZiw8S 928CTAFFACETAn+NVHpSxEziOxhulL8= X-Received: by 2002:a7b:c7c5:: with SMTP id z5mr34244569wmk.184.1620640277782; Mon, 10 May 2021 02:51:17 -0700 (PDT) Received: from ?IPv6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id j13sm21964872wrw.93.2021.05.10.02.51.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 May 2021 02:51:16 -0700 (PDT) Subject: Re: [PATCH] tty: nozomi: Fix a resource leak in an error handling function To: Christophe JAILLET , gregkh@linuxfoundation.org, akpm@linux-foundation.org, stefani@seibold.net Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <4f0d2b3038e82f081d370ccb0cade3ad88463fe7.1620580838.git.christophe.jaillet@wanadoo.fr> From: Jiri Slaby Message-ID: <749cb98d-07d6-740e-1d2d-46306520089b@kernel.org> Date: Mon, 10 May 2021 11:51:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <4f0d2b3038e82f081d370ccb0cade3ad88463fe7.1620580838.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09. 05. 21, 19:22, Christophe JAILLET wrote: > A 'request_irq()' call is not balanced by a corresponding 'free_irq()' in > the error handling path, as already done in the remove function. > > Add it. > > Fixes: 9842c38e9176 ("kfifo: fix warn_unused_result") > Signed-off-by: Christophe JAILLET Reviewed-by: Jiri Slaby > --- > I also wonder if the loop above is correct. The 'i < MAX_PORT' looks really > spurious to me. > 'tty_port_destroy' can be called twice for the same entry (once before > branching in the error handling path, and once in here) and > 'tty_unregister_device'/'tty_port_destroy' will be called on entries > that have not been 'tty_port_init'ed or 'tty_port_register_device'd. > I don't know if it may be an issue. Yes. The fail path handling is very broken there. Both the code of err_free_tty label, and of the err_free_kfifo label. The loops should have been _something_ (I didn't invest much thinking into it, so it's likely wrong) like: for (i--; i--; ) { ... } > --- > drivers/tty/nozomi.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c > index 9a2d78ace49b..b270e137ef9b 100644 > --- a/drivers/tty/nozomi.c > +++ b/drivers/tty/nozomi.c > @@ -1420,6 +1420,7 @@ static int nozomi_card_init(struct pci_dev *pdev, > tty_unregister_device(ntty_driver, dc->index_start + i); > tty_port_destroy(&dc->port[i].port); > } > + free_irq(pdev->irq, dc); > err_free_kfifo: > for (i = 0; i < MAX_PORT; i++) > kfifo_free(&dc->port[i].fifo_ul); > thanks, -- js suse labs