From patchwork Wed Nov 8 20:50:55 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: 118339 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5792536qgn; Wed, 8 Nov 2017 13:23:11 -0800 (PST) X-Google-Smtp-Source: ABhQp+RFJK/0A6oSS3nyaciq0jIe3hlkR0C9dESULbFg8GA6f1wkdFKyuSxiet6Vb69toyGrgq5F X-Received: by 10.101.90.133 with SMTP id c5mr1677248pgt.441.1510176190968; Wed, 08 Nov 2017 13:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510176190; cv=none; d=google.com; s=arc-20160816; b=lIMliaes6/0I/9BymHI8vXrWFVr3ODLBcM/CBfX10hVV7dAytYMAZwZLiuPivydU6k v4BW/oelEW35iK97ZIgHTYTNbe4Or08kJ5O4phPSFXINXlVFqtS8hTv8eKi4xROZw8/D Vko2/pctQvMCQC03eBRrlSg1wegURK2Y3IdMfBtAsVVeZPvzeIYPji3FzMv+g6PsptGz AhsS0DT12jbg+DLjh5c1MmiAAI36UDR7WhPzX4i5/RgTRlKuIlR8dQeLOeiLjuuXSEsO oewYCzPspioeDW/QqcvBxQCt0Csl+mP2hEUozPpRXnj5tEzotEkbNjCuajMLKOyix+wj J9Gw== 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=m+Gh8Ne8HTagB0zQr9lR0cI/SIRZAv9LdwqkX9W4YUk=; b=Dz5zXDMZM5r2pXGMMIsmwuceZLze2GJtbSYdo/OqxR9kp6t00ehtFxgosCq6LtszmK pfgjXUfEGQpLG/YyOgKRyLh4p/O498VOKn87HV+mGJR9g9XmPpCzdOqU/lGNhJkVj+Y0 vnW/fW707D1NC4Ln4PjoKEvbnteQJs1kkopDNU40ibN8S9bGK4tR9gUTBBwHl2OV5+ol YdneI6akCbcAVv9UwvkBc6E071fnb4Jq3xMnvxejedsp8vmZn1c2r0GvN34NTNaFmYYg M9SLLYz5NS0C8PEl+inpnyFqX9TexN9g7/SvxeKpSyGoclT/l76zyA4MtcHwfaMcjHAf GUqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@one.verizon.com header.s=corp header.b=T1BIWib8; dkim=pass header.i=@verizon.com header.s=corp header.b=ljPCI5dT; dkim=pass header.i=@verizon.com header.s=corp header.b=ljPCI5dT; 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 y68si2344426pfk.100.2017.11.08.13.23.10; Wed, 08 Nov 2017 13:23:10 -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=T1BIWib8; dkim=pass header.i=@verizon.com header.s=corp header.b=ljPCI5dT; dkim=pass header.i=@verizon.com header.s=corp header.b=ljPCI5dT; 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 S1753514AbdKHVXJ (ORCPT + 25 others); Wed, 8 Nov 2017 16:23:09 -0500 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:34076 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752856AbdKHUxE (ORCPT ); Wed, 8 Nov 2017 15:53:04 -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=1510174384; x=1541710384; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=0tKATBS0DLyy6MNZO5RbUrlcOp5WUXe3ZVZQDTEcAnA=; b=T1BIWib8hEL6Hglxa7Hg08m8iEz5+koQIVLSOlHUTf4FSYg+YR1BToLu iOApEO9HHq1CmV/Zm4IwRWaRo15nPBkq3rT68DmKQ/m8lFdGme8leTUHg HFZbWW/ODCulLewW+aXSv+DMnVUkMQmhkRaI9gRtf6cd9YMr9+etBs9fI 8=; Received: from unknown (HELO fldsmtpi01.verizon.com) ([166.68.71.143]) by fldsmtpe03.verizon.com with ESMTP; 08 Nov 2017 20:53:02 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO atlantis.verizonwireless.com) ([10.255.192.101]) by fldsmtpi01.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Nov 2017 20:52:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1510174344; x=1541710344; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=0tKATBS0DLyy6MNZO5RbUrlcOp5WUXe3ZVZQDTEcAnA=; b=ljPCI5dTw5oS1I+3wqXfUxUiVsuVCn6t8a5BS2vecis7SSxC8cJ8J++C +4i5xOU8LpEWk9u8nKk7GPgPoyg9QGhKH8HFrTudQl9UgfdaXMVPG5gvt +jtcudSSt5taAzp5kU5sg4beyQWK+0br3MQqcYx1LUseQ91AZsHb79ldk U=; Received: from mariner.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.84]) by atlantis.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Nov 2017 15:52:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1510174344; x=1541710344; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=0tKATBS0DLyy6MNZO5RbUrlcOp5WUXe3ZVZQDTEcAnA=; b=ljPCI5dTw5oS1I+3wqXfUxUiVsuVCn6t8a5BS2vecis7SSxC8cJ8J++C +4i5xOU8LpEWk9u8nKk7GPgPoyg9QGhKH8HFrTudQl9UgfdaXMVPG5gvt +jtcudSSt5taAzp5kU5sg4beyQWK+0br3MQqcYx1LUseQ91AZsHb79ldk U=; X-Host: mariner.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 08 Nov 2017 20:52:24 +0000 Received: from tbwexch16apd.uswin.ad.vzwcorp.com (153.114.162.40) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 8 Nov 2017 15:52:24 -0500 Received: from OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) by tbwexch16apd.uswin.ad.vzwcorp.com (153.114.162.40) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 8 Nov 2017 15:52:24 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 8 Nov 2017 14:52:23 -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:52:23 -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-3.18 01/27] extcon: palmas: Check the parent instance to prevent the NULL Thread-Topic: [PATCH AUTOSEL for-3.18 01/27] extcon: palmas: Check the parent instance to prevent the NULL Thread-Index: AQHTWNNFAzuFt/0TnUeVpH+C7gVFiA== Date: Wed, 8 Nov 2017 20:50:55 +0000 Message-ID: <20171108205049.27612-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 230e1220ce48..1cee9f4909db 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -150,6 +150,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;