Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1316610rwi; Wed, 26 Oct 2022 13:43:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ztZWn1CPbyqlzgzlvi9wUqb/In/SbhIca/V29pBvKeVhGNJ9/7drxpR0XQ31C1pj/s2tt X-Received: by 2002:a17:902:e88a:b0:183:9ecb:ff85 with SMTP id w10-20020a170902e88a00b001839ecbff85mr46034244plg.169.1666816993442; Wed, 26 Oct 2022 13:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666816993; cv=none; d=google.com; s=arc-20160816; b=WMQlGUPGb0CKj2u6Gt/SiDF/GDhvk3KInwGBU6EA53RkbSgtrazA0Hnup4R3Y8sY3J tXTeLp4c+nVDNKr6lplCF3tj+B5SlHmQiC3CJD5PocI4QHv5I2Z0Oq/IRFzN7Oiaw8tZ uXbguVdy9PF9gmB9Q1uRYI43HUg9b/F6CbdQI/2P/edaak6LvwjAyfUAKvM8DUAJlQ9b R91H0MpV9+OxGc1eFyJBvo7fD9xUGQZMF5OkkyhCQRSppHCsz+o9Au/7pFXgQuyotZhv 37e5wrxR3jX6YxvsxepA6mADVIw71vF711KhxQ9thI1X9guTXae+Wem2XWFpEmpeitOy XGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=VdAVDobjmtciUcYGASdLnZ/w3UKHagQzg53I9t+ff6Q=; b=V6vA5QfVHeCA2xcWLXjRyQNk2GKZZ/7FjrAIZfhNeI/kr0MJFDwCYhzQqFAYaQavN4 QPG8bzviE1awDOA+a5nHPKMdUiKxOdsbcpbQtiQugGq6TsvwOJPeno0AistUvpKoE8DE v7NOdZLSYrlGV3zl9S5JZf1bl8J9cV12HvqnyJVQ5Z3mLl67qAutKM8vEKHKK2GaK7WC MyiVFjfiVPVpYGLl4rONZ3g+HvXFIh48FbxHYqwY+Hr1rH8wkYtL+VI0NAepaQqEJdmL iZNaAAFd7PKv32kgO18przphmbM0LOIMpFBDZEZsgklIau8EVC29taRcFi2Y0uMbGM1i Wd9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id il3-20020a17090b164300b00213255221e3si1163374pjb.1.2022.10.26.13.43.01; Wed, 26 Oct 2022 13:43:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235096AbiJZULI (ORCPT + 99 others); Wed, 26 Oct 2022 16:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235074AbiJZUKz (ORCPT ); Wed, 26 Oct 2022 16:10:55 -0400 Received: from smtp.smtpout.orange.fr (smtp-17.smtpout.orange.fr [80.12.242.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47D6E100415 for ; Wed, 26 Oct 2022 13:10:50 -0700 (PDT) Received: from [192.168.1.18] ([86.243.100.34]) by smtp.orange.fr with ESMTPA id nmjaohDontk1anmjao3cDN; Wed, 26 Oct 2022 22:10:48 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 26 Oct 2022 22:10:48 +0200 X-ME-IP: 86.243.100.34 Message-ID: <61826266-3f02-bc04-bd98-6391fe5d9fa6@wanadoo.fr> Date: Wed, 26 Oct 2022 22:10:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 tty-next 1/3] 8250: microchip: pci1xxxx: Add driver for quad-uart support. Content-Language: fr, en-US To: Tharunkumar.Pasumarthi@microchip.com, jk@ozlabs.org, Kumaravel.Thiagarajan@microchip.com, gregkh@linuxfoundation.org, ilpo.jarvinen@linux.intel.com, wander@redhat.com, u.kleine-koenig@pengutronix.de, etremblay@distech-controls.com, macro@orcam.me.uk, jirislaby@kernel.org, johan@kernel.org, andy.shevchenko@gmail.com, geert+renesas@glider.be, phil.edworthy@renesas.com, lukas@wunner.de Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com References: <20221001061507.3508603-1-kumaravel.thiagarajan@microchip.com> <20221001061507.3508603-2-kumaravel.thiagarajan@microchip.com> <676c5723-a9b7-9f28-fbb4-27a5c6f6145b@wanadoo.fr> From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 26/10/2022 à 13:12, Tharunkumar.Pasumarthi@microchip.com a écrit : > On Mon, 2022-10-03 at 21:36 +0200, Christophe JAILLET wrote: >> EXTERNAL EMAIL: Do not click links or open attachments unless you know the >> content is safe >>> +             } >>> +             priv->line[i] = serial8250_register_8250_port(&uart); >> >> In case of error, this should be undone in an error handling path in the >> probe, as done in the remove() function below. >> >> If we break, we still continue and return success. But the last >> priv->line[i] are still 0. Is it an issue when pci1xxxx_serial_remove() >> is called? > > This will not cause a problem in pci1xxxx_serial_remove as this condition 'priv- >> line[i] >= 0' will be checked for each of the ports before calling > serial8250_unregister_port API. Yes, this is my point. We check for >=0 in pci1xxxx_serial_remove(), but if we have an error in the "for (i = 0; i < nr_ports; i++)" loop, some line[i] we'll still be zeroed because 'priv' is zalloc'ed. In such a case, the probe still succeeds. So, if pci1xxxx_serial_remove() is called later, we potentially call serial8250_unregister_port(0) several times. This can lead to double (or more) free in serial8250_em485_destroy() (but maybe this path can't be taken here?) or maybe some other troubles elsewhere (I've not checked all the logic in uart_remove_one_port() to make sure that calling several times this function with the same args is fine). So my point is maybe just a "can't happen" case. If so, apologize for the noise. CJ > > > Thanks, > Tharun Kumar P