From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934399AbdA0LbP (ORCPT ); Fri, 27 Jan 2017 06:31:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43080 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933749AbdA0LbM (ORCPT ); Fri, 27 Jan 2017 06:31:12 -0500 Date: Fri, 27 Jan 2017 12:31:12 +0100 From: Greg Kroah-Hartman To: Shailendra Verma Cc: Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, p.shailesh@samsung.com, ashish.kalra@samsung.com, Shailendra Verma Subject: Re: [PATCH] Tty: serial - Fix possible NULL derefrence. Message-ID: <20170127113112.GA2042@kroah.com> References: <1485515773-3542-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: <1485515773-3542-1-git-send-email-shailendra.v@samsung.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 27, 2017 at 04:46:13PM +0530, Shailendra Verma wrote: > of_match_device could return NULL, and so can cause a NULL > pointer dereference later. > > Signed-off-by: Shailendra Verma > --- > drivers/tty/serial/max310x.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c > index 8a3e926..a94d147 100644 > --- a/drivers/tty/serial/max310x.c > +++ b/drivers/tty/serial/max310x.c > @@ -1323,6 +1323,10 @@ static int max310x_spi_probe(struct spi_device *spi) > if (spi->dev.of_node) { > const struct of_device_id *of_id = > of_match_device(max310x_dt_ids, &spi->dev); > + if (!of_id) { > + dev_err(&spi->dev, "Error: No device match found\n"); > + return -ENODEV; > + } Have you ever hit this with a "real" system? thanks, greg k-h