Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1097214ybz; Wed, 29 Apr 2020 15:02:05 -0700 (PDT) X-Google-Smtp-Source: APiQypKj8RWqVbxNHVVhaazQ50HMKpDfzF70MA4oglA8XcEhGhckVwpQb0NAvXY2vQJ2XiHOaDqe X-Received: by 2002:a17:907:11de:: with SMTP id va30mr4837270ejb.121.1588197725186; Wed, 29 Apr 2020 15:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588197725; cv=none; d=google.com; s=arc-20160816; b=EAsNRfPDiLaLE+1NWBF85iJTbRu0S/IYEHgkW4j1kvjPIZKLuPUuMBfs1x9IMZck7d GHLfXvoD+9paZLlo/56U+sAghuJiu1NsBIyDPfSespaqPjrKdY+XaDuiomqdLaz3LW53 SUZy5xbSDYLzfFkm39tQomBY2rpTt012j62aV3Swi6k2sRiM5F41vsj5zRDKL70WOMvB AWncv0VtiZ2nvYExqM7LYXLfeEXtTxK6EE0pSRqryFcaOYVzReYQbh/2c3IHR75aYL+m n+wht4E41fzqPreBHQgmtngx5ni6EFtCOSLMcIAuuFVsKNPuCOyQbb/mDrn1/OocucVK RKwA== 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=YYmsHW47j6fj+qzu60zRqqeIvSFUsfZyXD/zOOb3+oA=; b=J7uNiMhzTTfwtEJU9n36wuNkqGHOjo+SypbOtLjSRQH/73M961BceSeW6t2b/8lBd6 nSFMJhSHcD6Ax5O2bBsvNWeBVgJS1dZhm887Csx2RoSYhJnWAGKLAUuzRGqmXXtSmTPI EPobI0/ngN2AMnCvl1WThxGuC38HlTxk13gRjRpK5xNQgtFVMWRQmn7Sy/aOT3nKtiXM rUqzWJdIS5XvxVXrzbFZmtgmNW8zm1LogRru81rvTLm7qTTXo0z9WA07ScN+r71Exgjy Yp1AQCIxwymLs2OzpPJq1ZBdiJS2RG50AlPsBG0Y4rVQzZeK2fIdf3WuWchhVSrmSZEz lIkQ== 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 a17si4775535edb.590.2020.04.29.15.01.41; Wed, 29 Apr 2020 15:02:05 -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 S1726887AbgD2V6L (ORCPT + 99 others); Wed, 29 Apr 2020 17:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726511AbgD2V6J (ORCPT ); Wed, 29 Apr 2020 17:58:09 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32335C03C1AE for ; Wed, 29 Apr 2020 14:58:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 655242A22CF Subject: Re: [PATCH] platform/chrome: cros_ec_typec: Handle NULL EC pointer during probe. To: Daniil Lunev , LKML Cc: Prashant Malani , Benson Leung , Guenter Roeck References: <20200428110253.1.I926f6741079cafb04ecb592130aef75b24ad31ae@changeid> From: Enric Balletbo i Serra Message-ID: Date: Wed, 29 Apr 2020 23:58:02 +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: <20200428110253.1.I926f6741079cafb04ecb592130aef75b24ad31ae@changeid> 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 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); >