Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp260041pxa; Wed, 26 Aug 2020 09:51:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/JCd1yT8+SGQ72aH3dWMiFJuZ1yzzi+ESt580jfOA+jOgpRlT+0U4Y9xQ+vjbFNOjz9kh X-Received: by 2002:a17:906:71c7:: with SMTP id i7mr16020532ejk.245.1598460677302; Wed, 26 Aug 2020 09:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598460677; cv=none; d=google.com; s=arc-20160816; b=R6GcZxr2XCUf9PuZxn3P6f0XuLqOEOTLwhQuC4ogTPxgaSGTwnj8iebatFRvBW9fbH Yf8jkbOrnk04Br0YMWYEgfo56T932eYx1ZJxZGK1dvibVMYvI6u+VQf8BKAUpD3ZRSag THPaxGEXggscaDEptHPkHvGn1nbTp+NejSM4cXqHab9zvmT2+6kI2BYNo278/UBnMguZ 4o5dwrZsuZ0LUDpHITlVbAUilnRkdD4xZd6q27vNzlrp0+EWHpKpcsTPkQNapjhNsccr TGFExwcueqRzFSZLSloi7hHSMPDcS1PH2kXT/43fADEkQLigdKIcY8/mK08uzxTJWLgb 7rBg== 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=jCF/a0xKIWqbt7wIUY8AEgGbHy28w20HVJLneFBKefA=; b=LB+zQlsse//oNxLwZuULZuuoh8JYk0WHISWBDcIEtyvZOjD+uAKFIyrK4lRXU9k1hG CALdaSdU08QQIQwXyM9jz431ocsLxv90AGAd9tTFKrnwukt3z0naaA/RokVB8mmia2CE eA2LxR2Y4X/397V5O3/UP9rEOyHr6hueXvStYUWDzoRpCBArBCfo255fDGipeKwgATCo h4fIYJqWL9ApJqplb40NnMPOU+uCPkw3tBXhlbgC5M6HC6ohovO1ab8ay8R/LFn+vVFw qHUWct1jL8TzaWL2p6K27ae//OhBhKMlpixUWrVFQtJzWDU0Qy916jtjxY/QbcLldNa1 Pf6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f9AZkUF8; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g64si1799544ede.153.2020.08.26.09.50.54; Wed, 26 Aug 2020 09:51: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; dkim=pass header.i=@linaro.org header.s=google header.b=f9AZkUF8; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728153AbgHZQtE (ORCPT + 99 others); Wed, 26 Aug 2020 12:49:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726929AbgHZQpe (ORCPT ); Wed, 26 Aug 2020 12:45:34 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF597C0613ED for ; Wed, 26 Aug 2020 09:45:32 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id a8so940010plm.2 for ; Wed, 26 Aug 2020 09:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jCF/a0xKIWqbt7wIUY8AEgGbHy28w20HVJLneFBKefA=; b=f9AZkUF8HwjIrp6vPGOuGK5/BZQ33xA15gaimxyXyvQqbYPMj/aTBZyE79upHJXcyx g0QJuEEu5J6Y1FHXlnQhPuuAeC0D40IYRf81gM2IaC7kqLRVpFie8Eft3ETUodKI4Clk fRWIkJmznBpF/DtjU6iC04NjhKCfy5PL4vbyxzu7KGSFFTf45esVto7O31wAJ1QzCFxa /XgqHeg+eK0QHle+WRUMi9uCgz70vNlJh3foE2Ey/zxfILokqIfynvcBv4K3fwOIaWFq g0+3JbAgzeAoP34ux82szDlXvf3kv6Cp7FfXZBQtWFPAL8uOb7k8zLrJo3hPsaj2QDTA MTOA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jCF/a0xKIWqbt7wIUY8AEgGbHy28w20HVJLneFBKefA=; b=MF3na+JKHkxCI9ANY8qpK4l5bEuwYqXRTlvXNIjO2sR/juGd0wED5tR2WjwofIi+fA MQMz7M7iZG7Iz2KfXCAXn30vQn4lyIz9ogNYcFaYHxXokJ+cRNg1PQHPQHC5OIrAt+dY j4AbzoY2rVp+vw9S5133Tbn69+CiteRWLlkjJqzlF4vlU0x2hpEXRIONm2hDSUV5IlGU aIW+pHnLU/qKih/GPHiifTKyaKaRCMeAyYaqBga8aDq6xBLxphR0G4nxXKPlL503pZW5 ii8g5Ei7pzj38kZyOCMHN0R4tTDmfdRmBCiejGZg63rynK3G9hIhHuvDhqk2Sh5RWpBQ SLeg== X-Gm-Message-State: AOAM5301STz0GRYhCpTgORGGVZvCkh7noajuGLbY+I4z8Vlpx+iw4ocp s+enZd9yYB/k6lbbTCEwWkMfwg== X-Received: by 2002:a17:902:b28b:: with SMTP id u11mr3741410plr.117.1598460332525; Wed, 26 Aug 2020 09:45:32 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:32 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/13] remoteproc: Re-check state in rproc_shutdown() Date: Wed, 26 Aug 2020 10:45:17 -0600 Message-Id: <20200826164529.224476-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The state of the remote processor may have changed between the time a call to rproc_shutdown() was made and the time it is executed. To avoid moving forward with an operation that may have been cancelled, recheck while holding the mutex. Cc: Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7f90eeea67e2..fb2632cbd2df 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1834,6 +1834,9 @@ void rproc_shutdown(struct rproc *rproc) return; } + if (rproc->state != RPROC_RUNNING) + goto out; + /* if the remote proc is still needed, bail out */ if (!atomic_dec_and_test(&rproc->power)) goto out; -- 2.25.1