Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2013883ybz; Thu, 30 Apr 2020 09:20:17 -0700 (PDT) X-Google-Smtp-Source: APiQypKeVoR43S/YrtwDf3XKyb6P6+Dmal+Ily+oz53AFPRzU6QihY5SpHyL31KGsDX7aBjytzSB X-Received: by 2002:a05:6402:1b0b:: with SMTP id by11mr3401468edb.269.1588263617266; Thu, 30 Apr 2020 09:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588263617; cv=none; d=google.com; s=arc-20160816; b=ro0LMXuF9hyqJnboL2e2lRt0xifIdIVjEqHyC4VwoCYmwbJvqXXHeutgR1QuUQL/5R bvAiGWGKFkyJHiBjbAlj9czBx72T8B3h/eeI9VvL+x7DibM/p4lIEULHPV7FlA0s0VBR ykSwy6gXktlERiq0B1z3iJvyyqVW4nGXmyKPU3/205h3ZNRg4bUDXGqqiwL7F+gR4rKH UwAlLDyfIG85wBh/HmDqFEwOeIOO95ViCKdD0W26qcBEzCt6C3m5L38fKO5lXnB2eIHr 8Qr9mkbzLHEMax9P9UwOx8/bjR4HP84O+9/1UGuH7KTKg3Or5CYmsKSSeHaS4QaGvAxk OgHA== 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=1ywhvVtyaBoKC3XFG8v7uMK9P4ingTUxeVNCtR26SJM=; b=AIiAL2DqSp/fbEO/szQAWHS64xUnmM/PkIlm9lyVa73QFI3wPmvDYTWY58u12eJ/2y 7IAJRpL8ej7CpSw+CyESLWcbd9BHmI5I/ChTmj3H5u0BZ3hovOkjvrDbvuHS0W2X98EF iNUmwUObHA/qy5FI4xOBOLZgCE28yDyJsxxH1uKORv3jOrwkOhIbOZ3ct4/I/Cmb51tZ o5bf/9uECYF8yisneUoeF/OQ2M78+/iDw/4GlnurY71l9VhgCsw8BFHBdqKVQNX3feUC 5HKBHg2vzZs5EGiPuQSX4zKNOatFGTURJDr6ncna8M1gmkyEMxdJvab4dy51qzuBOLgU BSCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=O+Alrd3A; 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 n20si60518ejr.443.2020.04.30.09.19.53; Thu, 30 Apr 2020 09:20:17 -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=O+Alrd3A; 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 S1727778AbgD3QRP (ORCPT + 99 others); Thu, 30 Apr 2020 12:17:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726420AbgD3QRP (ORCPT ); Thu, 30 Apr 2020 12:17:15 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 798B8C035494 for ; Thu, 30 Apr 2020 09:17:15 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id k12so5481874qtm.4 for ; Thu, 30 Apr 2020 09:17:15 -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=1ywhvVtyaBoKC3XFG8v7uMK9P4ingTUxeVNCtR26SJM=; b=O+Alrd3ANyUNfJgulqXODq31NAax7hf0J5B9ih1dwg8jTcUqlXwl3faP2rQE6s4bkS foEmGBVV6mHEPsIKcA60YL2ovTfFzjVfBUgUSyme7jYnRbm4+meB3JyMVoJnZSUFa620 ce4m7nMBlWaqs0h9AZ6Vu+DY9rO/Ap9Xr8Bno= 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=1ywhvVtyaBoKC3XFG8v7uMK9P4ingTUxeVNCtR26SJM=; b=cknLU58uapVPI9u/q09K+s3J7JupFtegvpKyNH3CCvFI8HdZZNb0BH35tGD/Vp6xgh tkSqtR3eGV9MyW3vPseGfZEgR4lKSm/mTPRE71QVjyHo1zaLMyYZBa6swYAMlL/vypBK 71OH119/r4a1eymJn2v1GnNod//S7llCDKddXR4XM2noEKaHdj5XkEUGmJk2DIFGGqBM QeR7oNTHnkG2X4yLvJUmBe6FMwEVccSZoYp+0sfu3AEEjWOv/lizUinV9aWUkDnbD59h eKqWGuwLz9ydtm6O9K6zCk/Z8htripURx1FIpdd3QJDBMTpjmUzv36WSJ8137Px/WW7c WtSw== X-Gm-Message-State: AGi0PuY3zHXr6s2+dvXemMpo1YG1Tl9h9sg2G2D7WgrbkOglzFOl8LMr fMlnA8TxPjeFVP+s4GdQfx6ONc3hpkF+0IaaG/hIwg== X-Received: by 2002:ac8:746:: with SMTP id k6mr2290106qth.141.1588263434577; Thu, 30 Apr 2020 09:17:14 -0700 (PDT) MIME-Version: 1.0 References: <20200428110253.1.I926f6741079cafb04ecb592130aef75b24ad31ae@changeid> In-Reply-To: From: Prashant Malani Date: Thu, 30 Apr 2020 09:17:03 -0700 Message-ID: Subject: Re: [PATCH] platform/chrome: cros_ec_typec: Handle NULL EC pointer during probe. To: Enric Balletbo i Serra Cc: Daniil Lunev , 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 Hi Enric, On Thu, Apr 30, 2020 at 8:26 AM Enric Balletbo i Serra wrote: > > Hi Prashant, > > On 30/4/20 2:43, Prashant Malani wrote: > > On Wed, Apr 29, 2020 at 5:38 PM Daniil Lunev wrot= e: > >> > >> [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 wr= ote: > >>> > >>> Hi Enric. > >>> I encountered the issue on a Hatch device when trying running 5.4 ker= nel on that. After talking to Prashant it seems that any device with corebo= ot built before a certain point (a particular fix for device hierarchy in A= CPI 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= so. > > > > 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 for the clarification. Then, I don't think we need to upstream thi= s. This > kind of "defensive-programming" it's not something that should matter to = upstream. Actually, on second thought, I am not 100% sure about this: Daniil, is the erroneous ACPI device on a *production* firmware for this device (I'm not sure about the vintage of that device's BIOS)? My apologies for the confusion, Enric and Daniil; but would be good to get clarification from Daniil. Best regards, > > Thanks, > Enric > > > >>> 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 t= o the > >>>>> probe function which leads to NULL pointer dereference when trying = to > >>>>> send a command to the EC. This can be the case if the device is mis= sing > >>>>> or incorrectly configured in the firmware blob. Even if the situati= on > >>>> > >>>> There is any production device with a buggy firmware outside? Or thi= s is just > >>>> for defensive programming while developing the firmware? Which devic= e 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/plat= form/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_de= vice *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); > >>>>>