From patchwork Thu Feb 7 17:30:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10801585 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 DA6691575 for ; Thu, 7 Feb 2019 17:30:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D232E23E for ; Thu, 7 Feb 2019 17:30:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B919A2E33A; Thu, 7 Feb 2019 17:30:35 +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 5FFD52E23E for ; Thu, 7 Feb 2019 17:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726915AbfBGRae (ORCPT ); Thu, 7 Feb 2019 12:30:34 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:38874 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbfBGRae (ORCPT ); Thu, 7 Feb 2019 12:30:34 -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=I6zxVXI2yPgBYR1/Z7YaMZDL/g/YpQoVfry2/jStnG0=; b=Vx7M1d5VY0z8VWMG2B6nhyG+V iJD921w3aNeWb3754KsRmO/X8HV2HABW84fSWF9L1crxWEAGmLnrqiW+q392jfZ2dzvhmPantO+XT jzQXsbywulzw+G8PXUkV3jX02sVR0ONxlMosR1vLjaUmLeJvn9l5vNibacx7vKYdPrZzUP0i1km0d M+ZtqtwweSsaMdMn1lPBr8Sn+2uQjGUgwV8IeT2PNf4Bdp4WxzRoboTASid7NGzT20lnUaeRGHCLK QRgakwMOTRvQpCdH+Plp7Mjqirg6jDgy+v0mKg4NvTQfYMkI3MiZ1Jr0lLDeGv8mLhi4EaslnMo+g jaMij6H/w==; Received: from 177.205.88.104.dynamic.adsl.gvt.net.br ([177.205.88.104] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1grnVP-00045Y-Jv; Thu, 07 Feb 2019 17:30:31 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1grnVL-0004If-MI; Thu, 07 Feb 2019 12:30:27 -0500 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil , Ezequiel Garcia , Kees Cook , Anton Leontiev Subject: [PATCH] media: vim2m: don't use curr_ctx->dev before checking Date: Thu, 7 Feb 2019 12:30:26 -0500 Message-Id: <22f05d646df9fdb4f1ff19582f17d350665c2ea9.1549560622.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.20.1 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 It seems that it is possible that dev to be null, as there's a warning printing: "Instance released before the end of transaction" Solves this warning: drivers/media/platform/vim2m.c: drivers/media/platform/vim2m.c:525 device_work() warn: variable dereferenced before check 'curr_ctx' (see line 523) Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vim2m.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c index bfa1a2a16009..bd125ad34343 100644 --- a/drivers/media/platform/vim2m.c +++ b/drivers/media/platform/vim2m.c @@ -520,13 +520,14 @@ static void device_work(struct work_struct *w) unsigned long flags; curr_ctx = container_of(w, struct vim2m_ctx, work_run.work); - vim2m_dev = curr_ctx->dev; if (NULL == curr_ctx) { pr_err("Instance released before the end of transaction\n"); return; } + vim2m_dev = curr_ctx->dev; + src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx); dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);