Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6029538rwn; Mon, 12 Sep 2022 19:37:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR7/YlB94zGYsBQ7n9cEETParoWPNS3W/az+Z837mSd4c5S5kccpOGf6PdPlv/4GOCZ+maP4 X-Received: by 2002:a17:902:ab5c:b0:178:37f7:6a55 with SMTP id ij28-20020a170902ab5c00b0017837f76a55mr6144328plb.45.1663036658655; Mon, 12 Sep 2022 19:37:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663036658; cv=none; d=google.com; s=arc-20160816; b=JCeceKaLZeYZlQUxU3O91ydeVHTcbCLug42YnO7MigiiB3GLM92nLzjtiTEec7u0FP tQB31kBYcbv5iPLfSd0mWoTPtCcwQXz3RgjoZQUxhhzO8f4Ac0v97pPVEz8xAOb/5u+s BvZk9OjfhzTd4ILEBMpsVNS2BagYiM09iV/Dxmes/wRLG9fFBGPxjwARvcHScHjiQcuA vx6V3Y8bmkt1HdUYH2txJpwPZV7TbVRuQ145ZW39GuS+NkoDdNuodn9Z9TlFzTupbnuh o5Dknl+SUobGhJDgb6fpQWqg1EXhR6+oGnAg4G/exOgoUmfgdflwQyaOYe4Gxk3q67ii W4xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=SYQu88AYNeRedurbyukbZuS1E36ldgIFaNZeNTguNCM=; b=g7TqSbLbOo4SwGZRTw9cLb5rfShZfBnB4jdym02+hpG4Qe0np2W3smlnEt29nCdkxr 03sBEEYit+rGAy2OuvKPpZJa7BE171YlvfLyG66cP+QwfZxwlsg2tNIalsy1JeSBC5E3 QCQI4b4g7+XpltIlBkz1ZCujPN0SePxs523ItuuMQ2JjqymFHAni/Kr6FO/j96C5PeHU LLpo5VqPDPOhAPoIpXHGmlqNNgX4r7CUxCo4BzZHPahqkX98e0ovPc7Z6mf3sQcdEXO5 Gf/BAQ4lBQf4Ldjh2FvR4mZs7RgoU6p7M9GSeblOKrF3ZYVVFTY6iycZl2xa4llbN+aY dZVg== ARC-Authentication-Results: i=1; mx.google.com; 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 x17-20020a63f711000000b00434fe5b0ae5si10854861pgh.285.2022.09.12.19.37.26; Mon, 12 Sep 2022 19:37:38 -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; 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 S229790AbiIMCa2 (ORCPT + 99 others); Mon, 12 Sep 2022 22:30:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiIMCa1 (ORCPT ); Mon, 12 Sep 2022 22:30:27 -0400 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C85581DA5B for ; Mon, 12 Sep 2022 19:30:23 -0700 (PDT) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-05 (Coremail) with SMTP id zQCowADn7t4u6x9j3KQRAg--.35577S2; Tue, 13 Sep 2022 10:30:12 +0800 (CST) From: Jiasheng Jiang To: agross@kernel.org, bjorn.andersson@linaro.org, konrad.dybcio@somainline.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] soc: qcom: apr: Add check for idr_alloc Date: Tue, 13 Sep 2022 10:30:03 +0800 Message-Id: <20220913023003.1677467-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowADn7t4u6x9j3KQRAg--.35577S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Jw4rGF47CF17Wr48Wr4rKrg_yoWDGwbEkF s09r97Xr4UCrWfWw4UJw1fur9YyF4qqw18Za1Iqas3Ja4UAFn7tF1DZr1fW34fur4UCr1U GF90v3s2yr1IqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbzAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F 4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0E wIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04 k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY 1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfU5WlkUUUUU X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 As idr_alloc() can return negative numbers, it should be better to check the return value and deal with the exception. Fixes: 6adba21eb434 ("soc: qcom: Add APR bus driver") Signed-off-by: Jiasheng Jiang --- drivers/soc/qcom/apr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c index b4046f393575..1b73ce9b4f9a 100644 --- a/drivers/soc/qcom/apr.c +++ b/drivers/soc/qcom/apr.c @@ -454,8 +454,12 @@ static int apr_add_device(struct device *dev, struct device_node *np, adev->dev.driver = NULL; spin_lock(&apr->svcs_lock); - idr_alloc(&apr->svcs_idr, svc, svc_id, svc_id + 1, GFP_ATOMIC); + ret = idr_alloc(&apr->svcs_idr, svc, svc_id, svc_id + 1, GFP_ATOMIC); spin_unlock(&apr->svcs_lock); + if (ret < 0) { + kfree(adev); + return ret; + } of_property_read_string_index(np, "qcom,protection-domain", 1, &adev->service_path); -- 2.25.1