Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1295572pxb; Fri, 21 Jan 2022 14:38:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwecOHH9OdBrRL5Q9emhngUDEskQG7/KqQfS1/8UKIGkuEXIcMArpDGd1TTBIqr86eSm5Er X-Received: by 2002:a05:6a00:1a87:b0:4c4:ff65:749 with SMTP id e7-20020a056a001a8700b004c4ff650749mr5303279pfv.32.1642804715119; Fri, 21 Jan 2022 14:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642804715; cv=none; d=google.com; s=arc-20160816; b=m7e+AdxE+HDcukZ5tDtsD+ao2GgeP+bLRnbnPUbp5I2HjecLOTFeCh8KMz/OIE2na1 xmJKiJqLNHEkCFiSuqlC3usiGRsJPCbg0v4bpZyurIYejYGgOf0yTTeLIDmjsnAAD9E6 2LTfnU9BK2kzsDeTPR7YLYoUzByUMQ2nU/EwSA40ROFLT5FSgx0Md2ZU+vxjJSZcJVVp lXl5LaQgn/a49gqsQBLNi0bMoAQ8ZVvvPSax4ssU+1ToZHv8fNCAkHKLNaHZlsTwVwE1 IN2K5MfVDxekal/4kK9xJM6g7SAhyqrMT4naqCRLB9HHqr0/34ZWjqmu+woY/nAkIoAA CbKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EVkemQwZkoxm+9DhleE/PjTxXOeu2kwjkp28PcOXQIQ=; b=HUW7O+EAfbvmKl46VAwXw9CK725EA4AlMfVTeJkVZG25pirrWRNvvumJX9K8+xiZHO kSgIQxFBw7AJl/F8L/WZTbXQ9ZJw1YuLLXLYFYceLznnG4A3nvtbocj3LI8KY+7I/h84 CLhi0X5+BZj0jOMDXq/ihb/NraJUIuXe8V3w8N2Bz1gAuyOerVl1KkrnDHjg8uR8oczu PNC4G+StA4lrJWG6OmvTpVl3IS+R9yHH7kaHdzFavG2R9w7NrQOKS1Wok6FmQ65p9YdL SYI7BWbG+gFei9RlL+HRZckvSG9HKaVzlVlcMQ1w7AHpUHC9FubB2qkljgiEeMmwCdzL szoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="laCM5sW/"; 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=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si7305984pgj.203.2022.01.21.14.38.23; Fri, 21 Jan 2022 14:38:35 -0800 (PST) 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=@quicinc.com header.s=qcdkim header.b="laCM5sW/"; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377726AbiATUpR (ORCPT + 99 others); Thu, 20 Jan 2022 15:45:17 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:15503 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347336AbiATUpQ (ORCPT ); Thu, 20 Jan 2022 15:45:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1642711516; x=1674247516; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EVkemQwZkoxm+9DhleE/PjTxXOeu2kwjkp28PcOXQIQ=; b=laCM5sW/NsIIwxggza5RvTCP5WAFxSa974qEL7d0BEeDSUKylB66/sk2 hjCYNE6+Ax7Tsyeqveglb4alyD4NppcpPcJ8y6nMVIdAMwuing3eUX8qp A2Q1g6U2qucypkJbhFKqleQHqHbdQ+7sLWAA3dEXeLbNBiVY1Rj0fsGv/ k=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 20 Jan 2022 12:45:16 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2022 12:45:16 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Thu, 20 Jan 2022 12:45:16 -0800 Received: from hu-amelende-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Thu, 20 Jan 2022 12:45:15 -0800 From: Anjelique Melendez To: CC: , , , , , , , Anjelique Melendez Subject: [PATCH 3/3] input: misc: pm8941-pwrkey: avoid potential null pointer dereference Date: Thu, 20 Jan 2022 12:41:37 -0800 Message-ID: <20220120204132.17875-4-quic_amelende@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220120204132.17875-1-quic_amelende@quicinc.com> References: <20220120204132.17875-1-quic_amelende@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Collins Add a null check for the pwrkey->data pointer after it is assigned in pm8941_pwrkey_probe(). This avoids a potential null pointer dereference when pwrkey->data->has_pon_pbs is accessed later in the probe function. Change-Id: I589c4851e544d79a1863fd110b32a0b45ac03caf Signed-off-by: David Collins Signed-off-by: Anjelique Melendez --- drivers/input/misc/pm8941-pwrkey.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 0ce00736e695..ac08ed025802 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -263,6 +263,10 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) pwrkey->dev = &pdev->dev; pwrkey->data = of_device_get_match_data(&pdev->dev); + if (!pwrkey->data) { + dev_err(&pdev->dev, "match data not found\n"); + return -ENODEV; + } parent = pdev->dev.parent; regmap_node = pdev->dev.of_node; -- 2.34.1