From patchwork Fri Mar 12 09:15:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 2926 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Fri, 12 Mar 2010 09:15:42 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Fri, 12 Mar 2010 07:13:38 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Nq0y5-0008Ej-TP; Fri, 12 Mar 2010 09:15:42 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756938Ab0CLJPk (ORCPT + 1 other); Fri, 12 Mar 2010 04:15:40 -0500 Received: from mgw1.diku.dk ([130.225.96.91]:52935 "EHLO mgw1.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756908Ab0CLJPi (ORCPT ); Fri, 12 Mar 2010 04:15:38 -0500 Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 8FC9252C40B; Fri, 12 Mar 2010 10:15:36 +0100 (CET) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XNgEc7rsEuVj; Fri, 12 Mar 2010 10:15:32 +0100 (CET) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id 42FF552C32E; Fri, 12 Mar 2010 10:15:32 +0100 (CET) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id 3485D6DFB5B; Fri, 12 Mar 2010 10:09:45 +0100 (CET) Received: by ask.diku.dk (Postfix, from userid 3767) id 1F993200B0; Fri, 12 Mar 2010 10:15:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id 17104200AC; Fri, 12 Mar 2010 10:15:32 +0100 (CET) Date: Fri, 12 Mar 2010 10:15:32 +0100 (CET) From: Julia Lawall To: "Karicheri, Muralidharan" Cc: "akpm@linux-foundation.org" , "mchehab@infradead.org" , "linux-media@vger.kernel.org" Subject: RE: [patch 2/5] drivers/media/video: move dereference after NULL test In-Reply-To: Message-ID: References: <201003112202.o2BM2HpB013125@imap1.linux-foundation.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Julia Lawall In quickcam_messenger.c, if the NULL test on uvd is needed, then the dereference should be after the NULL test. In vpif_display.c, std_info is initialized to the address of a structure field. This seems unlikely to be NULL. Test std_info->stdid instead. In saa7134-alsa.c, the function is only called from one place, where the chip argument has already been dereferenced. On the other hand, if it should be kept, then card should be initialized after it. A simplified version of the semantic match that detects this problem is as follows (http://coccinelle.lip6.fr/): // @match exists@ expression x, E; identifier fld; @@ * x->fld ... when != \(x = E\|&x\) * x == NULL // Signed-off-by: Julia Lawall Acked-by: Muralidharan Karicheri --- drivers/media/video/davinci/vpif_display.c | 2 +- drivers/media/video/saa7134/saa7134-alsa.c | 2 -- drivers/media/video/usbvideo/quickcam_messenger.c | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) -- 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/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c index 803d3e4..f0043d0 100644 --- a/drivers/media/video/usbvideo/quickcam_messenger.c +++ b/drivers/media/video/usbvideo/quickcam_messenger.c @@ -692,12 +692,13 @@ static int qcm_start_data(struct uvd *uvd) static void qcm_stop_data(struct uvd *uvd) { - struct qcm *cam = (struct qcm *) uvd->user_data; + struct qcm *cam; int i, j; int ret; if ((uvd == NULL) || (!uvd->streaming) || (uvd->dev == NULL)) return; + cam = (struct qcm *) uvd->user_data; ret = qcm_camera_off(uvd); if (ret) diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index d48c450..d3bd82a 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c @@ -1011,8 +1011,6 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip) unsigned int idx; int err, addr; - if (snd_BUG_ON(!chip)) - return -EINVAL; strcpy(card->mixername, "SAA7134 Mixer"); for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_volume_controls); idx++) { diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c index dfddef7..b2dce78 100644 --- a/drivers/media/video/davinci/vpif_display.c +++ b/drivers/media/video/davinci/vpif_display.c @@ -383,7 +383,7 @@ static int vpif_get_std_info(struct channel_obj *ch) int index; std_info->stdid = vid_ch->stdid; - if (!std_info) + if (!std_info->stdid) return -1; for (index = 0; index < ARRAY_SIZE(ch_params); index++) {