Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1233006ybz; Wed, 29 Apr 2020 17:45:26 -0700 (PDT) X-Google-Smtp-Source: APiQypJoNfTBP9PT9R0CscJMXT6QFaonIEMEw9bk6B/GR6COjy0RYQmNAP2C5lHqTKk+RVqG/3RB X-Received: by 2002:aa7:c0d2:: with SMTP id j18mr520106edp.283.1588207526498; Wed, 29 Apr 2020 17:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588207526; cv=none; d=google.com; s=arc-20160816; b=M3wmUArBhDZdBgLMo0eqd5F3XIkNzDjIT31qPnvZD2CvUbHuNLGQgUI0+DuF36i9YP 4tvw9gnHy0uDyIwL5U0vGchz6i0c8uL5jiR39OQfphtlqoa0nRylHvBMj1M7p1lvF91b h+Hy0kl3nCPESQt98mjjnvPF82Ty5sl905s/Z4MF41mwTA2ScS/IAMEVeOrPJ8MX18hl sdhJepcwyWvxjTETxDdVKFZfB5H2nmzeT9plQmiAjaxgcGME5c7vvFsNWOiMa0lpSQaL VkumtD0RCdlm1lBJpAKHiGE5dSgMV23Cc3pZVHfhr7PqZ/Q3/OBwblX79Ohrd6SYwXtA JqRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5o/Er+M3stuv2s1188l/Kps5H4ED2pxcg+ddDdjlJ8s=; b=zAs1528lPCclrdNYZ8v2xm8xlMaueXbEcDdS7JACdVdXZIqWvs4YZJwRoBruwwlXZ5 UXaiLez1OeT6hKq6fKC9aTXc6Qv9Nr0Sq6to12QAW2o/oghHEZ7CXlmRV5uVhGM9l0iC IGJfOgqwZm88XvM30YZei3g2v6Z3cJB3hkn/IjNHJWyTJXe7MUEsu0Gnm+sm3TuYxPsk M0JuVeeEFyN80Z2rIPeTqmxi6cjxA3HkSbDd+oE2f1bjCW0ikJjNs/lyrtPtNjtyripR +XzCYD0SKB5VT7YjynFJNFybky0VFrTxsYuNDruPYKGdCEQCtvaGqwzDpkx0RHK7/EIc 1NVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FfcNmeqW; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si4916228ejx.386.2020.04.29.17.45.03; Wed, 29 Apr 2020 17:45:26 -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=@chromium.org header.s=google header.b=FfcNmeqW; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgD3Ang (ORCPT + 99 others); Wed, 29 Apr 2020 20:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726309AbgD3Ang (ORCPT ); Wed, 29 Apr 2020 20:43:36 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E687C035494 for ; Wed, 29 Apr 2020 17:43:36 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id p13so2162230qvt.12 for ; Wed, 29 Apr 2020 17:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=5o/Er+M3stuv2s1188l/Kps5H4ED2pxcg+ddDdjlJ8s=; b=FfcNmeqWBWruARuFzkjgHZp3rrglu4upXfmDX/X6a498J/M1Mk3viO7rgpCGJ7t+4Q vZGnmJY3pETS04ZqmDDAe7FUs9rLNh/pCKEiUWg9nLn+w4W6lG/ao5iziap0KeMoV62w v3k8wdfAU4IsuqT3rybNFITNCePP8UlBKxdIA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=5o/Er+M3stuv2s1188l/Kps5H4ED2pxcg+ddDdjlJ8s=; b=VOzLXcBQUR6el8JGN6xuVu9UMY9/hU5rQ1MaJb5jLSuSirnnw021m0AURaX4lEfHr1 OikUdXZS5rdUwecSLNZdM6szPBn3sGsiE42OY8Q84U0mVI8nHBZDXWcUC3SNhmCwO2ZB dwnlregSKkKYnspmEQR26M4m/ioz6Bx+hV4iw9G6ZUB8zGcG9YoR0lRF9/sl0I1+z0Ni Mzc+zmE6hEt5eOzTd8pgvd2hV9qiLK7bYvTxdzsDnVaESQEqixYc+PN5cKxo4r9wxp4S jpRqMnFsEJM76JVwqrlt+Exm4exJldBj+OkNfkPdHy7D+qtWYap6efoH5EgnnK0/PsgU WIcg== X-Gm-Message-State: AGi0PuaxDgYPlKSBfKyOKDuAELIk0LDV07yw8Gp9LApZ6MVyKjNuTPMX TmaLs+2Gj+j8oweu5WfHLWEM95tmOnZefuqrVH4RJUxU X-Received: by 2002:a05:6214:150f:: with SMTP id e15mr593521qvy.18.1588207415260; Wed, 29 Apr 2020 17:43:35 -0700 (PDT) MIME-Version: 1.0 References: <20200428110253.1.I926f6741079cafb04ecb592130aef75b24ad31ae@changeid> In-Reply-To: From: Prashant Malani Date: Wed, 29 Apr 2020 17:43:24 -0700 Message-ID: Subject: Re: [PATCH] platform/chrome: cros_ec_typec: Handle NULL EC pointer during probe. To: Daniil Lunev Cc: Enric Balletbo i Serra , LKML , Benson Leung , Guenter Roeck Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 29, 2020 at 5:38 PM Daniil Lunev wrote: > > [to make it appear on the mailing list as I didn't realize I was in > hypertext sending mode] > > On Thu, Apr 30, 2020 at 10:11 AM Daniil Lunev wrote= : > > > > Hi Enric. > > I encountered the issue on a Hatch device when trying running 5.4 kerne= l on that. After talking to Prashant it seems that any device with coreboot= built before a certain point (a particular fix for device hierarchy in ACP= I tables of Chrome devices which happened in mid-April) will not be able to= correctly initialize the driver and will get a kernel panic trying to do s= o. A clarifying detail here: This should not be seen in any current *production* device. No prod device firmware will carry the erroneous ACPI device entry. > > Thanks, > > Daniil > > > > On Thu, Apr 30, 2020 at 7:58 AM Enric Balletbo i Serra wrote: > >> > >> Hi Daniil, > >> > >> Thank you for the patch. > >> > >> On 28/4/20 3:02, Daniil Lunev wrote: > >> > Missing EC in device hierarchy causes NULL pointer to be returned to= the > >> > probe function which leads to NULL pointer dereference when trying t= o > >> > send a command to the EC. This can be the case if the device is miss= ing > >> > or incorrectly configured in the firmware blob. Even if the situatio= n > >> > >> There is any production device with a buggy firmware outside? Or this = is just > >> for defensive programming while developing the firmware? Which device = is > >> affected for this issue? > >> > >> Thanks, > >> Enric > >> > >> > occures, the driver shall not cause a kernel panic as the condition = is > >> > not critical for the system functions. > >> > > >> > Signed-off-by: Daniil Lunev > >> > --- > >> > > >> > drivers/platform/chrome/cros_ec_typec.c | 5 +++++ > >> > 1 file changed, 5 insertions(+) > >> > > >> > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platf= orm/chrome/cros_ec_typec.c > >> > index 874269c07073..30d99c930445 100644 > >> > --- a/drivers/platform/chrome/cros_ec_typec.c > >> > +++ b/drivers/platform/chrome/cros_ec_typec.c > >> > @@ -301,6 +301,11 @@ static int cros_typec_probe(struct platform_dev= ice *pdev) > >> > > >> > typec->dev =3D dev; > >> > typec->ec =3D dev_get_drvdata(pdev->dev.parent); > >> > + if (!typec->ec) { > >> > + dev_err(dev, "Failed to get Cros EC data\n"); > >> > + return -EINVAL; > >> > + } > >> > + > >> > platform_set_drvdata(pdev, typec); > >> > > >> > ret =3D cros_typec_get_cmd_version(typec); > >> >