From patchwork Thu Aug 19 10:00:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 4220 Return-path: Envelope-to: mchehab@pedra Delivery-date: Thu, 19 Aug 2010 07:05:45 -0300 Received: from mchehab by pedra with local (Exim 4.72) (envelope-from ) id 1Om20H-0006Tr-Ip for mchehab@pedra; Thu, 19 Aug 2010 07:05:45 -0300 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Thu, 19 Aug 2010 07:05:45 -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 1Om1vr-0007oZ-NT; Thu, 19 Aug 2010 10:01:11 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751397Ab0HSKBI (ORCPT + 1 other); Thu, 19 Aug 2010 06:01:08 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:65229 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751206Ab0HSKBH (ORCPT ); Thu, 19 Aug 2010 06:01:07 -0400 Received: by eyg5 with SMTP id 5so1065050eyg.19 for ; Thu, 19 Aug 2010 03:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=P9WCmckiQZ3XT25buftF85Fr1D2t4hvd3wnZ3V9XeVE=; b=fSO/dLy46DDWwj40mlENBUdOWJHx1PmIK6E0C27KtFg+PwqiZe4rXVh2iLo0kcVGYe YLbvBF3Th2Q15gA/9Yb7LgadUxPOInx4lZtwgZEjIUFu5IEXJHouAUMJJDb9RWEm4SPc m3BW/4EgEjtoUKHdknj5IrsjLjG9VF61dX3T4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=qxBScMpc6VAzVBktCw8jbqTwXuVNoGVVXqjcXi1SV7QXa6rao4FWt3q3oEqHHQZKcG iIPbLnr0zxL2bZT08yi/B7pFONxxPGsj/ebc+S2cpUyJ1OWqJ+MX0Ip9Q6W1dy0ADPAF WNrrbo2eLCe0gXDLjPC1B446iEOEeFv+HRxCM= Received: by 10.216.6.201 with SMTP id 51mr364079wen.110.1282212065861; Thu, 19 Aug 2010 03:01:05 -0700 (PDT) Received: from bicker ([41.205.146.22]) by mx.google.com with ESMTPS id j1sm872050wej.15.2010.08.19.03.00.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Aug 2010 03:01:05 -0700 (PDT) Date: Thu, 19 Aug 2010 12:00:22 +0200 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Steven Toth , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] V4L/DVB: saa7164: move dereference under NULL check Message-ID: <20100819100022.GA6674@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Mauro Carvalho Chehab The original code dereferenced "port" before checking it for NULL. I moved the test down below the check. Also I changed the comparisons a little so people wouldn't get confused and think "port" and "buf" were ints instead of pointers. (Probably that's what lead to this issue in the first place.) There is only one caller for this function and it passes non-NULL pointers, so this is essentially a cleanup rather than a bugfix. Signed-off-by: Dan Carpenter --- 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/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c index 5713f3a..ddd25d3 100644 --- a/drivers/media/video/saa7164/saa7164-buffer.c +++ b/drivers/media/video/saa7164/saa7164-buffer.c @@ -136,10 +136,11 @@ ret: int saa7164_buffer_dealloc(struct saa7164_tsport *port, struct saa7164_buffer *buf) { - struct saa7164_dev *dev = port->dev; + struct saa7164_dev *dev; - if ((buf == 0) || (port == 0)) + if (!buf || !port) return SAA_ERR_BAD_PARAMETER; + dev = port->dev; dprintk(DBGLVL_BUF, "%s() deallocating buffer @ 0x%p\n", __func__, buf);