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; From patchwork Fri Dec 7 13:07:55 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: 10718119 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 C644413AF for ; Fri, 7 Dec 2018 13:08:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D890D2E353 for ; Fri, 7 Dec 2018 13:08:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC9F72E436; 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 6DF082E35B for ; Fri, 7 Dec 2018 13:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbeLGNIB (ORCPT ); Fri, 7 Dec 2018 08:08:01 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:33332 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbeLGNIA (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:References:In-Reply-To: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:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mYGu2l8QdCYHQuBk0O4Sq+QGUtkkmRuGS2DOrLSjq9U=; b=m1TEadZVOvFlj5p+fsr0vmN7sH 3Q+kQcFhPaD94czMGxPv3cUmD691zVpCbm2TdOAaLFM8ctGkCIwcFBl5WXDo285XMubv0tz93A7yE DZ4PAgrDGRyjtCblyzK3fc9oJ/dc6rDUXmGU8IkmjrBhHQmqElbc2IoJkDRd/hUct3oIQL9DPjyfL KI2Uxe1x5K9P+LA3Tmbys6wDrp54WYGa9TwaUfDuV9JPynCh0t9ow+shsbBvckn+WRAnjaQB+HIO6 /8dVCMk281IvKHTC+U8jtbdKNta9chCb8qk28DAuK+ZwvfAWMTrN1D2MS0ecYqR7nPKn86mlv0/KC 5/mN6WQA==; 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-000336-Qp; Fri, 07 Dec 2018 13:07:58 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1gVFrI-0004Pn-7r; Fri, 07 Dec 2018 08:07:56 -0500 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Peter Rosin , Wolfram Sang , Nick Desaulniers Subject: [PATCH 2/2] media: drxk_hard: check if parameter is not NULL Date: Fri, 7 Dec 2018 08:07:55 -0500 Message-Id: <94488f55b92ab1567dfeaf1fffb12fecc8c0b1d0.1544188058.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: References: 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 There is a smatch warning: drivers/media/dvb-frontends/drxk_hard.c: drivers/media/dvb-frontends/drxk_hard.c:1478 scu_command() error: we previously assumed 'parameter' could be null (see line 1467) Telling that parameter might be NULL. Well, it can't, due to the way the driver works, but it doesn't hurt to add a check, in order to shut up smatch. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Nick Desaulniers --- drivers/media/dvb-frontends/drxk_hard.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index 84ac3f73f8fe..8ea1e45be710 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -1474,9 +1474,11 @@ static int scu_command(struct drxk_state *state, /* assume that the command register is ready since it is checked afterwards */ - for (ii = parameter_len - 1; ii >= 0; ii -= 1) { - buffer[cnt++] = (parameter[ii] & 0xFF); - buffer[cnt++] = ((parameter[ii] >> 8) & 0xFF); + if (parameter) { + for (ii = parameter_len - 1; ii >= 0; ii -= 1) { + buffer[cnt++] = (parameter[ii] & 0xFF); + buffer[cnt++] = ((parameter[ii] >> 8) & 0xFF); + } } buffer[cnt++] = (cmd & 0xFF); buffer[cnt++] = ((cmd >> 8) & 0xFF);