From patchwork Wed Oct 19 08:30:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp280342wrs; Wed, 19 Oct 2022 05:00:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51JVi2YNXf+jRUXNdwdGFNwM2Xli4sS2TlN/pTCPjy1trYJHlXmWR/61Z58tq6y+6mSt5C X-Received: by 2002:a05:6402:5162:b0:457:6ef2:df3 with SMTP id d2-20020a056402516200b004576ef20df3mr7068059ede.128.1666180840430; Wed, 19 Oct 2022 05:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666180840; cv=none; d=google.com; s=arc-20160816; b=MwA3wkhBL2KbHjBnQFx6UPoOIkXIDhFOHPIDfUQZ9TzRvDd1TkSKWBA4TiPFeihp75 f4afKuNA+l2f2j8jVDjc/ULikqZywGduQHtUjSpyjVU3Z9+TxhqsJ565iz8nnB4B5D42 BBktxNA7DLmRXli++WoWoEwgTZ9ofnaoYc2eFkDWdiPGpWYfCYf1oHIaVfRPRWW/hXwy R4MHM/xda/X8hPZWVJH52CPycZKfdRatP9ZQdRbjbJvZ/Z3ws6yee75QRlOdjjIi3Nuo MBP2VGhRYX4WBCZiNZULpSYPTytLn5lVs9CUVGkOBuCWiueZm9y7yV+pRTmuj3cjaF7p 8ZzQ== 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 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.00.13; Wed, 19 Oct 2022 05:00:40 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747117240696957440?= X-GMAIL-MSGID: =?utf-8?q?1747117240696957440?= 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;