Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp595887pxk; Thu, 3 Sep 2020 07:52:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzbz9POEgiq9WKi/BE6rVIwkZYWiQPs896BfPvD0pVlYTzeZ8BCR755PqDwZYuWDoh56z/ X-Received: by 2002:a17:906:b7d1:: with SMTP id fy17mr2595788ejb.391.1599144765980; Thu, 03 Sep 2020 07:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599144765; cv=none; d=google.com; s=arc-20160816; b=sAXKuFCqbsQI69M8FeufknqJ5x2cwMewBA+qkRDGXfp0wsv5nKC4FN1WJrvrEXvuDM ylUo+Rw3fFBaqC9aZ8sM1Ms1OCAMCKxXFnxJ2Z2pMn0Rcfm9q9ToD0mu6zwO8K2Lxp4B vEcF1zPJkSb0hpg9HfUIA8H24ShQPQDZs6s0vFTHCmiDcnqnDfmuslZ30Ph6RJPg2Kl7 YY/mS93/G2wxfBW8RhHHJCGLjmFljUEAaSF/d04bvY3skg0rQVUJhNdfGRk7MaKgdIMK f/RaYNEAfh0SgH18qRpj/6DpA3jlF+Yuh8pUReWMFLoUB2bwFKQ4RL8u21RVawhpwo37 +edA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=1FPRhJoWjqG8+gQHE9bU9UzjjoLvgSrA9NVzRzJ0CRg=; b=jmAqrZFGfpZvmsN5Q4GGUW/vAPaNJfMV96mceP3hP+Dy28+7GLpwh4Vmpp9SM2WITp B/ZBvDEog2uRwQohKqrAerGF55CdBLTOTQROZf2Lh2BHfOlO7emTzGiIcEcN4YCf3nru QBYudcDXzpHIjnBoC3L3kBksKl/IH0DxzSXO5KD+MkTcfrG/a3gXZIsNCaW0J0QKmNXG 91S+81faWLZTkA42sZVR6qxzTfVRf6UssUDtXytLrpltgULCdCkliDpkxlc+HRqwBszp TWNx84vRlbWrbEEJqH3BlhwsANGAiNDrj1r7dx0R+oe3z/+gBYyG0ELWO5VdBtt8p43M Jvow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bwZHjocM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay11si1845687edb.517.2020.09.03.07.52.22; Thu, 03 Sep 2020 07:52:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bwZHjocM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729228AbgICOvn (ORCPT + 99 others); Thu, 3 Sep 2020 10:51:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56117 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729235AbgICOvC (ORCPT ); Thu, 3 Sep 2020 10:51:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599144652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=1FPRhJoWjqG8+gQHE9bU9UzjjoLvgSrA9NVzRzJ0CRg=; b=bwZHjocMavLi9635e/4H2ZjfWApHbYtQf11fLMJFXBO3Y9pNHihcq1wPxdRp5lQfUjsjXs VjH+RQMSjGkL6sx7IcJFh2rA3bWl4LfIbiV+3ah67WBDGldlv5ssxgcnoliYkK2aT2rcSB sxD733l5Vbym583cJJ/V6LLOOnruFPE= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-2RS48A1dNlSrJRLMPFoWYg-1; Thu, 03 Sep 2020 10:50:48 -0400 X-MC-Unique: 2RS48A1dNlSrJRLMPFoWYg-1 Received: by mail-il1-f198.google.com with SMTP id f132so2466820ilh.16 for ; Thu, 03 Sep 2020 07:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1FPRhJoWjqG8+gQHE9bU9UzjjoLvgSrA9NVzRzJ0CRg=; b=fjZ8FF1Pw0ud1QImOyi5vuM4X/jpJUsMr6vqt5oYaTbb9iPWroX7qT4pYVF0r6nXOY BbPOAec58vZhD5YpxxXnU63DBcKEDl+INtx7aCHyJ0/+FW5qZ+b78jIotT6KXFoFg+HU cfSWQB/zPJxk8qcxtRH9SzPMJoLLdcARS9L7JEaBXe7o0eAmcFescvY0dVijXVOJPTer pI9CgGUAbARqQE+gUNTdrgHcZ9eRF10Fx0zGbvnUXPUU74OFalGtAfEBu5srHaWu5/Oi +eKgpw/NyyufLw/gy9L0O3QjSxrKdiMxHr+zmM4LwPMJbPZ/em4VxI/3RCY14E0JvPUd IaIA== X-Gm-Message-State: AOAM531BNCCMCLJM7cPfhlGbWig2VYMdxkfUbEKeg/G2etmyB3+kJlEx x/HsJb/AF45G22uioZywJJzvJZWAy3PfRJ/sVqVI309DXWDub2BWzlphprRxvMyAlUqy/amkjCt DYi2o8CxhkOi2v1+Uv3sZSAkL X-Received: by 2002:a5d:8042:: with SMTP id b2mr3475470ior.60.1599144648123; Thu, 03 Sep 2020 07:50:48 -0700 (PDT) X-Received: by 2002:a5d:8042:: with SMTP id b2mr3475460ior.60.1599144647939; Thu, 03 Sep 2020 07:50:47 -0700 (PDT) Received: from trix.remote.csb (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id c7sm1515541ilk.49.2020.09.03.07.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 07:50:47 -0700 (PDT) From: trix@redhat.com To: mchehab@kernel.org, natechancellor@gmail.com, ndesaulniers@google.com, brad@nextdimension.cc, mkrufky@linuxtv.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Tom Rix Subject: [PATCH] media: em28xx: fix function pointer check Date: Thu, 3 Sep 2020 07:50:38 -0700 Message-Id: <20200903145038.20076-1-trix@redhat.com> X-Mailer: git-send-email 2.18.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix clang static analyzer reports this problem em28xx-core.c:1162:4: warning: Called function pointer is null (null dereference) ops->suspend(dev->dev_next); ^~~~~~~~~~~~~~~~~~~~~~~~~~~ This is the problem block if (ops->suspend) ops->suspend(dev); if (dev->dev_next) ops->suspend(dev->dev_next); The check for ops->suspend only covers one statement. So fix the check consistent with other similar in the file. Change a similar check in em28xx_resume_extension() to use consistent logic as its siblings. Fixes: be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality") Signed-off-by: Tom Rix --- drivers/media/usb/em28xx/em28xx-core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index e6088b5d1b80..d60f4c2a661d 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c @@ -1156,10 +1156,11 @@ int em28xx_suspend_extension(struct em28xx *dev) dev_info(&dev->intf->dev, "Suspending extensions\n"); mutex_lock(&em28xx_devlist_mutex); list_for_each_entry(ops, &em28xx_extension_devlist, next) { - if (ops->suspend) + if (ops->suspend) { ops->suspend(dev); - if (dev->dev_next) - ops->suspend(dev->dev_next); + if (dev->dev_next) + ops->suspend(dev->dev_next); + } } mutex_unlock(&em28xx_devlist_mutex); return 0; @@ -1172,11 +1173,11 @@ 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) - continue; - ops->resume(dev); - if (dev->dev_next) - ops->resume(dev->dev_next); + if (ops->resume) { + ops->resume(dev); + if (dev->dev_next) + ops->resume(dev->dev_next); + } } mutex_unlock(&em28xx_devlist_mutex); return 0; -- 2.18.1