From patchwork Wed Nov 8 20:50:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 118338 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5763940qgn; Wed, 8 Nov 2017 12:53:11 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q6Xzx2BooQ4k1GdjY008oIlo9gNjmPE7kPaMk1Uo8xIgzBCeDi2xT8bN7LTYLZZvwLkZLF X-Received: by 10.98.204.69 with SMTP id a66mr1791944pfg.132.1510174391171; Wed, 08 Nov 2017 12:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510174391; cv=none; d=google.com; s=arc-20160816; b=ZzI46rCaouM/4/TC7rD9cNHQPh0ygJl+XbIRN2YQLxtufsNzJNJ4gpcDG7kzoXhq7d IFXTagwH5fF0+ZGdynhPlSiS5NZENJEP6W8NBK177ngdRHFG5yWayZ0mgbsYyXumQAcA +Zia07CPEYTu1HI2HEPSQLdHs/NV8irnigDxYsWayCByVk14SbWTjVWezbYRkrTXv2ml RaCebAKaMDoKtGU8IabJtiyaME2SQT2Goa90Ry6JlRRw0VQCqSsOmezCp3ytlg57Q/Tr UWn6MVI8Xc4+pVzXvZ/8GwteU9NAwr7Hs770Am3YknHfP/JO09N+WRfFiO8S+cCWhB1y UEcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:arc-authentication-results; bh=3G1wemvjSpYfyYOkjmKBR6KoASiHJB37j4qg28HKus0=; b=GvwVcH/8YzC2l8KOmpm6gVYeGuVE3rhjGYOQc82Dgf+vu5WaBgBIOTAxDIpVm8n3Zs vRzHWwAGCnB9kw474Rvx5VZqh/Yf0EjlyS5X6svhJ56mqToELzf1LIBkJAjq2aWWniWc LQlot0LugewMR94ueAhukLtSW2Fgy7iOS/AQLpcYfHiq0g3RCcuotsIgjWoybVk+UNv6 XBh3+vHrlIoPENx/mya8xm79bd45W6pMaWzgryCH3uDvXhTmtHte9cpMcVyghpBSAVlb 8x6cVQ17Hc7u/OdUOP6+CwZHVfeA2WPaUS+q+n8ddSHwz9EYDKfnpIEMm9p9dGd/NYpI 30Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@one.verizon.com header.s=corp header.b=Hmb6Nat6; dkim=pass header.i=@verizon.com header.s=corp header.b=sFs06jkD; dkim=pass header.i=@verizon.com header.s=corp header.b=sFs06jkD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e89si4491660plb.196.2017.11.08.12.53.10; Wed, 08 Nov 2017 12:53:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@one.verizon.com header.s=corp header.b=Hmb6Nat6; dkim=pass header.i=@verizon.com header.s=corp header.b=sFs06jkD; dkim=pass header.i=@verizon.com header.s=corp header.b=sFs06jkD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752891AbdKHUxH (ORCPT + 25 others); Wed, 8 Nov 2017 15:53:07 -0500 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:34072 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752747AbdKHUxC (ORCPT ); Wed, 8 Nov 2017 15:53:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=one.verizon.com; i=@one.verizon.com; q=dns/txt; s=corp; t=1510174382; x=1541710382; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=7xOGwgntENMzxZ6sMLQfpugpn1sLDcMbJiFCIrz93vk=; b=Hmb6Nat6+82/p0dRaB/9USkpdMdA4kl+yxCMNuStOzfpIkAyMEu8F5oH 7/s2tXSOoxjy8HdUtV99SprfNsXXGbhVgHAmsmuGw0ZMEpi7dlYK0EP2P j2Xs5sUJ9iK8DjVGKJlGcpXa6JehSiNyUyOreSx9QnfGKjI6y23Jam65Y w=; Received: from unknown (HELO fldsmtpi02.verizon.com) ([166.68.71.144]) by fldsmtpe03.verizon.com with ESMTP; 08 Nov 2017 20:51:59 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi02.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Nov 2017 20:50:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1510174259; x=1541710259; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=7xOGwgntENMzxZ6sMLQfpugpn1sLDcMbJiFCIrz93vk=; b=sFs06jkDSWtwTTxu8iYhy4e3kmbWUz/hHnFygIjITUxn5QpWmCXS5x/m Talca0P9VQynX2d+c12bB5X7oApSgTCc7nzinI3S+qBxUqPIdCVKYVCgN gDB45ATiHlO1XWAm+DbN3TI4usMDSLM+BIYSpPcdFhab/YeQuoDYa15Sv M=; Received: from pioneer.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.34]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Nov 2017 15:50:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1510174259; x=1541710259; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=7xOGwgntENMzxZ6sMLQfpugpn1sLDcMbJiFCIrz93vk=; b=sFs06jkDSWtwTTxu8iYhy4e3kmbWUz/hHnFygIjITUxn5QpWmCXS5x/m Talca0P9VQynX2d+c12bB5X7oApSgTCc7nzinI3S+qBxUqPIdCVKYVCgN gDB45ATiHlO1XWAm+DbN3TI4usMDSLM+BIYSpPcdFhab/YeQuoDYa15Sv M=; X-Host: pioneer.tdc.vzwcorp.com Received: from ohtwi1exh002.uswin.ad.vzwcorp.com ([10.144.218.44]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 08 Nov 2017 20:50:59 +0000 Received: from tbwexch25apd.uswin.ad.vzwcorp.com (153.114.162.49) by OHTWI1EXH002.uswin.ad.vzwcorp.com (10.144.218.44) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 8 Nov 2017 15:50:59 -0500 Received: from OMZP1LUMXCA15.uswin.ad.vzwcorp.com (144.8.22.190) by tbwexch25apd.uswin.ad.vzwcorp.com (153.114.162.49) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 8 Nov 2017 15:50:59 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA15.uswin.ad.vzwcorp.com (144.8.22.190) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 8 Nov 2017 14:50:58 -0600 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Wed, 8 Nov 2017 14:50:58 -0600 From: "Levin, Alexander (Sasha Levin)" To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Roger Quadros , Chanwoo Choi , "Levin, Alexander (Sasha Levin)" Subject: [PATCH AUTOSEL for-4.4 01/39] extcon: palmas: Check the parent instance to prevent the NULL Thread-Topic: [PATCH AUTOSEL for-4.4 01/39] extcon: palmas: Check the parent instance to prevent the NULL Thread-Index: AQHTWNM40cORlBiRZUuTogDJzM6dag== Date: Wed, 8 Nov 2017 20:50:33 +0000 Message-ID: <20171108205027.27525-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roger Quadros [ Upstream commit 9fe172b9be532acc23e35ba693700383ab775e66 ] extcon-palmas must be child of palmas and expects parent's drvdata to be valid. Check for non NULL parent drvdata and fail if it is NULL. Not doing so will result in a NULL pointer dereference later in the probe() parent drvdata is NULL (e.g. misplaced extcon-palmas node in device tree). Signed-off-by: Roger Quadros Signed-off-by: Chanwoo Choi Signed-off-by: Sasha Levin --- drivers/extcon/extcon-palmas.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.11.0 diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index 93c30a885740..aa2f6bb82b32 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -190,6 +190,11 @@ static int palmas_usb_probe(struct platform_device *pdev) struct palmas_usb *palmas_usb; int status; + if (!palmas) { + dev_err(&pdev->dev, "failed to get valid parent\n"); + return -EINVAL; + } + palmas_usb = devm_kzalloc(&pdev->dev, sizeof(*palmas_usb), GFP_KERNEL); if (!palmas_usb) return -ENOMEM;