From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932271AbdA3TIV (ORCPT ); Mon, 30 Jan 2017 14:08:21 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:43310 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932096AbdA3TIU (ORCPT ); Mon, 30 Jan 2017 14:08:20 -0500 Date: Mon, 30 Jan 2017 19:08:10 +0000 From: Russell King - ARM Linux To: Shailendra Verma Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, p.shailesh@samsung.com, ashish.kalra@samsung.com, Shailendra Verma Subject: Re: [PATCH] Arch: arm: plat-pxa - Fix possible NULL derefrence. Message-ID: <20170130190809.GH27312@n2100.armlinux.org.uk> References: <1485752311-29754-1-git-send-email-shailendra.v@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1485752311-29754-1-git-send-email-shailendra.v@samsung.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 30, 2017 at 10:28:31AM +0530, Shailendra Verma wrote: > of_match_device could return NULL, and so can cause a NULL > pointer dereference later. Please explain how this can happen. The driver is matched to the device via the driver model looking up the compatible string in the match table: .of_match_table = of_match_ptr(pxa_ssp_of_ids), It then calls the probe function, which notices that there's a DT node pointer, and the driver looks the device up in the very same table. If the driver model found a match and then the device driver didn't for the very same device, something really bad went wrong. So, if you want to add something: if (WARN_ON(!id)) return -ENODEV; should be about it, since it's something we expect to never encounter. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.