From patchwork Thu Nov 15 13:44:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 1751291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id EE734DF2AB for ; Thu, 15 Nov 2012 18:07:05 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TZ3oA-0005Zl-Dj; Thu, 15 Nov 2012 18:04:58 +0000 Received: from mail-gh0-f171.google.com ([209.85.160.171]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TYzjl-0005Ti-Hl for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2012 13:44:11 +0000 Received: by mail-gh0-f171.google.com with SMTP id r17so313741ghr.16 for ; Thu, 15 Nov 2012 05:44:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=jyx9EzqpWvEYrRRObWX0bbtqLqMgNXvk8IV21ry5khs=; b=Jc9mhUWR+maxy+y4dHVB7GHNYHa9V7fAZV42FHcyH4rE48yoQyKKexpTzP5h2WyHrj HLi6YTqt/kTsPQMnKEtpYmp6C0kzoVndpId3zjgI54GmSyR5nRtuCtgIDeTbubg640b6 X6aUdXiLhLlemdndGwIBn+b+9WkOSS4vOk8FAvuEQJBT8fxVk0zkFcUOKnHryJ94ezC2 gwTtHewAnM61yVCRRAUTR3nBEqq8PWswhvSQi+DW+n+tzZHPtCBRlH32+GiTGFeEmPC2 yqUBfBLM5RTJLEtUHvNHzAQ++7ATCbshmzQExIMGGaZe+RROEqNWsJRNb4W5xD1DZ+26 u9ww== MIME-Version: 1.0 Received: by 10.236.141.81 with SMTP id f57mr974975yhj.13.1352987047768; Thu, 15 Nov 2012 05:44:07 -0800 (PST) Received: by 10.146.138.35 with HTTP; Thu, 15 Nov 2012 05:44:07 -0800 (PST) X-Originating-IP: [122.121.51.115] In-Reply-To: <20121115083511.08f5a16f@skate> References: <1352955096.6793.1.camel@phoenix> <20121115083511.08f5a16f@skate> Date: Thu, 15 Nov 2012 21:44:07 +0800 Message-ID: Subject: Re: [PATCH 1/4] pinctrl: dove: Prevent NULL dereference if of_match_device returns NULL From: Axel Lin To: Thomas Petazzoni X-Gm-Message-State: ALoCoQmxDDmAPS09yoBBXXPd42vOkKBE8MFld2bqOrn4it3dTvy0+j2Afdv36FArmh6/X96qUGqg X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121115_084409_663933_7E494702 X-CRM114-Status: GOOD ( 15.48 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.171 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 1.7 URIBL_BLACK Contains an URL listed in the URIBL blacklist [URIs: ingics.com] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 HTML_MESSAGE BODY: HTML included in message X-Mailman-Approved-At: Thu, 15 Nov 2012 13:04:30 -0500 Cc: Linus Walleij , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 2012/11/15 Thomas Petazzoni > Dear Axel Lin, > > On Thu, 15 Nov 2012 12:51:36 +0800, Axel Lin wrote: > > of_match_device() may return NULL. > > > > Signed-off-by: Axel Lin > > Could you detail under what conditions of_match_device() may return > NULL in the specific case of this driver? This of_match_device() call > is using the same dove_pinctrl_of_match array that is used to ->probe() > this driver. So I don't see how you can get into ->probe() without > having a matching entry. > > Am I missing something? > hi Thomas, You are right. I was thinking when the case CONFIG_OF is not selected, of_match_ptr(dove_pinctrl_of_match) is NULL and of_match_device returns NULL. But this driver only works when CONFIG_OF is selected. BTW, I found there is no way to compile the dove and kirkwood pinctrl drivers. I need add below patch to compile these two drivers, how do you think about below patch? ( In dove, the USE_OF is optional, it is selected only when MACH_DOVE_DT is enabled ) Regards, Axel diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 14f8160..dda6785 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -531,6 +531,8 @@ config ARCH_DOVE select CPU_V7 select GENERIC_CLOCKEVENTS select MIGHT_HAVE_PCI + select PINCTRL + select PINCTRL_DOVE if USE_OF select PLAT_ORION_LEGACY select USB_ARCH_HAS_EHCI help @@ -542,6 +544,8 @@ config ARCH_KIRKWOOD select CPU_FEROCEON select GENERIC_CLOCKEVENTS select PCI + select PINCTRL + select PINCTRL_KIRKWOOD select PLAT_ORION_LEGACY help Support for the following Marvell Kirkwood series SoCs: