Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6429082iog; Thu, 23 Jun 2022 19:54:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v7b26UL1bRAsHHw8ztp82nBjiNl8lRBH0Yh0Ff6UUr9neTic7rwvPwRa4KSDPCqpe/UdAk X-Received: by 2002:a17:90b:1c87:b0:1ca:f4e:4fbe with SMTP id oo7-20020a17090b1c8700b001ca0f4e4fbemr1292627pjb.159.1656039269226; Thu, 23 Jun 2022 19:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656039269; cv=none; d=google.com; s=arc-20160816; b=G6UPrHskbU5ol3Sf2Suo16dOI4fQjD5cPVp8dFaTA/mXsz5j4R/TRWZ9cHL462hSrr 7i17QNvTFKM8CPUYolXGQd4CpClRHeENTuDD5fjOJyFr7KIKeQsAGeXfoB4b1vHazU8I q/5m43JUHVAS2K5Na1s3Xs7ctC//09Iagu8MFh+vwNKyAs4PtgPIKdGM+XGAlcKyH6uq UGO1GdJAltxn+myxnWJy0nkiJSIRH01qVMEwLhxIgNu3fPB5DqfQhYLnXtafufMR3Eza mMQDcrr46Imn7MF9KRiKPXH0vSc74+hKMmMYurM6MRtXA8DqfQHcI9uWfAXpVIEZrKJc RQjA== 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:dkim-signature; bh=4JPmBa9YRGGIbNymzaZBwCj2uTHp/bKyA501RluWmfw=; b=rqLFwMrVXe/HXVTzi6H6ErqL/2WLXtUyCTBl4thjzdMcXOO9sKPYQEuXPAk/9NqWFQ M3R85YEaEcPIgtj/Y9utnKWaxAQHcftg7CaGraXqtEocqgf/PcI9+xN6+TsdK42CfU8s 7spTCNveeRY87J+5VjilnBuk6q8jxm01N9VizRYfC5toPpGPBhePw5iYWW5JRx1psBbr KmVAs1vFvMT4H8lb2QCXM/ZGjTTLDIvWImSMj0mKx9EYktZSfG7Yp/guK2cHzbHe3axb sjdG5uBI+E1CIug5TppSTDwIPnkMNd4uvL5PXSppHy4CIaiV2zxaOMmYRk1RZI72f4fp smAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=e2Zhs3Jm; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a056a0016c500b0052513e4ac16si1344801pfc.43.2022.06.23.19.54.17; Thu, 23 Jun 2022 19:54:29 -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=@gmail.com header.s=20210112 header.b=e2Zhs3Jm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229639AbiFXCmW (ORCPT + 99 others); Thu, 23 Jun 2022 22:42:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiFXCmW (ORCPT ); Thu, 23 Jun 2022 22:42:22 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 695CA56745; Thu, 23 Jun 2022 19:42:21 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a11-20020a17090acb8b00b001eca0041455so4555649pju.1; Thu, 23 Jun 2022 19:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4JPmBa9YRGGIbNymzaZBwCj2uTHp/bKyA501RluWmfw=; b=e2Zhs3JmLacTcis3WcQcUHnaiF05hNZPRtHQ7Ccd0f6j91n886n7ShnklJ/7geL43r QPRyDoYL0sQdysS8N8OmWcQyIHD0czcc1CoeTzh3cm13KOTe0vvuuJMNRebcxB0SZCqs t3S/na5PFpsTm3AflB39HpRqFGj/ts0lNqK9N72oG3OnlyiDURBEeTEZVr6XzN9MLSGf mMPSPgt+kJNqTZjdweGWGCF6dE6rn+ElPIM/zvmf4LdiRn1pqg2cpu3vuDqPkl/jiujx IDntf5nQbNdPewDyOqwJIt6tTTeBpk2WlRGBqmrCTl+DpTwllvAE5khWsxL3bMI42Z0v pXXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4JPmBa9YRGGIbNymzaZBwCj2uTHp/bKyA501RluWmfw=; b=SPp4NN/XoULxxoZ3O8HlLaoKK0yZkz2/zBHYrJbD7+mV+syoVd7n0JMAPNvHI0jboP PJjZaN+hl9P6O0wrKA4gGXY2lKTEwkh7cH0S59QuGWWMN5xCm0/kGNf0gLL4x4dIaN3i ahJwXpi1V/Rx9vGPuE2FfZlDrJc53m1aDB4hYk30fL4T5Zf5A5ROmewXCpcEoVi9h0LR 9FZBn3WU6LZG0nE/s2ZW5ML9e9JpCj2PbtaYTCjkTZWJWnSZP/Zl1iwG8NPq9Pp8w95D lSypzLn8kXj3bWeTqKibSJ9BZKiuiDhIVtH8n8eKM4503m2Qu+1rwGqMY1zlOnqueONP /VPw== X-Gm-Message-State: AJIora8sQXtu5RhTwswktHhDWV4OeLpD++c2ZmpkFRIDsDaNSuwvQp6m wSt5rllzt+8Sc/g/heV6t7g= X-Received: by 2002:a17:902:7005:b0:163:ffe7:32eb with SMTP id y5-20020a170902700500b00163ffe732ebmr42023769plk.18.1656038540717; Thu, 23 Jun 2022 19:42:20 -0700 (PDT) Received: from localhost.localdomain ([103.84.139.165]) by smtp.gmail.com with ESMTPSA id l10-20020a17090a660a00b001ec7c8919f0sm2625936pjj.23.2022.06.23.19.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 19:42:20 -0700 (PDT) From: Hangyu Hua To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, gregkh@linuxfoundation.org, krzysztof.kozlowski@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Hangyu Hua Subject: [PATCH v2] rpmsg: fix possible refcount leak in rpmsg_register_device_override() Date: Fri, 24 Jun 2022 10:41:20 +0800 Message-Id: <20220624024120.11576-1-hbh25y@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 rpmsg_register_device_override need to call put_device to free vch when driver_set_override fails. Fix this by adding a put_device() to the error path. Fixes: bb17d110cbf2 ("rpmsg: Fix calling device_lock() on non-initialized device") Signed-off-by: Hangyu Hua Reviewed-by: Krzysztof Kozlowski --- v2: change the commit log. drivers/rpmsg/rpmsg_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 290c1f02da10..5a47cad89fdc 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -618,6 +618,7 @@ int rpmsg_register_device_override(struct rpmsg_device *rpdev, strlen(driver_override)); if (ret) { dev_err(dev, "device_set_override failed: %d\n", ret); + put_device(dev); return ret; } } -- 2.25.1