Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp941912rwi; Wed, 19 Oct 2022 05:02:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6EZA3k4l2PadNUn0jX1A54TIxUlFxWZN3yxhiUuJZxyt3OgvE50O0zPNY0sQbWoY9VAmh0 X-Received: by 2002:aa7:d28c:0:b0:459:3cc5:3cb8 with SMTP id w12-20020aa7d28c000000b004593cc53cb8mr7291173edq.261.1666180959782; Wed, 19 Oct 2022 05:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666180959; cv=none; d=google.com; s=arc-20160816; b=DeR9HI/UZR69rq6NuC+m/zh/oQPesN71c8zregp9wXxX6flEOvs9NC7OENO1DXabMI wVo1/f3yQ+BNPLTsKbWJM7joV/jDztK8q+ECPPkOV5ZkYT9m9Pmm3lIF+3S0aLOMgT9n ZtBFkxqwZQpSg/KiLmSyw2j/HKHKCCvg/UswhJuY8Xsmgd+t7DkbSYxdnrDS26uwXS1O 9aSUyujESI4ZIR3Ljs5wy5jtZ7FgBQZHvxIejGM9akGKXy7q4bVFsyxSHVK4rIfpySZ2 uNlQMHlFz3CSqdKa6bvklNASpSXfQGssQUl9REC4VpidW+Ks55fp/nnP/KQ0aRE6Sb7p XhTg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Tk6rJCCrUU+UDNO3KpzwcKkHRjzn/vohe9OfHA2ccnM=; b=rvYeqxVxXMvZNVbNHS6yrQlO0HuGdNMK/5PUgiLEZuVjA/JU1V3IG9slqrQ8VdIvJL odUPOBO2meDBbAXrN9FiLnfbpRN05KcXCgEg/Nfb0DRAXYb/HYLHAi2mUxb0ZOqB0LiA +OwW/uHy+mlyK1JRDvO6g+UzRzDcmVXoRRtZf8lKXwEumjvUD+gGOONDMRgFAVnpde8f 6638ndSgRS2kNF+9UVQSkBaBcMFWe6hp9peSj65LuLVi0p7Biorr1zjivokq1gpbI+Xw ZmWrLT7XW8XVhi/HyM+Cj0diohAmI4tNWPOiBPo5vbKtlyuZKlTfdWFfUJ923hk6xzXl sCQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uPyOXGHK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p11-20020a056402500b00b0045d212cc170si13526557eda.363.2022.10.19.05.01.25; Wed, 19 Oct 2022 05:02:39 -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=@linuxfoundation.org header.s=korg header.b=uPyOXGHK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231852AbiJSLxF (ORCPT + 99 others); Wed, 19 Oct 2022 07:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231857AbiJSLwt (ORCPT ); Wed, 19 Oct 2022 07:52:49 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8081ACA84; Wed, 19 Oct 2022 04:31:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id A4F2ECE2170; Wed, 19 Oct 2022 09:04:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C502CC433C1; Wed, 19 Oct 2022 09:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170291; bh=AIPgOlTw2C29CZW+Rcr36Sfqvrn2uqvWjCZRKazOqQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uPyOXGHKxg13vb4UmrEf0/Ue6S6nsUQ82IOUsKUTTnC+Xw0fe1fzPgjIHSTez7OD6 V68xrBimGBocJrKx65NZQuXHC1YQdgcvzKJiYpt1rXMLpk8xrrPfSo25+VRvt8ruTc O1Ugx5uVEWhiGjm7wkT3xf3vdNGnyvQCupPsqQIE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Neil Armstrong , Lin Yujun , Sasha Levin Subject: [PATCH 6.0 562/862] slimbus: qcom-ngd: Add error handling in of_qcom_slim_ngd_register Date: Wed, 19 Oct 2022 10:30:49 +0200 Message-Id: <20221019083314.815961935@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Lin Yujun [ Upstream commit 42992cf187e4e4bcfe3c58f8fc7b1832c5652d9f ] No error handling is performed when platform_device_add() return fails. Refer to the error handling of driver_set_override(), add error handling for platform_device_add(). Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver") Reviewed-by: Neil Armstrong Signed-off-by: Lin Yujun Link: https://lore.kernel.org/r/20220914031953.94061-1-linyujun809@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/slimbus/qcom-ngd-ctrl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index bacc6af1d51e..d29a1a9cf12f 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1470,7 +1470,13 @@ static int of_qcom_slim_ngd_register(struct device *parent, ngd->pdev->dev.of_node = node; ctrl->ngd = ngd; - platform_device_add(ngd->pdev); + ret = platform_device_add(ngd->pdev); + if (ret) { + platform_device_put(ngd->pdev); + kfree(ngd); + of_node_put(node); + return ret; + } ngd->base = ctrl->base + ngd->id * data->offset + (ngd->id - 1) * data->size; -- 2.35.1