Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4316363rwb; Mon, 31 Jul 2023 05:15:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlE5CcCKaQkgKyBax3/MFvjhFairbQv76QoYapnumZtxUfyyweVrKUSXggb2FfIS3tAIIl3l X-Received: by 2002:a17:90a:e391:b0:268:2c60:9969 with SMTP id b17-20020a17090ae39100b002682c609969mr9363552pjz.47.1690805707331; Mon, 31 Jul 2023 05:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690805707; cv=none; d=google.com; s=arc-20160816; b=uhSVccROnQ6j/0aLLCTV52H5smF9rlvuUSQd+o+rWufOpx+12dAJRjGzejkkFDdySC 5j4shaYtQi2UDr8gRlJR5rLrPjVQ5wOGDZRrxftsa0eDHX7+J6YoMqbtKYY0FBjIBvlP uS9hid+BJJBIn8aDZuhi9aWAatoAlPIoKv5+tzbq2rYnx6KXvKKD8U5QNnpeXfACfG0X n6dEMG+iw/pJ3opnMBf52knPjXGPwg/zu9LzRVXmbrlGVAMNiegURBF4Me1XyAq1vkGV IQOfqFdR6/IZoBoisjvuuVbvwAD6gyF9mw/kFsaPS8NaxgrgJEQieRBpZOzR1cllSRVa xR7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=47eiz6FcNZ8gSioplh2M/dC1atxtxUSOYo54kCp4kA0=; fh=8y9oY1dbUo5a4c+JCQgzJsiQW3o8tzDuiALe/aM+ykY=; b=TcUAcRWwsBfyZjrk3GiSo4mk6UZXcSDPm6Qqcnfuejm//r2MH1vOlIkT19/CT6Aycv q6ZjHYSJ9S0n69kH2KN1lwn596Dw1S92D5WagVkVo2OmGU5EGH8fiibTn9/t5jvCpXm8 ma2USn+aphbTp0MVHIZhK6OOxTWvikpLjXLH1a2GWhu3sVvLaLCK9AlM2GBVRWTWIOqW Rj5ejF6E14Yz9D7e4tfxMZu/kas0gWEgxY7P5jLrUWOEXtdjx8s2Hl19oT/dqBxWs0t5 5bAwXR8pRr2pIp59llAyW4Iq8LZPqL8UYa1BGqeYA36FIsLopST9X7qJjhiXIA8lhuT1 3eSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eMVoQIbN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b1-20020a17090a6e0100b0025c1af5672fsi5965996pjk.112.2023.07.31.05.14.55; Mon, 31 Jul 2023 05:15:07 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=eMVoQIbN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231791AbjGaLGL (ORCPT + 99 others); Mon, 31 Jul 2023 07:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231737AbjGaLGK (ORCPT ); Mon, 31 Jul 2023 07:06:10 -0400 Received: from mgamail.intel.com (unknown [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B7D12A; Mon, 31 Jul 2023 04:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690801569; x=1722337569; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Ms8UFtG4oh1EAp/tG2dT3wGuSxTU49wwvkM/j/HRWIo=; b=eMVoQIbNWc+KUOxSRUxk8jw3Fz6upLzQFw5BL/wSpsZyFYh9HG0dMPSj /3M5LtdLj2AlOrSGnM2ROgv/tYo6oiVK+lmyALRtw2YfvKxpOBhB6ds60 s8vwQ0yocw4V+84UFE94tZL0XDqLe2JULZcid7m+ar1in0qoxVfAel8tw fSjgfD/Lir5WY9Z/7XQ3mQ7YDRyNibnI9sV8m5AnGyPRlEP0gbAewFBWE G0OiVcBUk2SE0HAUw+0b0apKCIidcLn7uNObu8K4LV9WpdJrMvyBCdjWl WnSx0faAwL3KBrcQyjitG/7G0E5d7gs6YgXJqbmxXVOYaBbOJ9KavF60o g==; X-IronPort-AV: E=McAfee;i="6600,9927,10787"; a="399935683" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="399935683" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 04:06:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="871643710" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 31 Jul 2023 04:06:08 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 31 Jul 2023 14:06:05 +0300 Date: Mon, 31 Jul 2023 14:06:05 +0300 From: Heikki Krogerus To: Jimmy Hu Cc: linux@roeck-us.net, gregkh@linuxfoundation.org, kyletso@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: tcpm: Add IS_ERR_OR_NULL check for port->partner Message-ID: References: <20230630065711.801569-1-hhhuuu@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230630065711.801569-1-hhhuuu@google.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 Hi, I'm sorry to keep you waiting. On Fri, Jun 30, 2023 at 06:57:11AM +0000, Jimmy Hu wrote: > port->partner may be an error or NULL, so we must check it with > IS_ERR_OR_NULL() before dereferencing it. Have you seen this happening? Maybe the partner check should happen earlier, before tcpm_pd_svdm() is even called? > Fixes: 5e1d4c49fbc8 ("usb: typec: tcpm: Determine common SVDM Version") > Signed-off-by: Jimmy Hu > --- > drivers/usb/typec/tcpm/tcpm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index 829d75ebab42..cd2590eead04 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -1626,6 +1626,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, > break; > > if (PD_VDO_SVDM_VER(p[0]) < svdm_version) { > + if (IS_ERR_OR_NULL(port->partner)) > + break; > typec_partner_set_svdm_version(port->partner, > PD_VDO_SVDM_VER(p[0])); > svdm_version = PD_VDO_SVDM_VER(p[0]); Now you will still build a response? I'm pretty sure you don't want that. Do we need to do anything in this function if the partner is lost? If not, then why not just check the partner in the beginning of the function. Or just make sure we don't even call tcpm_pd_svdm() if there's no partner. thanks, -- heikki