From patchwork Fri Apr 3 17:50:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 189756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A754C2BA12 for ; Fri, 3 Apr 2020 17:50:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5A072080C for ; Fri, 3 Apr 2020 17:50:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WjEZli5Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbgDCRuO (ORCPT ); Fri, 3 Apr 2020 13:50:14 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:42953 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404156AbgDCRuN (ORCPT ); Fri, 3 Apr 2020 13:50:13 -0400 Received: by mail-qk1-f193.google.com with SMTP id 139so8894883qkd.9 for ; Fri, 03 Apr 2020 10:50:13 -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=+oLntqojuWdUH12fyW0ncnBZUNvUMEl0ST479v3SavI=; b=WjEZli5Y2ZbsGjbFRuKXBBPa3y4gFEAzTwatQ2IXdzW+4mBALDH3CECyepTjQmyzck 8JlCht3lbpb7d41uQlzpVDj81/Ln3rHLB81SJNxZ3M+Up+aLyA9UEfvA+QQqdRIB1kJO 0pl4vBdS21KLE8SK3DxXqs1t+iVJOgl++mQl2Z6vJVzfrUi7nX0n3487sv+cjzQVdPm5 /tcwo0NG+w25yzkjM0Aedf4IrMwAI77dwAGekhIu5mV/rVgJMrwXcDjKaLxmhBOgBsNr 9EjjTy/+OX4H1N2HGBgAjzg9cGembmRbKgloXYpfw3gsdJbnRH01JDgrXofUh7DGudNB T72w== 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=+oLntqojuWdUH12fyW0ncnBZUNvUMEl0ST479v3SavI=; b=YbPmw27h3KXyom6ENC8cJ8Bn+6M5v1GjwRJki6JJIrtHpp3B4xSWDooyQNwKD/eeOt M9JhUl4X89dj0TGIdZggFAw4jKKv4XVwMgGHD58wR6GuvfhPng/CLz5twKLzkoK941Rd t8wCDhg/bxHAWSrCe5bhsZtplQOecmQ/M+fEa6TDo84V3AmB8T71XxVF8iU69l7l0dCw yIqKhkrCm/SjPbS9RrofbR+AMgZvlQyUo2OdbiJvyNtgrQPlQ6eUD9IcHsbbPjvf0QhS rhfJXN83pmVvkaUMCqs9eS/MBrVAQcx3QNILrO1AXU2bhwEDhuGK8e0XhghzwEIwi14l tJXQ== X-Gm-Message-State: AGi0PubVVvokqRbBPu0MDyhACaWeKKJJMDcMAnNVLQV3DOXaU+Day0Sy Z8E8fVmdTFXV0PhIRzBysjHHxA== X-Google-Smtp-Source: APiQypIJYUesBNolCLhwv6B5eaa/K0FLECq529AU39kc1RoB8T/W83qqfbTOjo1T94kludYx50eMcQ== X-Received: by 2002:a37:e115:: with SMTP id c21mr9366907qkm.249.1585936212649; Fri, 03 Apr 2020 10:50:12 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id 77sm6821225qkh.26.2020.04.03.10.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 10:50:12 -0700 (PDT) From: Alex Elder To: Bjorn Andersson , Ohad Ben-Cohen , Andy Gross Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] remoteproc: fix a bug in rproc_alloc() Date: Fri, 3 Apr 2020 12:50:03 -0500 Message-Id: <20200403175005.17130-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200403175005.17130-1-elder@linaro.org> References: <20200403175005.17130-1-elder@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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(). Signed-off-by: Alex Elder --- drivers/remoteproc/remoteproc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e12a54e67588..59b6eb22f01c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2054,6 +2054,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, 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); if (rproc->index < 0) { @@ -2078,8 +2080,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); From patchwork Fri Apr 3 17:50:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 189755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3C3EC2BA16 for ; Fri, 3 Apr 2020 17:50:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C36B20CC7 for ; Fri, 3 Apr 2020 17:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iVNXp3/4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404204AbgDCRuY (ORCPT ); Fri, 3 Apr 2020 13:50:24 -0400 Received: from mail-qv1-f66.google.com ([209.85.219.66]:34668 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404156AbgDCRuP (ORCPT ); Fri, 3 Apr 2020 13:50:15 -0400 Received: by mail-qv1-f66.google.com with SMTP id s18so4042929qvn.1 for ; Fri, 03 Apr 2020 10:50:14 -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=wAONRYcVO4RfP3C96vLmeLLooX/mPDYTON30vhuD5cY=; b=iVNXp3/43clmRsJeacYyRlYtzqzS5AZhSQ+jH/korT8/ktSvyrD0uBudRLip/aSzbx i3fJFMr+zBwDbnWF746bGQS1W+f+TGbLCuvbuOXaXJ7ewQ7lMgSeG3Ssyee9mXg+uzVS Rbu0gz0chlxDH3WByItA3qxFkhkTQV85EHb3nchE3AKLKGqXg8XLT3BVF6iSXkScPZ6I GMlPFqHdj346kWYJfx5lGdmdWN/KtzwrrgutCoguh4oAwvmNkyu3lFIYXare2g/obs1W DbsJZD8F4GEDNnS/+ggh7rbgTZHuuJmelaPmCCxAVtJO4yFwtDbDtXoH01+qbqmngOAN j1bg== 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=wAONRYcVO4RfP3C96vLmeLLooX/mPDYTON30vhuD5cY=; b=mlMKuQSMCzW6JiQGhdGVF7nHI7pBEXcPEzRTULAfu2C3uxuhAjI0kbwQUTtItEtSNS TI2LACkGvCqkHJ7r2Guaf1gLy88JJYef1LAX8C+5JE3q1Qo767RNkxMw8eU6yGiy7nKN 1vNI7wT8/k0bbx/gtAphzYF9zFjkVQfBqMLX7PKvlMT8Z1QZi9lMr/GcTEArNzAFsXJA IAw6vUzicv+SxCVxfkHnFQ/rH9vMqv070CMdttF21TlbE6h7EDHW9Nw6/p17bNyYICbc 6LugDYMHrW4xYZyhNtbGoNC8ksxXOM6/saiOM7PAOWmr4xO08icnIZeau0NKoFQOt1wp 3CRA== X-Gm-Message-State: AGi0PuaGT1sSkA3z0/w45M8UekaG1n6AwFRW3irZlyoIRbnEKXi11hFM YpaTEIhTIsO69RixoR4ucKYVfQ== X-Google-Smtp-Source: APiQypJ8RDEp8OGf/STkumxgjzcqkfiVAr1Uw4MNFcGtFAkjN8HqNzwHWoaFlOk7r8uDk/0Zf+QGkw== X-Received: by 2002:a05:6214:1583:: with SMTP id m3mr9622282qvw.215.1585936213887; Fri, 03 Apr 2020 10:50:13 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id 77sm6821225qkh.26.2020.04.03.10.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 10:50:13 -0700 (PDT) From: Alex Elder To: Bjorn Andersson , Ohad Ben-Cohen , Andy Gross Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] remoteproc: qcom_q6v5_mss: fix a bug in q6v5_probe() Date: Fri, 3 Apr 2020 12:50:04 -0500 Message-Id: <20200403175005.17130-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200403175005.17130-1-elder@linaro.org> References: <20200403175005.17130-1-elder@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If looking up the DT "firmware-name" property fails in q6v6_probe(), the function returns without freeing the remoteproc structure that has been allocated. Fix this by jumping to the free_rproc label, which takes care of this. Signed-off-by: Alex Elder --- drivers/remoteproc/qcom_q6v5_mss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index ce49c3236ff7..60cdf699ea80 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1675,7 +1675,7 @@ static int q6v5_probe(struct platform_device *pdev) ret = of_property_read_string_index(pdev->dev.of_node, "firmware-name", 1, &qproc->hexagon_mdt_image); if (ret < 0 && ret != -EINVAL) - return ret; + goto free_rproc; platform_set_drvdata(pdev, qproc);