From patchwork Mon Apr 23 11:02:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10356787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29CE2601D3 for ; Mon, 23 Apr 2018 11:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B8152856B for ; Mon, 23 Apr 2018 11:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FFD428A6D; Mon, 23 Apr 2018 11:03:08 +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=-6.4 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,URIBL_RHS_DOB 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 7C0992856B for ; Mon, 23 Apr 2018 11:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755003AbeDWLCu (ORCPT ); Mon, 23 Apr 2018 07:02:50 -0400 Received: from osg.samsung.com ([64.30.133.232]:55784 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754984AbeDWLCr (ORCPT ); Mon, 23 Apr 2018 07:02:47 -0400 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id F14133D65E; Mon, 23 Apr 2018 04:02:45 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com Received: from osg.samsung.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NURnac9cz4TB; Mon, 23 Apr 2018 04:02:43 -0700 (PDT) Received: from smtp.s-opensource.com (177.18.30.209.dynamic.adsl.gvt.net.br [177.18.30.209]) by osg.samsung.com (Postfix) with ESMTPSA id 7CD483D653; Mon, 23 Apr 2018 04:02:43 -0700 (PDT) Received: from mchehab by smtp.s-opensource.com with local (Exim 4.90_1) (envelope-from ) id 1fAZF3-00011E-8I; Mon, 23 Apr 2018 07:02:41 -0400 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH] media: em28xx: Don't use ops->resume if NULL Date: Mon, 23 Apr 2018 07:02:39 -0400 Message-Id: <875ca4eae7623e3f54acb2fd364404491b78951d.1524481357.git.mchehab@s-opensource.com> X-Mailer: git-send-email 2.14.3 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 Changeset be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality") introduced a potential NULL pointer dereference, as pointed by Coverity: CID 1434731 (#1 of 1): Dereference after null check (FORWARD_NULL)16. var_deref_op: Dereferencing null pointer ops->resume. var_compare_op: Comparing ops->resume to null implies that ops->resume might be null. 1174 if (ops->resume) 1175 ops->resume(dev); 1176 if (dev->dev_next) 1177 ops->resume(dev->dev_next); Fixes: be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality") Signed-off-by: Mauro Carvalho Chehab Acked-by: Sakari Ailus --- drivers/media/usb/em28xx/em28xx-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index 36d341fb65dd..0cefd29184f6 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c @@ -1171,8 +1171,9 @@ int em28xx_resume_extension(struct em28xx *dev) dev_info(&dev->intf->dev, "Resuming extensions\n"); mutex_lock(&em28xx_devlist_mutex); list_for_each_entry(ops, &em28xx_extension_devlist, next) { - if (ops->resume) - ops->resume(dev); + if (!ops->resume) + continue; + ops->resume(dev); if (dev->dev_next) ops->resume(dev->dev_next); }