From patchwork Fri Aug 27 05:57:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 4236 Return-path: Envelope-to: mchehab@pedra Delivery-date: Fri, 27 Aug 2010 08:20:36 -0300 Received: from mchehab by pedra with local (Exim 4.72) (envelope-from ) id 1Oowz6-0006j3-BI for mchehab@pedra; Fri, 27 Aug 2010 08:20:36 -0300 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Fri, 27 Aug 2010 08:20:36 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Oorwz-0006n4-UF; Fri, 27 Aug 2010 05:58:06 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754072Ab0H0F5p (ORCPT + 1 other); Fri, 27 Aug 2010 01:57:45 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:59068 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752284Ab0H0F5n (ORCPT ); Fri, 27 Aug 2010 01:57:43 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw2.diku.dk (Postfix) with ESMTP id 2635619BCE7; Fri, 27 Aug 2010 07:57:42 +0200 (CEST) Received: from mgw2.diku.dk ([127.0.0.1]) by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03261-02; Fri, 27 Aug 2010 07:57:41 +0200 (CEST) Received: from palace.topps.diku.dk (palace.ekstranet.diku.dk [192.38.115.202]) by mgw2.diku.dk (Postfix) with ESMTP id F153419BCEA; Fri, 27 Aug 2010 07:57:40 +0200 (CEST) From: Julia Lawall To: Mauro Carvalho Chehab Cc: kernel-janitors@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drivers/media/video/em28xx: Remove potential NULL dereference Date: Fri, 27 Aug 2010 07:57:18 +0200 Message-Id: <1282888640-27042-2-git-send-email-julia@diku.dk> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1282888640-27042-1-git-send-email-julia@diku.dk> References: <1282888640-27042-1-git-send-email-julia@diku.dk> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Mauro Carvalho Chehab If the NULL test is necessary, the initialization involving a dereference of the tested value should be moved after the NULL test. The sematic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ type T; expression E; identifier i,fld; statement S; @@ - T i = E->fld; + T i; ... when != E when != i if (E == NULL) S + i = E->fld; // Signed-off-by: Julia Lawall --- drivers/media/video/em28xx/em28xx-video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 7b9ec6e..95a4b60 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c @@ -277,12 +277,13 @@ static void em28xx_copy_vbi(struct em28xx *dev, { void *startwrite, *startread; int offset; - int bytesperline = dev->vbi_width; + int bytesperline; if (dev == NULL) { em28xx_isocdbg("dev is null\n"); return; } + bytesperline = dev->vbi_width; if (dma_q == NULL) { em28xx_isocdbg("dma_q is null\n");