Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3031026rwd; Wed, 14 Jun 2023 10:13:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hSbrvqO6q0L/y9IOsCIdvaOhWJ3FcrvyR2SscbZQ9PjNLMKt1+UDX+hIq/Cchbpjs2ksA X-Received: by 2002:a05:6a00:16cc:b0:646:9232:df6 with SMTP id l12-20020a056a0016cc00b0064692320df6mr3294534pfc.33.1686762830240; Wed, 14 Jun 2023 10:13:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686762830; cv=pass; d=google.com; s=arc-20160816; b=Cm1Zdg7Uvf55CJtdYcHm1pfvNBsSqXK6CFGcdFadqRhgOwNQyf2WyVBb5Z+8PwCCyX eC2LHgvDfZXZyITxqaKQFZNzMDVq9OG+XuvVVPYQdzRCOs5tzyMOamS75JYdw040U0qO JrDppf8FE8RzCxiL7QefK9Uk3Az0obu6hNu2QyQ7oAGgCEDWNLxC1dTD28lmYZxFjjt6 VeR3Y4V3uJf80oA5Ut4gQ9QJzVC25jP9awrFdqdNEtoIpJet8gLdsY2eDHLWBEYXzs5M n1fATbuijX8+H4ONeYUwn8Qh4JWe5ifaE/HLSz8MujumVfIe1KQta64Gb6MAxiPlpIgI l0VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature:dkim-signature; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=NxP14r70eB5qGXsJ+xlouX1fitPsCHvJoPYKtOXJt+uKKJktvGXXRROA+YITv6ntkW paAc9jYBEldU9NHYcnV+qnxTAmrOuz2a8oitqVqbNaYjnydTO7rDuQgXrwLDzPG5Dg7J qNtSbkbQRuf5F6eHE5ExTE1S2NE2yfScCpqHv8yOOQbsRXnz8f3XVqjTnmGSPS27TlL3 SCvZCQumtO7ulRUGHcLHaTjsIIJoxw55h8x2a7nQ8Oo8DTdGxLgJHAtW3lWEzywZL2YD CnCNn5FOMmQn3JvTg8UyGHXAbPVSggx626mHVZjKySLsE020N5kFbK9+2dT/qUdLM9Wc G9wQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gerhold.net header.s=strato-dkim-0002 header.b=JcxBcGPa; dkim=neutral (no key) header.i=@gerhold.net header.s=strato-dkim-0003 header.b=qciHgIC2; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o23-20020aa79797000000b0063b82925d69si11190464pfp.337.2023.06.14.10.13.36; Wed, 14 Jun 2023 10:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gerhold.net header.s=strato-dkim-0002 header.b=JcxBcGPa; dkim=neutral (no key) header.i=@gerhold.net header.s=strato-dkim-0003 header.b=qciHgIC2; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233926AbjFNQcR (ORCPT + 99 others); Wed, 14 Jun 2023 12:32:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjFNQcP (ORCPT ); Wed, 14 Jun 2023 12:32:15 -0400 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [81.169.146.164]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426E91A3; Wed, 14 Jun 2023 09:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686760325; cv=none; d=strato.com; s=strato-dkim-0002; b=svbPe323u+L4XXWIhtfqYnowXOJoDHc8+oHjEl5Qt7DhVydd6t1Hh+COLm1+mKS7F9 nxe9UJaA9459NAlfTLRRX3beZeEwqB4JeZv2s0zb++8hzTfq32QdppKPowfb+eonzlpj CSRkjH8EmZr0hbtAnfP+CxUJ1y0bfI4NXZjWjiNLNxqEQJ7wZT/x/9gpuv/tIneJKOrB ONWfYcRxPlGBgJ5m+iCBR/JbycDSUA9Z2u0UxSdeijjM4gMNN84giG6+To6BylzJzbPX Y3Bo747cCRFB4h9HnoaWSIBxzVnEFJXunY3yMkPOVMdDtmc9jcoxuLaaogDlM2Clw2lS K9WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1686760325; s=strato-dkim-0002; d=strato.com; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=pLWXrq/l7HJWkttzP11zi3TVWFU7s2t7O5HR6TkhIo8FwgPP0hOF62j6uYLu8P+1Or NUSI4BWpc2JIIUOMG0M+IsajVrkVIceE+yFj/ABzPuNTOW4aIYQJmQO3y9p59TceoB2i +tBu0VrHJGLo9MwDm+vMlzEyCQtMqCXWI9ijy+XJGQmXjQMMI2bCd04OQSgB6KbuUejo jYRpvwe9sWpRTDO27C3YUJXKFK+wNRnw+8HoHJyo8sfGk6UgTCoQ4cS4rQS42yk8T2cU L86gmlZ3rHV6wXr7LXuV+A/xbtxlrJrinVDsvw8w0BbSTH71rnIUU85EhlepmLfuN+Cd CunA== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1686760325; s=strato-dkim-0002; d=gerhold.net; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=JcxBcGPaZqH2eE+/LNMff7DL9IRVol6Q5Dyp5d0r1AXlaWe3GPYtFOPYuSj59zdIud Ec6NRiwXwuWG0OF75PvkU3bcrZwNZwpM3MyFinfsIqhjIn7GFzZoPtFKLswbOjvenT9F vIdutPC4AOd4HjQcwXwo6HQbVKhsbLn34Pa1XbHJxOm7wKqlACrYKVhd02tgNjYNv7P1 QshQOleyHGBj69Wyot4xm5CwD6AsM3nVXEu+nvjgfBAL8wg+MChRry1/s1RUC6LleoCm 9Nfck7F1gJt6I1Dtnbo1wPEppR7MOUNVan4H1iXToDs/NwtKU9VjsRqTZZlqZJ/LkCOt 1a5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1686760325; s=strato-dkim-0003; d=gerhold.net; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=qciHgIC2hl9TZ//hlpzHC4kgh7sXed9uT58ElvtBAAxkJk5E1j6V21RwxcAMFLGuiD f+f/EvEkWMXCH2I9OcBg== X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVOQjVd4CteZ/7jYgS+mLFY+H0JAn8u4xxmw==" Received: from [192.168.244.3] by smtp.strato.de (RZmta 49.6.0 DYNA|AUTH) with ESMTPSA id D0d0a8z5EGW50U3 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 14 Jun 2023 18:32:05 +0200 (CEST) From: Stephan Gerhold Date: Wed, 14 Jun 2023 18:31:54 +0200 Subject: [PATCH v2 1/2] remoteproc: qcom: Handle reserved-memory allocation issues MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230529-rproc-of-rmem-v2-1-95e39b959585@gerhold.net> References: <20230529-rproc-of-rmem-v2-0-95e39b959585@gerhold.net> In-Reply-To: <20230529-rproc-of-rmem-v2-0-95e39b959585@gerhold.net> To: Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Mathieu Poirier , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan Gerhold X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If Linux fails to allocate the dynamic reserved memory specified in the device tree, the size of the reserved_mem will be 0. Add a check for this to avoid using an invalid reservation. Signed-off-by: Stephan Gerhold --- New patch in v2, I wasn't aware of this until Bjorn posted a similar patch for rmtfs: https://lore.kernel.org/linux-arm-msm/20230530233643.4044823-4-quic_bjorande@quicinc.com/ --- drivers/remoteproc/qcom_q6v5_mss.c | 2 +- drivers/remoteproc/qcom_q6v5_wcss.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 70bffc9f33f6..a35ab6e860f3 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1932,7 +1932,7 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc) return 0; rmem = of_reserved_mem_lookup(node); - if (!rmem) { + if (!rmem || !rmem->size) { dev_err(qproc->dev, "unable to resolve metadata region\n"); return -EINVAL; } diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c index b437044aa126..9edab9d60c21 100644 --- a/drivers/remoteproc/qcom_q6v5_wcss.c +++ b/drivers/remoteproc/qcom_q6v5_wcss.c @@ -882,7 +882,7 @@ static int q6v5_alloc_memory_region(struct q6v5_wcss *wcss) rmem = of_reserved_mem_lookup(node); of_node_put(node); - if (!rmem) { + if (!rmem || !rmem->size) { dev_err(dev, "unable to acquire memory-region\n"); return -EINVAL; } -- 2.40.1