Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp929350ybt; Wed, 17 Jun 2020 18:10:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3U8B5//rjYcxnZ85iUAaTUT0qG76wF1sy8V/WKKT2gkCz7RMWbvXNQyaG9ysNHp7Qu5od X-Received: by 2002:a17:906:c452:: with SMTP id ck18mr1861365ejb.116.1592442641685; Wed, 17 Jun 2020 18:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592442641; cv=none; d=google.com; s=arc-20160816; b=V+C9mTCDWRf2klYJ+0IgDYYdA57f1vHOwlBrUrKAsZK0UObMnyxgDLT5HkbIGzniuE 27BUTyoLty99Jxy3jan7YDxhWx2iFiDXiAO5fSC9dkOT2zkwvJk0pLgAeRzR4S83hMBu 7pSO+dihblX/MpISvVsJiEiqi3MVkBJh5YFMlvLQ4CWpGBxYbdePpzqLNgHHWSNTG27b /UVWgSoBBcLzAEN/CvPL9VEjbDr/oxfqqRVo6BpZ6WnNolqmNbj+nW8kc22zDIYJJdPE 4z0V/EIiYCzpAhd2T9zkCQCqMp+KdPnIcRc6SlBK5jm7Nb3l9FXDfD07Arz2uvjvUK+f 7rKQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9US6Xe6nA7JsknZoBGlsJHcopq42cqb5eS2F5Jmivo8=; b=O51dbITqEZEUY4disHOBli4EG81P9tEBqZ2hjJry0/lqJQIUtHz9qVBweOIbRHh1L/ HEX1Ydpu4xnczxl9LBqDx17sENDoj8ezfIlIertziRRq/Y+I0mxc8Ktu+05JtZor3KhX 5Rj7iXDpUR+ZL8gQp2AnA6FUIPf/EV4NJrlnlVNF0MNtoeyYn98X82ZYi1Wk/0B7XFKj 8KPg7hCrFDiOs1K0hyR6sP8hQny50J+hZ/4u/Hzcp0rdp5/f8xFvebiOMAc8zqeWmLYr MffqRSJ/AjL/vgau11T2exykOXWnxRd0oSzjdVstutn1QvrQH9QGXgJxwZXWH669Rz4A kPCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B5kHqYEx; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z39si944382ede.374.2020.06.17.18.10.19; Wed, 17 Jun 2020 18:10:41 -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=@kernel.org header.s=default header.b=B5kHqYEx; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727777AbgFRBIW (ORCPT + 99 others); Wed, 17 Jun 2020 21:08:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:33868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727060AbgFRBIT (ORCPT ); Wed, 17 Jun 2020 21:08:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3133B2193E; Thu, 18 Jun 2020 01:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592442499; bh=dUtyJ0sPCHDAMrCFVYZk9Na/o7Im+6kdHi4WP4M/VJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B5kHqYEx7ALMHmA1Q7w/SxOqgKu6OCo9zhGe5XRfSANQs3hpxKlnPpwclu62XYHb7 r8/EMgRUFE9MU2bAJUpDpyBPxj8G8WjkGkgZNcKJx6FHxxfNU6UCjVgNqh+hidnbnM OTwMCTjDNkDb3Bfssj7sI5aV9AcDw+xNDkI2K65s= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alex Elder , Mathieu Poirier , Suman Anna , Bjorn Andersson , Sasha Levin , linux-remoteproc@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 010/388] remoteproc: Fix IDR initialisation in rproc_alloc() Date: Wed, 17 Jun 2020 21:01:47 -0400 Message-Id: <20200618010805.600873-10-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618010805.600873-1-sashal@kernel.org> References: <20200618010805.600873-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index be15aace9b3c..8f79cfd2e467 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2053,6 +2053,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); @@ -2078,8 +2079,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); -- 2.25.1