From patchwork Sat Oct 22 07:25:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1124457wrr; Sat, 22 Oct 2022 02:36:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7y1CNaW6XKQCLY2W1jr06hV0052hb2DDkTRf1lsxReY9emj1gCC5Dg2d3LWML3Yctexq4q X-Received: by 2002:a17:90b:4c48:b0:20d:5c55:b8a8 with SMTP id np8-20020a17090b4c4800b0020d5c55b8a8mr27642333pjb.207.1666431403894; Sat, 22 Oct 2022 02:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666431403; cv=none; d=google.com; s=arc-20160816; b=YLziATmmwtVTsJNvfT/z1Bn1mIfyVtcTtcbY2LfkW0Vmb7zAg4yaJ53/lg0wCck1Ka a0WUhV8rhzc5iPEZRung1nzWgeZKY0F/TeZTU9uubTTQmJupWbzmqt3YcROnvRBzSFBy xyuJk1MmsYlRApl89TvTsLSeR2S2ei1xmA36pItEn4kanzlfJjWVb7Q4bFUuVXS0vJaC YJORIsmveAzuc+x5e1INlbQgLm/BzqGOYbFjzfOyox6bEDKIvEjggloPZrtbx2cWU2VL dsR/WR7U+Lil9ZNMcb0VPYyPtXwWhutSSY6mOMyOtzRLv0fNDR0QMidCwXbzD9w9bPwx h27w== 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=OfbAzkOFz3NoSH9g+k7fZhWCodokTq9Cj3QnKdJvAAKqCvxKcx2YBH59a/pZZckSC4 kV+Ik0x1qAHAj03kcARkUdRt7OLbJ6Pev1tChZt9S+Kgroz6SzLXwBGK3gLtKnyisNs9 8dIR3Hi0PaLWekrufoMqIQF8Jw3bpWPDPK37XFvb5ZhtJ4o9VPr0ga4HTMkFCPqUxsyx UZX1IwxB3WukNkDkG0QKdYiiG78prNQyttecp5Du66n0QV91pnD3waUVCP2onDEuBjvq ojFvxGlhFceHVfnNriA2DZU9yUGPizyYO38HqvNRb3vQpY8TQIp7jdJ8CXzscFo5T6UM xfjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yli5Fmwh; 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 c13-20020a63d14d000000b00439e032756fsi25022639pgj.65.2022.10.22.02.36.30; Sat, 22 Oct 2022 02:36:43 -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=yli5Fmwh; 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 S230272AbiJVJSu (ORCPT + 99 others); Sat, 22 Oct 2022 05:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230328AbiJVJSF (ORCPT ); Sat, 22 Oct 2022 05:18:05 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B382830A0DB; Sat, 22 Oct 2022 01:32:00 -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 ED5B3CE2CAD; Sat, 22 Oct 2022 07:54:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA5BC433D6; Sat, 22 Oct 2022 07:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425295; bh=AIPgOlTw2C29CZW+Rcr36Sfqvrn2uqvWjCZRKazOqQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yli5Fmwh6McwGdFLAXZ/NGXzjWhJlkYbKjtKw9TKSQFxrqVTUXgVIXc0Po+qQS7+d 0nbCc0mX0zVC4bvkE18Btfusdri1prqDqbUyNNePWlQbgb1mG9mlNXSo2QQn07Rdi2 Z7nNkBHAbmqXQIfuUTG346TQw28mhUDqABX/eeL8= 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 5.19 453/717] slimbus: qcom-ngd: Add error handling in of_qcom_slim_ngd_register Date: Sat, 22 Oct 2022 09:25:32 +0200 Message-Id: <20221022072518.316510505@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747379975638519415?= X-GMAIL-MSGID: =?utf-8?q?1747379975638519415?= 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;