Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp274862imw; Fri, 8 Jul 2022 02:45:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v5HCqkUgvUtWMAcjPolFsFppiqYeKSUnXTlOBix+PAryD76ijUBDxyd7Uh9W9nOGLr6gif X-Received: by 2002:a05:6402:278c:b0:43a:91cb:c43a with SMTP id b12-20020a056402278c00b0043a91cbc43amr3623204ede.188.1657273557501; Fri, 08 Jul 2022 02:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657273557; cv=none; d=google.com; s=arc-20160816; b=M7cSLSRsFj63zkkjw/Bu02bTdpCo30aWYkts4MOg1dwpt37JEk52xeUQjhTsp6DORZ Qv07agD1oCT7CmNdyV+bABN2beGfDOnuAIAYOcBP9YKbAWsFKDU/QKfWFAAMLbIgbMQV BMc3zAtNA3uJP/OFZjFxeRQVDxaEhH4uW2Fckd4i6Xt+CdUo4c0oTKaXr2SNhwSTFihr o5mP12NBGpeXeOg4OY2XZ45AoPTqcKq0HFWD18EJFqK3WcV9WZOGW8WUL2Z/qamLlLAo 0vQ/dAqGi7Wxj2YNcm6KyGZEFEZCH+VJuiDT2tFeKkZjkJTqK1D7SRmyxx/z6T5Eh4hm QHEA== 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:organization :from:references:cc:to:subject; bh=MX1x6DJgTQV4xT0Moaafyxuontaf/X3kzV0IVp18Y/k=; b=iMurZm0lM8U8yT9MH2TLAxA8+fg37Sw+l/hJDY1q0Vrmdh8iONhztkKWUxO77gA+ZT WsHZ3WK5vdoC7cfGV8Q/EvdCBkSh0hSGGh2yZzVXeKvR+1VWR/OCGgnBlQcXN8l49o8S jVPa+rW/QrihTZSX91opwUy0zJAGF3X30zlZvkOZx0DuoFdIDs7lHbHBfhjzH/LKbanI bNP6/Gau1V672U3+yT6hDdryL/ANR6TvMO032o5eXkvTpv8hhRjbu5dUs8W/IKtw9o1f WDSCTmPdrF7rNv46iv5/owRxlcOVQ15DXTgucKMEKJEmt9kzvQ4dGPLtknyqY9/bPJKH DWYQ== 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 go20-20020a1709070d9400b007269e670e4asi2922951ejc.912.2022.07.08.02.45.31; Fri, 08 Jul 2022 02:45:57 -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 S237573AbiGHJkB (ORCPT + 99 others); Fri, 8 Jul 2022 05:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237190AbiGHJj7 (ORCPT ); Fri, 8 Jul 2022 05:39:59 -0400 Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C3ED6B245; Fri, 8 Jul 2022 02:39:58 -0700 (PDT) Received: from [192.168.1.103] (31.173.81.246) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.14; Fri, 8 Jul 2022 12:39:49 +0300 Subject: Re: [PATCH v3 2/9] usb: typec: Add retimer handle to port To: Greg Kroah-Hartman CC: Prashant Malani , , , , , , Daisuke Nojiri , "Dustin L. Howett" , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Sebastian Reichel , Tzung-Bi Shih References: <20220707222045.1415417-1-pmalani@chromium.org> <20220707222045.1415417-3-pmalani@chromium.org> <509bf6fe-4406-c577-aa70-6eb70801e375@omp.ru> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: Date: Fri, 8 Jul 2022 12:39:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [31.173.81.246] X-ClientProxiedBy: msexch01.omp.ru (10.188.4.12) To msexch01.omp.ru (10.188.4.12) X-KSE-ServerInfo: msexch01.omp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.20, Database issued on: 07/08/2022 09:19:09 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 59 X-KSE-AntiSpam-Info: Lua profiles 171638 [Jul 08 2022] X-KSE-AntiSpam-Info: Version: 5.9.20.0 X-KSE-AntiSpam-Info: Envelope from: s.shtylyov@omp.ru X-KSE-AntiSpam-Info: LuaCore: 493 493 c80a237886b75a8eec705b487193915475443854 X-KSE-AntiSpam-Info: {rep_avail} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: {relay has no DNS name} X-KSE-AntiSpam-Info: {SMTP from is not routable} X-KSE-AntiSpam-Info: {Found in DNSBL: 31.173.81.246 in (user) b.barracudacentral.org} X-KSE-AntiSpam-Info: {Found in DNSBL: 31.173.81.246 in (user) dbl.spamhaus.org} X-KSE-AntiSpam-Info: omp.ru:7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;31.173.81.246:7.1.2 X-KSE-AntiSpam-Info: ApMailHostAddress: 31.173.81.246 X-KSE-AntiSpam-Info: {DNS response errors} X-KSE-AntiSpam-Info: Rate: 59 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dmarc=temperror header.from=omp.ru;spf=temperror smtp.mailfrom=omp.ru;dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 07/08/2022 09:21:00 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 7/8/2022 6:55:00 AM X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 7/8/22 12:21 PM, Greg Kroah-Hartman wrote: [...] >>> Similar to mux and orientation switch, add a handle for registered >>> retimer to the port, so that it has handles to the various switches >>> connected to it. >>> >>> Signed-off-by: Prashant Malani >>> --- >>> >>> Changes since v2: >>> - No changes. >>> >>> Changes since v1: >>> - Relinquish retimer reference during typec_release. >>> >>> drivers/usb/typec/class.c | 9 +++++++++ >>> drivers/usb/typec/class.h | 1 + >>> 2 files changed, 10 insertions(+) >>> >>> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c >>> index 9062836bb638..f08e32d552b4 100644 >>> --- a/drivers/usb/typec/class.c >>> +++ b/drivers/usb/typec/class.c >> [...] >>> @@ -2249,6 +2251,13 @@ struct typec_port *typec_register_port(struct device *parent, >>> return ERR_PTR(ret); >>> } >>> >>> + port->retimer = typec_retimer_get(&port->dev); >>> + if (IS_ERR(port->retimer)) { >>> + ret = PTR_ERR(port->retimer); >>> + put_device(&port->dev); >>> + return ERR_PTR(ret); >> >> Why convert it to and fro, and not just return port->retimer? > > That would be a use-after-free as port might now be gone. Ah, indeed! It would also ensue an explicit pointer cast... > thanks, > > greg k-h MBR, Sergey