Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1962758ybz; Thu, 30 Apr 2020 08:28:31 -0700 (PDT) X-Google-Smtp-Source: APiQypJHTp//TMJ3QfQJFv+KVRKI35BWgC6ZirpFjoSjHgLOKKj1EOIghMs2M/WdWXfns3oo2XHM X-Received: by 2002:a50:9e6a:: with SMTP id z97mr3032526ede.375.1588260511547; Thu, 30 Apr 2020 08:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588260511; cv=none; d=google.com; s=arc-20160816; b=lbDpNDa+WQHpICHAdAikcUaO5zfCsyzoO/sRFblLVFoyzC2eohXRYlhEZKrzahMYh1 uNKnFjMLsLZ/GmmZUVnV9RJ0F5vl+hiURbvu2wUYoalJ7TAB5oyC7iC8IQEXEM116KlX JPnLGqUfX9LjyhUz5fVxjyof0v5RUaRz6rvkqh5cN2bbG53/B8vE45WonqWYVVX9u5IT GCsufYLLBNeVvUBZQozA03XNZd71EBGvzblWVeJiOKzNI1sqAvS53hhvDbtX7Rn5Kiq7 pW5arF5XVHMsltf0WaSciRmYxlDKmABbzB1+LEJ5MwkVv+v7Su+S78QsHlmjADcBBlwH 10gA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=T8/J70ZzZhDiXtVH3XMIr+tMKHCv6lq2drOkHmy3A5Y=; b=MuaNYnF7yqgCFmtOvTvLD09d5Sfzy62wI74fxVsDIgmRRQ60YjdqzvBklsr4XuMMi9 tJZXJYREDdyqhZAnRRBaGSzDByXFEGKZrg05kG+Onvf1bQ/Y9KT2OIla8pI8eBPB/cJn SCtY6Ot3G63RJ5mQlnxuQQ+6hRFuDZDmSNSf7corLR6HMvtP6+a6toQXtzHNRj4Crn/q z8OplLRjWBSCn46EIRJ5A/UFNrammnRCa9dJoAJaFK3c0OlTMgbFGZ39UQh8/+YTUCyA 2kk0u+Q2wLruiPAdDEgdz2nmR1V1PaIe0Jujsr+nLwTfvliJkBtkZfUMaHiSWYTHM3pi Woqw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e2si6008158edr.204.2020.04.30.08.28.07; Thu, 30 Apr 2020 08:28:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbgD3P0o (ORCPT + 99 others); Thu, 30 Apr 2020 11:26:44 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49392 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgD3P0o (ORCPT ); Thu, 30 Apr 2020 11:26:44 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 156592A297F Subject: Re: [PATCH] platform/chrome: cros_ec_typec: Handle NULL EC pointer during probe. To: Prashant Malani , Daniil Lunev Cc: LKML , Benson Leung , Guenter Roeck References: <20200428110253.1.I926f6741079cafb04ecb592130aef75b24ad31ae@changeid> From: Enric Balletbo i Serra Message-ID: Date: Thu, 30 Apr 2020 17:26:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prashant, On 30/4/20 2:43, Prashant Malani wrote: > 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 kernel 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 ACPI 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 this. This kind of "defensive-programming" it's not something that should matter to upstream. 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 to 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 missing >>>>> or incorrectly configured in the firmware blob. Even if the situation >>>> >>>> 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/platform/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_device *pdev) >>>>> >>>>> typec->dev = dev; >>>>> typec->ec = 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 = cros_typec_get_cmd_version(typec); >>>>>