Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2708708pxf; Sun, 4 Apr 2021 11:15:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+Bods3puvGiMTEpnUA2BHrtEo36U1I/UZ6zc1vGiP7yJB/vknFRXHHOS5zt1yfC238s++ X-Received: by 2002:aa7:db15:: with SMTP id t21mr27547435eds.145.1617560117786; Sun, 04 Apr 2021 11:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617560117; cv=none; d=google.com; s=arc-20160816; b=cK/8V/mVC95ylNa+xQZmSbabQ+taCkVRb2TEEVTx85ksKgAuDUZ7+mtp01Rq1brtD8 KlQGohvB81GmJO2WggN0AKmYEL7N2jSUEwxDg9NJTp/4kGjOSQ85KCCE9Q3xKo2ycC0Z qKDegSTkU7VRt3uSIzS/rxkMgPBJf/VsSYxscAPpqGO0iDUFyxGeyWYGhWLgJQzLasbF gkskSXfsBEvY5uKfC+KPpYS6lHBgY5VUaEnvc8WiKx739PBeBi0FtAi3JCAAlGvLUmVi H4uH9Z5QjbrcBeOJeuk1DszY+HSTPgie+LRFLyDtubcRxIK+TlBv5LYC18p6HJO4vgZ+ RKLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=xWTlAky7gDSnURtzqEYV1IdtzF7FFHKQZXqUxL/jz2I=; b=nCpGpF7OWmyB93KHPEY4FSNfpidPnD9B7t9ec4vryrVC5CHSlljDs0Hha2NB2rfXa2 w6CPbeoEPfwacW1QrQ2Fh+V+aEQdTjm6KNweA8GQTHNzS3BFXp0wHAnq6aZ19sdECHvD k+9mfQpvX9T189q6E7lDs9+aYn0iNXmFDrwzxiyXYuOtaUkPPTUe/HxicNMFD/nBPYnr iYyDzDn/0yPDuL5rZYRVabTK+X3op3sZWvdrig8CeG0ikPFgQqEtrmNE/BHtKeS+xra5 Gla3Di4xLsGG0AbRR0NgBS7htu4scQYd4og1Cyr26kvnxjn30ApUvZK/GrJ1WIXgfXZm rX1w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si12921662ejd.203.2021.04.04.11.14.55; Sun, 04 Apr 2021 11:15:17 -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; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbhDDSOY (ORCPT + 99 others); Sun, 4 Apr 2021 14:14:24 -0400 Received: from fgw23-7.mail.saunalahti.fi ([62.142.5.84]:63240 "EHLO fgw23-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbhDDSOY (ORCPT ); Sun, 4 Apr 2021 14:14:24 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id 911d8938-9571-11eb-8ccd-005056bdfda7; Sun, 04 Apr 2021 21:14:16 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Daniel Scally , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab Subject: [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices Date: Sun, 4 Apr 2021 21:14:09 +0300 Message-Id: <20210404181409.1451026-1-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we continue, due to device is disabled, loop we have to drop reference count. When we have an array full of devices we have to also drop the reference count. Note, in this case the cio2_bridge_unregister_sensors() is called by the caller. Fixes: 803abec64ef9 ("media: ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver") Cc: Daniel Scally Cc: Sakari Ailus Signed-off-by: Andy Shevchenko --- drivers/media/pci/intel/ipu3/cio2-bridge.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c index c2199042d3db..85f8b587405e 100644 --- a/drivers/media/pci/intel/ipu3/cio2-bridge.c +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c @@ -173,14 +173,15 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, int ret; for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) { - if (!adev->status.enabled) + if (!adev->status.enabled) { + acpi_dev_put(adev); continue; + } if (bridge->n_sensors >= CIO2_NUM_PORTS) { + acpi_dev_put(adev); dev_err(&cio2->dev, "Exceeded available CIO2 ports\n"); - cio2_bridge_unregister_sensors(bridge); - ret = -EINVAL; - goto err_out; + return -EINVAL; } sensor = &bridge->sensors[bridge->n_sensors]; @@ -228,7 +229,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, software_node_unregister_nodes(sensor->swnodes); err_put_adev: acpi_dev_put(sensor->adev); -err_out: return ret; } -- 2.31.1