From patchwork Fri Jan 24 09:29:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33C5AC32771 for ; Fri, 24 Jan 2020 09:56:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F041420709 for ; Fri, 24 Jan 2020 09:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579859765; bh=ZgCg7PwdWQQ51VpUPtQrqvjOkoDFiL+F8qHs3fwrhZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pQZWwhmnaeRK8Ub1nzzz3BWEiXwJqff1+QJl6YkIz5GKzy3jikEu+ii0CKkz7MJXj u1CgwLJf83Een51Tg9b+oeu1H641iekiHYvmJ4voyNy0DyeD4Q8JCAPb0HZln1KGmS kvO/qS+ZEsu8JXvK4/zxwI6qkP7dSwOyRps+2Jxk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730735AbgAXJ4E (ORCPT ); Fri, 24 Jan 2020 04:56:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:59710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731830AbgAXJ4E (ORCPT ); Fri, 24 Jan 2020 04:56:04 -0500 Received: from localhost (unknown [145.15.244.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8040A20718; Fri, 24 Jan 2020 09:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579859763; bh=ZgCg7PwdWQQ51VpUPtQrqvjOkoDFiL+F8qHs3fwrhZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yLY4CAJidnsgwumtYMCTrilncvprKB3+9l6kH3M7B0SuK+4r/LQccEnCOR1ku1m7c IzSIbN9TgLFhI7wGIj6g1IBBE545GbBnufHgCGDPkavaifdQFpYgVLOstSrVmru92g zXfFmrQMa7HWfv/IoN+0MAP4XG2q030csJhAtTNY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YueHaibing , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 155/343] media: tw5864: Fix possible NULL pointer dereference in tw5864_handle_frame Date: Fri, 24 Jan 2020 10:29:33 +0100 Message-Id: <20200124092940.367465716@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124092919.490687572@linuxfoundation.org> References: <20200124092919.490687572@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: YueHaibing [ Upstream commit 2e7682ebfc750177a4944eeb56e97a3f05734528 ] 'vb' null check should be done before dereferencing it in tw5864_handle_frame, otherwise a NULL pointer dereference may occur. Fixes: 34d1324edd31 ("[media] pci: Add tw5864 driver") Signed-off-by: YueHaibing Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/tw5864/tw5864-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c index e7bd2b8484e3d..ee1230440b397 100644 --- a/drivers/media/pci/tw5864/tw5864-video.c +++ b/drivers/media/pci/tw5864/tw5864-video.c @@ -1395,13 +1395,13 @@ static void tw5864_handle_frame(struct tw5864_h264_frame *frame) input->vb = NULL; spin_unlock_irqrestore(&input->slock, flags); - v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf); - if (!vb) { /* Gone because of disabling */ dev_dbg(&dev->pci->dev, "vb is empty, dropping frame\n"); return; } + v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf); + /* * Check for space. * Mind the overhead of startcode emulation prevention.