Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3538531ybz; Mon, 27 Apr 2020 18:04:53 -0700 (PDT) X-Google-Smtp-Source: APiQypI0b1JE6pkW35UWkXAKkPTATUGOQKBhzgLGUZ1brd9BPXrvZKPtUR9J3NrL7EjUQSEqhCJU X-Received: by 2002:a50:f61c:: with SMTP id c28mr19582740edn.365.1588035892975; Mon, 27 Apr 2020 18:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588035892; cv=none; d=google.com; s=arc-20160816; b=FfoYIe2k1EI/iJplgrBOodCUgeLc4YhZfR/e0L0o/gy627IyXBmJNhHjbXNGTydfjl be0h/k22EK7IKxn+EwpVcZU1kzjVwVlhcKBoHCPTCus0mHJaqaVxUxU7UjEOYib4i0rp RxZjPCvtXL905bsb/HVASNN8S57rSrNtUjFq54MdGG/kK+bcxG/chQBcTqcnaPZXl0MK F8v9HvYVOdmPpgKId8oB8ARLOa89osLKS5uIXTKGhjlMsceGcQ8X4YpgkfePmVX3vkAZ yxlf2tqNfXL/5EtdfHrS9Pkec/uz/4sAPGGtzIzUNkVF0SO8bBjGZ2827srgMK3fOE6G 1yTA== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1KP0Ez7hKSnKb+povEU3BzAbH8Pt0yNwSNaVttztrRk=; b=oAIWkdcwzaItbT9QI4aWwOSsf61ejHqNkhAWFxpV0pielm5OsFioh9gI0y+U5Sng3u IJ4wzuYZ+6s4iAInRVm5jH9ra6RvqzfoKMVdm2mrHhEgXLJ2YJLUVWNpYV3UabPRXeL0 88+O6XFijpLV/mlDMqZC1+TpDOGGW28wtfidc0rrgz44vrtbvWqpxQMZtcQJOatmcMth IMQfhEeSNeLzJnfW1lNk1UR9NbL0xhzd8nNP7EQ+cyoSaKad9g9IkDSgy+UgmNjLkITi ZUAY7w+PEnKa371zQ9/QrytEZWWLj1wqx9ABlOpFQylZ6SaTC++Ca8DSQfgGndthaA/5 HYEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CHcQb9jd; 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 o15si802374eju.289.2020.04.27.18.04.29; Mon, 27 Apr 2020 18:04:52 -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=CHcQb9jd; 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 S1726309AbgD1BDE (ORCPT + 99 others); Mon, 27 Apr 2020 21:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726263AbgD1BDD (ORCPT ); Mon, 27 Apr 2020 21:03:03 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0A81C03C1A8 for ; Mon, 27 Apr 2020 18:03:03 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a7so381587pju.2 for ; Mon, 27 Apr 2020 18:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1KP0Ez7hKSnKb+povEU3BzAbH8Pt0yNwSNaVttztrRk=; b=CHcQb9jdYyP6gCgFKoXSog75I+fwwXi8tHwq3opxqfLD6dG55Dk+bqbxAE6/DC0LAL h7jn1mQIl6kqwVpYNyXzUYgmpWsue1PASrSuim/H5yEzov1PrhYU3ZaWEWKGUA2Lrvsp Os2oC73xaWQfiRX49BC2SQKEUbSVbIG6AdZIU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1KP0Ez7hKSnKb+povEU3BzAbH8Pt0yNwSNaVttztrRk=; b=Ot3kGVUHQrscm4YvQDenXE762YwCd15ap/P5oyc/Y5LXNFDEAA8qRDSvMkfEwJQwWj QT3ghl+tUOT7nTEF9OJYa7hlc+5tDz0hGLsISggMRoGD2LGaLyU/VFD/c5Qw88UImLJM Cqi8YqiEVF29/aqLdDzOYjD2UwsGAH+d0AFDOivs/elAQBzuNkZoNZIZ/wEjF2hEqujk M5XO08jQO4jirRJeBbwLs2wVAc7MWKjbfPacOSrCp8VZexmOtGB4MEcJpaYphONXscQd X1HcucyKOc0rlImAWV3FDuOUhn7DRSnYkaT2jRvWHWkGGSif9g6EyJqfjyNP1vjwSRzA Ntxg== X-Gm-Message-State: AGi0PuaQ60vqgzYmuiYIdusMfc93cBzMUc2FLkkhS5em/VTzhKJK2fsX NdlgfszaU4ELzy5CHdftIfsWyecz3Vc= X-Received: by 2002:a17:90b:2388:: with SMTP id mr8mr1765611pjb.107.1588035783213; Mon, 27 Apr 2020 18:03:03 -0700 (PDT) Received: from dlunevwfh.Home (n1-43-86-194.mas2.nsw.optusnet.com.au. [1.43.86.194]) by smtp.gmail.com with ESMTPSA id q6sm9392922pfh.193.2020.04.27.18.03.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2020 18:03:02 -0700 (PDT) From: Daniil Lunev To: LKML Cc: Prashant Malani , Daniil Lunev , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH] platform/chrome: cros_ec_typec: Handle NULL EC pointer during probe. Date: Tue, 28 Apr 2020 11:02:56 +1000 Message-Id: <20200428110253.1.I926f6741079cafb04ecb592130aef75b24ad31ae@changeid> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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); -- 2.24.1