Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1455139ybh; Mon, 13 Jul 2020 20:39:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy28yI9eZxQPBYFfxYFM1CuWBgXBpjdG2RWs4sCRxN7vs5CdEhOG9Y9765A2HwOebrhY3jM X-Received: by 2002:aa7:d6cc:: with SMTP id x12mr2558502edr.354.1594697996675; Mon, 13 Jul 2020 20:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594697996; cv=none; d=google.com; s=arc-20160816; b=nGFWP1s+FnFj6PMRJ0z5Ir8xNbjtl0G6KjE9WKJdMOyFkMbJ8RBbdXbuC2KIHcFPqQ qGuYBvvOt2d2IDAta2gHBV7fKRdmYT9laDIH89vxlHDzutd3VwVuPaNgSzihTHMmXHw+ eI+3wxtxwC+liCRiOQ6g5EgBUtNE8LlNxpKkaEwDzdTfBlQJIkM7k+1oW7V9QjDW7i5F +xDnUfi6yGXHbrgi3oJn6LA93+2TRIXExeFHIjcKMlgBny1zWgvc9goWup/xxAw+g92U PBzgAQFLATMUxUJQL71pdSp29NVwieSusT73cXsyBfheseIV2P1BICCH5OMmenLbZ4H4 u4NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=QRGV21zDsqgReRz8UhXO3hb4yh7SnqqrmCjjSQRfV8I=; b=d3OZZNk0GAZmvtANbRzXwvZMU7hhlRGtSKD4lFDFjBojpOt+FJGXgYM+csODk5jimq q2uHMa0HuVWxQ4foMnBN9ptUUUcRjLFVlyHmEI3S2oUoB+Kl5+0gHJeI71vtd1BuRW/F 4TR7L5kP9W6xmdYhNyc23umlvf0yetZA/j4C45njdz5hH9hL1635M27/wRI4wV2UZa0g ylcqDHnDkPHDV2b4Jl3Ca1vZYuIfiQOTs/m294ZsC9OLXqnyPJy3TfENbnol/VuyzUWa 3rK078dKLZy3ekwH2V1742+B3F6SycoQH7e3OiSFFto7Yh69vWx2ogAFYoA/k/7bjaj/ MtvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XphMBp2T; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck29si9926898edb.236.2020.07.13.20.39.33; Mon, 13 Jul 2020 20:39:56 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=XphMBp2T; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbgGNDg0 (ORCPT + 99 others); Mon, 13 Jul 2020 23:36:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbgGNDgZ (ORCPT ); Mon, 13 Jul 2020 23:36:25 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DA8DC061755 for ; Mon, 13 Jul 2020 20:36:25 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id h10so11709704qtc.4 for ; Mon, 13 Jul 2020 20:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QRGV21zDsqgReRz8UhXO3hb4yh7SnqqrmCjjSQRfV8I=; b=XphMBp2T7rn+hqKSzkbTANp5kYe95a79kEgcFT+LoKklRhZiEDcYtPZNqpe4AV2gmA MsLZ1AtT+o8cbj/r3syUri/JyYmwDfagrzEc95+MRqkmlYHUZXXQb7//kN5fzv0pl2lE Uk/S/2A90wmxcm7YYxLhvymp2CphBVmvYk0YNmn1l6MQqxZUgJv721/zruOk3mP+VszF 8JUfUqfHKkbzozRA/WuxjeLL0OQoIOsZPa+XCm0yn5mQKqwoG+uH73K+ioWE0O4GsyK4 sF6RNN4ngo6iu9K/bx7Fb8i3obmzLl50TPQiJ83t7oaQp5fOYVTGOx4J9/EtYz06EPA7 Arjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QRGV21zDsqgReRz8UhXO3hb4yh7SnqqrmCjjSQRfV8I=; b=DoGzUTPZK4MMlwMFFaG6lMt28h1ZH7UXPqS5FKP1bVFIawT+A4PfCT7Vx6aoK9V7W+ wPoAXfy9zFHceGoD/4x7JriGjiXGMGcPE/cQQBhpgbgjym3f3qhRFj1but/dO6YDMQCk AFKVSWYPElYzZhlCejHUK06VBRErwabTOlDKy9uMBXckVWp33OtyfkNBmVx8iBXxGf3d FVR4VZvuFGupKzPDYPywXIYKY+a1DxY4RpzgPVAKo23mPzWJAJaRxEJRTKeBkvY554gR tI0mLR+RH3kqyviLEj6qUkGuCqnqgp4dgWIqgHEUoHxHKnXNPpeAoj610bW90IanTa82 erIw== X-Gm-Message-State: AOAM5339GAsAiUvQpWkCurjt+c2CVMjKqlmZRkjuV0W8TWndd6Xn/YFb 7f81IEd/fd62Iw3CqgJcAyxPxVvBqRMU X-Received: by 2002:a0c:cd84:: with SMTP id v4mr2554450qvm.35.1594697784025; Mon, 13 Jul 2020 20:36:24 -0700 (PDT) Date: Tue, 14 Jul 2020 11:34:53 +0800 In-Reply-To: <20200714033453.4044482-1-kyletso@google.com> Message-Id: <20200714033453.4044482-3-kyletso@google.com> Mime-Version: 1.0 References: <20200714033453.4044482-1-kyletso@google.com> X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [PATCH 2/2] usb: typec: tcpm: Error handling for tcpm_register_partner_altmodes From: Kyle Tso To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org Cc: badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org typec_partner_register_altmode returns ERR_PTR. Reset the pointer altmode to NULL on failure. Signed-off-by: Kyle Tso --- drivers/usb/typec/tcpm/tcpm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 82b19ebd7838..a6d4b03ec250 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -1061,9 +1061,11 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) for (i = 0; i < modep->altmodes; i++) { altmode = typec_partner_register_altmode(port->partner, &modep->altmode_desc[i]); - if (!altmode) + if (IS_ERR(altmode)) { tcpm_log(port, "Failed to register partner SVID 0x%04x", modep->altmode_desc[i].svid); + altmode = NULL; + } port->partner_altmode[i] = altmode; } } -- 2.27.0.389.gc38d7665816-goog