From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751808AbdA3KAq (ORCPT ); Mon, 30 Jan 2017 05:00:46 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:35115 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbdA3KAa (ORCPT ); Mon, 30 Jan 2017 05:00:30 -0500 MIME-Version: 1.0 In-Reply-To: <1485752113-29581-1-git-send-email-shailendra.v@samsung.com> References: <1485752113-29581-1-git-send-email-shailendra.v@samsung.com> From: Geert Uytterhoeven Date: Mon, 30 Jan 2017 11:00:28 +0100 X-Google-Sender-Auth: UjZcX58JbuhZCKxqMRXRjbJ0g2s Message-ID: Subject: Re: [PATCH] spi - Fix possible NULL derefrence. To: Shailendra Verma Cc: Mark Brown , linux-spi , "linux-kernel@vger.kernel.org" , p.shailesh@samsung.com, ashish.kalra@samsung.com, Shailendra Verma Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shailendra, On Mon, Jan 30, 2017 at 5:55 AM, Shailendra Verma wrote: > of_match_device could return NULL, and so can cause a NULL > pointer dereference later. Can it? The driver uses DT exclusively. There is no legacy platform code creating "mxs-spi" platform devices. > Signed-off-by: Shailendra Verma > --- > drivers/spi/spi-mxs.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c > index 5b0e9a3..c3aea7e 100644 > --- a/drivers/spi/spi-mxs.c > +++ b/drivers/spi/spi-mxs.c > @@ -470,6 +470,11 @@ static int mxs_spi_probe(struct platform_device *pdev) > */ > const int clk_freq_default = 160000000; > > + if (!of_id) { > + dev_err(&pdev->dev, "Error: No device match found\n"); > + return -ENODEV; > + } > + Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds