From patchwork Fri Dec 7 13:07:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10718117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8B561759 for ; Fri, 7 Dec 2018 13:08:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB6FF2E35D for ; Fri, 7 Dec 2018 13:08:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAB762E36B; Fri, 7 Dec 2018 13:08:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C6052E353 for ; Fri, 7 Dec 2018 13:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726287AbeLGNIA (ORCPT ); Fri, 7 Dec 2018 08:08:00 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:33330 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbeLGNIA (ORCPT ); Fri, 7 Dec 2018 08:08:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=S4D309UtMR+Ifs2BnnxBWbxL9F/zRbU2P6RZrdAxbwU=; b=rFJj+GA0YRRpLVUQDE3PW+qpI B5HW/UIe9R072Y8jDKaymBWB2r3YiGFaaEadCGZouYov8lmXM2B77kCCV81zl8FivqeNGZ/6EoQal SylEXFBgpQd10mOvnTqwblsQi7JMaiLvv+bfYxLX+CFIbHOef1b3tb/fmiOCIVi1HdEyc37F8Ami5 WhoQAkV6IEa24zBsMr8mq8fTgeBw9nUNXEU5kCdRKxlSb7rzC+k+QMSPMBUqgGMLVh2dtp9mrRQpU qK2nS6onp19lDIiwitciHGE6Ap8xPxj7vW/MsN4cAwfwfh7iFlR7Czj+5aoGQLaMUVSd6EvnfLRUa 2eMQXMkAw==; Received: from [179.95.33.236] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVFrK-000335-Qo; Fri, 07 Dec 2018 13:07:58 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1gVFrI-0004Pk-74; Fri, 07 Dec 2018 08:07:56 -0500 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Akinobu Mita , Masami Hiramatsu , Steve Longerbeam , Nathan Chancellor , Robert Jarzmik Subject: [PATCH 1/2] media: pxa_camera: don't deferenciate a NULL pointer Date: Fri, 7 Dec 2018 08:07:54 -0500 Message-Id: X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As warned by smatch: drivers/media/platform/pxa_camera.c:2400 pxa_camera_probe() error: we previously assumed 'pcdev->pdata' could be null (see line 2397) It would be possible that neither DT nor platform data would be provided. This is a Kernel bug, so warn about that and bail. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/pxa_camera.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c index 5f930560eb30..f91f8fd424c4 100644 --- a/drivers/media/platform/pxa_camera.c +++ b/drivers/media/platform/pxa_camera.c @@ -2396,6 +2396,9 @@ static int pxa_camera_probe(struct platform_device *pdev) pcdev->pdata = pdev->dev.platform_data; if (pdev->dev.of_node && !pcdev->pdata) { err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev, &pcdev->asd); + } else if (!pcdev->pdata) { + WARN_ON(1); + return -ENODEV; } else { pcdev->platform_flags = pcdev->pdata->flags; pcdev->mclk = pcdev->pdata->mclk_10khz * 10000;