Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp286111rwb; Thu, 27 Jul 2023 12:43:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMiOsnBQO5s0U6X0TuVWUh8+rmRI92uZk3ykH2en7PUsgoCHp090JRt0ITEQpvVb5VBsAf X-Received: by 2002:a05:6a20:96cb:b0:134:951c:acb3 with SMTP id hq11-20020a056a2096cb00b00134951cacb3mr60938pzc.35.1690487002447; Thu, 27 Jul 2023 12:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690487002; cv=none; d=google.com; s=arc-20160816; b=senEVyxEYHBxN3/siGFRhnW54DC1Do6iGbqTTeisxvY/uVXhnOEVGGHSU7tm6tkHtZ eamUkwQyqsMBaJi3gsTvySrdRCvRjAsgPpTcONdb07ZgLtHTDKboWx1AKk6SoeP5KQxg 32/PQfZhynFQbiivpCXyJvHeEtlll7qmtvwqY/50js+vSJVtKG3kB9N4gX1vsDGOGNiC /Lgt1IPqtujqz46dHeqchuep6JBAB3KBq8RnggfSV5NwpDotYzYFg1f8t2tO4KDyMn9c woUNUqw/WAyIdWhZg39VTpCLoDLg3sX1JlG10i5VBU986I6p1SeHXX0IeIE7pWm13unE E91A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=DiDS0mChascCO6L3tr3Hz0xDTzt2hEO5MJ+iwsPLl7U=; fh=gsGVjOfIQG+9wmiC1MwOsGemedLW9+1AOXf58ARdo2k=; b=P16iGQaaFEstazRgu4ZiqVWPndaQ1gwqD9/Jdb2H5M6dlcTVvSpqkjOGU6XKD/T7Jg Dv3qc+J69TIPROnBNyco4cx+lAYf9XYGSr9mF36Oq1l1fBSukGF22MZ5FFPqlDrOufqB vGgZaUkwtVCvF3A+N/wRp3hZrnWMEb3/ypncwE2RqhT7o23q5mfivwIrXfQ0W6mOTFSB svqs7ryO3T4pLgcqENeJ+v6W60TqUuXS+hxdN66gNa33vm6ATXkqjeDBGP4pNrdiz9fL tRIf5RWLIJ7bppLgN1fDbdhOMqP8oIKxRZmDdTKT60WIYfSdPtUoOMHzjXMN4Chnj6Wk g/+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OqKw06mi; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx11-20020a056a00428b00b0067ea76a7c59si1801897pfb.50.2023.07.27.12.43.09; Thu, 27 Jul 2023 12:43:22 -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=@google.com header.s=20221208 header.b=OqKw06mi; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231233AbjG0SQW (ORCPT + 99 others); Thu, 27 Jul 2023 14:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbjG0SQU (ORCPT ); Thu, 27 Jul 2023 14:16:20 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A963530D3 for ; Thu, 27 Jul 2023 11:16:18 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-516500163b2so1317a12.1 for ; Thu, 27 Jul 2023 11:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690481777; x=1691086577; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DiDS0mChascCO6L3tr3Hz0xDTzt2hEO5MJ+iwsPLl7U=; b=OqKw06mieFE2i7Texhe7OHQzvhb6ib37GdrPTOEVqzDpVnflcRQEdAUGLqXs5nDotf 9obVCG4LmcSQGVVzMtLTO02vaJnzEX3/MPZN3ISVLwmESgeAh43kLyodB72Fob+qTKpP oNeWog1pOi9+GtH0Z9+Ce+a/yb/i/vjtN92mAcSdXKK6ytR7LUQuWBnjXENNuQlIVO+p GiKyx0qsNKgN+APrsJvS0VzdSWngL0ZF838Jqp3Br+H/5tqyZQwfOHvrRp2hJGeG2JxN LhQPUyuyGhqRToDM8Dqi7G3/NWs0LbavhI+ThoXGxk9nGs3LC2rAmS5s+FiHasYv79AH uv4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690481777; x=1691086577; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DiDS0mChascCO6L3tr3Hz0xDTzt2hEO5MJ+iwsPLl7U=; b=iVfRlb8Uq/w/YA9wtF+uUlNAGww/kfCiMosR1nFO5lCHXBlZHRZNW+hodlGX4ctVdv eC92K+0QsSuFYQYkZ+iifkgNlm0XOCEAUZ0xF1t2zc8Hlzkub/AjJw4BQIPI+zXSeGw3 5BmIvFyIEV8g7Gz2ZRTzvYU31rjou1AkUDwt3OjGKEhN8N2b/uh1q+U80A/QfqOJPEUn oaPXPdoWML+98PHbLBYtralo3ob6zwO1Tvq5V7YtVbULzTxAKdoWA5o4RBWlLOQ9pzyw 65Dsb6MgNbS5+YjNspme1HbGMSD0PJiT865nA+9yqhnSN6pBk9/bZFp1omcQ4fjWY8nc Kskw== X-Gm-Message-State: ABy/qLYdxMPf1K0bpiauv2Xk4XLUe6tAQ2ePbXr5KpUkweO03bakNsGx zf2Y2i2fvGbhHv7A4rclnb7qVWguXl1lck4KOgerBA== X-Received: by 2002:a50:d50d:0:b0:50b:c48c:8a25 with SMTP id u13-20020a50d50d000000b0050bc48c8a25mr14715edi.6.1690481777012; Thu, 27 Jul 2023 11:16:17 -0700 (PDT) MIME-Version: 1.0 References: <20230726020946.1409565-1-rdbabiera@google.com> <13b9a16f-0f26-23a4-1e2e-5b1cf9cb4070@roeck-us.net> In-Reply-To: <13b9a16f-0f26-23a4-1e2e-5b1cf9cb4070@roeck-us.net> From: RD Babiera Date: Thu, 27 Jul 2023 11:16:05 -0700 Message-ID: Subject: Re: [PATCH v1] usb: typec: bus: verify partner exists in typec_altmode_attention To: Guenter Roeck Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Tue, Jul 25, 2023 at 7:27=E2=80=AFPM Guenter Roeck = wrote: > Is this theory or actually observed ? This is actually observed. > This dereferences partner > > > + > > + if (!partner || !pdev) > > ... and then checks if partner is NULL. > > On top of that, pdev is not NULL even if partner is NULL because > adev is not the first element of struct altmode. > > In summary, this code and the check as implemented does not make > sense. Maybe partner can be NULL, but pdev will never be NULL. After looking at it more carefully, I agree on the pdev assignment and chec= k being odd. I'll follow how typec_altmode_vdm handles the NULL partner case and remove the NULL check on pdev. > > + return -ENODEV; > > > > if (pdev->ops && pdev->ops->attention) > > pdev->ops->attention(pdev, vdo); > > + else > > + return -EOPNOTSUPP; > > + > > So far this was explicitly permitted. Now it will log an error each time = it is > observed. I do not see the point of this log message; obviously it was > not intended to be considered an error, and I do not understand why it sh= ould > suddenly be one that is worth clogging the log. My rationale for logging anything is that it will make it easier to identify port partners that send Attention messages regardless of whether or not the port registers the partner Alt Mode. You're right that this is not an error= , so I will treat this case as a successful return moving forward. Then the only log generated will be for a port partner that sends Attention messages to a port that hasn't registered an altmode for it. Thanks for the feedback, RD