From patchwork Tue Jun 23 19:53:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 191553 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp2305749ile; Tue, 23 Jun 2020 13:22:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8YMu00eVU0G3zPv3vJxnyCQku/qC2sq/0/Ay7xUY8lpS7H2HUmGAxFFWB/WmUhVcRTzgW X-Received: by 2002:aa7:d054:: with SMTP id n20mr23280331edo.344.1592943745532; Tue, 23 Jun 2020 13:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592943745; cv=none; d=google.com; s=arc-20160816; b=R1lWMW00DGtPaqzHkVz5YneBJpp/3K0rsRvqG6lMvgzn4+VTolchmFunR9rgA9chiw XXRI7IcqQcrZPKIiifKcrRImjQUEC/Iq5w4K0chiwfqZ8FwZf4Tf5Gh2gPVCkYSopkXd 2uNH4KCiHlX+6HfL7PxgOd89BPyFsMyL9TMZteIIQey4am/uyDTvmDkkBccc2BoHiGfE B2vttlRqS3S/XstO+1Be99gQfjV1yt8wGvsgMwyHXFxuupGMSuLmQKKKSPetlc9c/DxM BXfjDZdjndSS+rfo9P3ZcGyEWU7IBonu9BB4bs+AjEON3Kmew8HHwWZ8cZxRk2rf6zjz Qwlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MFG9eKLbCcS/tdy4pwQ9BQ6eoivwFZGM3AKs0BLENtM=; b=JLx5/bIS2WyogMs5h5KdvjNmRYvgvcfQ8n+d1HHnAXUGLl9QNilitTe+FlqG03NlQd tI1t0W3TlyU05P0wXQygL3QbqeDptNOXwFqDwgvHp0FpUb3zM1WCfj9mvtshBeOWDEHJ R09g+gSXG6WYy3x0OqDwaI+BligeTlXxg/ec4oHeFX7M6tzW1Kp2e8WpysIXGGix/E31 s/swrifu7JMgpzRWLdtqFFHHKczHAbejN08mTJNytoco7IH0d1a+yiqdVnMGDMBesXKg onixRA/wQ5e0YOOQZTc1pK0zfvut9B8hZ0LcGH5OFY4005vPXBQoCSg05iK4Z59ZpmOX bW2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YdItPIm0; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t25si11765618edq.407.2020.06.23.13.22.25; Tue, 23 Jun 2020 13:22:25 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@kernel.org header.s=default header.b=YdItPIm0; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389617AbgFWUWX (ORCPT + 15 others); Tue, 23 Jun 2020 16:22:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:40266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389898AbgFWUWW (ORCPT ); Tue, 23 Jun 2020 16:22:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 EA1042064B; Tue, 23 Jun 2020 20:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943742; bh=iH08VnW3uKA0g3AvFh8w+vi2WfhazxAAViYMCsS7Izo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdItPIm0xRBa91oCT71M4hFMUNunUPbfK8JgeKOTBa3XfIfI9uUtMH4G5ftTrfr9j 02X3jV0kghq7bteEJOD/bi8lWE5nRuEndp1gDlDmfGlSgyVn68j+Q2rjjTX9fJ/js+ ar06lGSOxAYvIYRrXHgq9OSYpg1s3glTpxwBXSmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Elder , Mathieu Poirier , Suman Anna , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.4 007/314] remoteproc: Fix IDR initialisation in rproc_alloc() Date: Tue, 23 Jun 2020 21:53:22 +0200 Message-Id: <20200623195339.144198310@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@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: Alex Elder [ Upstream commit 6442df49400b466431979e7634849a464a5f1861 ] If ida_simple_get() returns an error when called in rproc_alloc(), put_device() is called to clean things up. By this time the rproc device type has been assigned, with rproc_type_release() as the release function. The first thing rproc_type_release() does is call: idr_destroy(&rproc->notifyids); But at the time the ida_simple_get() call is made, the notifyids field in the remoteproc structure has not been initialized. I'm not actually sure this case causes an observable problem, but it's incorrect. Fix this by initializing the notifyids field before calling ida_simple_get() in rproc_alloc(). Fixes: b5ab5e24e960 ("remoteproc: maintain a generic child device for each rproc") Signed-off-by: Alex Elder Reviewed-by: Mathieu Poirier Reviewed-by: Suman Anna Reviewed-by: Bjorn Andersson Link: https://lore.kernel.org/r/20200415204858.2448-2-mathieu.poirier@linaro.org Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/remoteproc/remoteproc_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0896b3614eb11..ce92ae227aa10 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2036,6 +2036,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, rproc->dev.type = &rproc_type; rproc->dev.class = &rproc_class; rproc->dev.driver_data = rproc; + idr_init(&rproc->notifyids); /* Assign a unique device index and name */ rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL); @@ -2060,8 +2061,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, mutex_init(&rproc->lock); - idr_init(&rproc->notifyids); - INIT_LIST_HEAD(&rproc->carveouts); INIT_LIST_HEAD(&rproc->mappings); INIT_LIST_HEAD(&rproc->traces);