Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6002406ioo; Wed, 1 Jun 2022 18:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgHZjYPakarzUbG0c4H6MeJG8YINlSLT0t3qquGAnheedAjlSDcJNsBVB1YgL0VUEbyElR X-Received: by 2002:a17:902:e947:b0:163:91e5:d3c with SMTP id b7-20020a170902e94700b0016391e50d3cmr2154550pll.39.1654132635705; Wed, 01 Jun 2022 18:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654132635; cv=none; d=google.com; s=arc-20160816; b=VrZm2Z3r8mQmL8WhEpYrZQ4AlUFq4v6aTawEzicTnz2lw8GDEK2TASb04Ovlh1nSBT liBuPLFaWyGS9m7RD7FsFRMa1WaKjoB8MsmauUkRTMYQOFg9heloP+R3XDFl7ejpu8eI IGQHj6W+zDPN1P/XSIjORT7scfVnrDGZhen/st4P56uMx+BjOKdQSojuCwnU49Dwuk4C cFJ1bgWmDg7SnaxHwX7KANFGnaPQokURYRFnJqWh38h7EkXUme3L1aZ34XrNvZVI6abH hHmvZfaHLATzqoE/Yl1fv0B7E6L0nbYMlRfs3R76zYOrUU4mZn8i7HKJpwsldD9bb1Yu eSbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=X2ieJMGlzcaHYK99zy4O4rgZqpHj0MIlPUsyySv/jig=; b=GcXqTRNkiOnd86WJSv852IKLqt+Hp5iDJzsyHBK2fGxljVB+kuFBH6QvWwbnR5UyWA pCduWhpyEuVzbEfpj+jkvtl2v8xeNZ7TSpVhhJNgYmX+rLUBUd3ctGYFtWyx/Ntj6fNB Yvd7w7UqJQSCRLDsmCDLpPPqgyAY9Gi6qVMZvya0599JYteC0e7iQ60b6kJ8ugb9NZzH 5YQDSKo/UsUrMtGeNPCLquae7gMY1GIknsE5PjQ43H2tfZo/9cP227z+OG1SlchvhMG7 dBGAANbPNfFJM27FCm1tIfmBK75smMzKz0SWfcILpqT4B+uoTTfjiCE2RNGbCJb8uDkz byXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WAJNsnTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n2-20020a634d42000000b003fa6b315967si4139183pgl.606.2022.06.01.18.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 18:17:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WAJNsnTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6B14228D6B4; Wed, 1 Jun 2022 18:12:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232974AbiFBBMN (ORCPT + 99 others); Wed, 1 Jun 2022 21:12:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232904AbiFBBMM (ORCPT ); Wed, 1 Jun 2022 21:12:12 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7EC128142 for ; Wed, 1 Jun 2022 18:12:10 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id w21so3480736pfc.0 for ; Wed, 01 Jun 2022 18:12:10 -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; bh=X2ieJMGlzcaHYK99zy4O4rgZqpHj0MIlPUsyySv/jig=; b=WAJNsnTQTnLlQTwXRbmYJVNioljwUHZ1Z0T7bvtRBgAzunZgyiZCuJvchhSQD/34Qs +5uo0zNsEoH3EPJQrQkr+02cxslNn1SkBgyn6iKetTeCHb2/TCmpeCKQnb0pwIHC41g7 L60OA2pcpBGtPxFoIVmYWv0YAuvbQc48d0ffKOv7uaeUBzY1FewzbjZUk6ruNJQLie+W ieQtgXF6jsXZC3GGf7KPmtaaPzb1OP0UIwRd9EoKlr0ByWe8SNiNegvzWLDL2Phu3Tk/ +6BCxvDtCruSKKu+Y4BFPA/tu/dE32CVIDCzKwpehJXDppeZNrZbUhHtm1BoZsM+TVlC x4Bg== 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; bh=X2ieJMGlzcaHYK99zy4O4rgZqpHj0MIlPUsyySv/jig=; b=LZ+1lUt0WKeJ7DWHxx+OnzsPE0lCmw67ifc1SRnbZrYiPwrFrela+2wmxLg0Gu3b4E BYH+pJw4ZUUhkN3g9IIcAdA9yIHZ4c+Ms7wREQs4T0M85u1sJ73CtpIY5kOCL8ZznKLd TrkrFHNi1WlwMaYAdTbn3vbH+gmk7fE4egkN2UfVKm4FNtMIXLI20zaRSNRC5Sj5Z8ef mm7WqtqN2ykSqrZy2L3z4N2skX9Hz6oanek0gBxmH0W9jpge3+zPNj4ITYf9E4Or4Vqe x/0OeXayHDKJsSrjerhPVP3/53N9EpZT6M4luQIiClmzsmqkhhg6xyOE8Nahgw+6tbGu RDwQ== X-Gm-Message-State: AOAM533FPBgS1SYbL5XFjb64yN/XpXTaxLPvXRdiSH9kwpa5MNUHDdcs KuVl3Qu4QTtm71NqXjKFBFA= X-Received: by 2002:a62:be14:0:b0:505:a43b:cf6e with SMTP id l20-20020a62be14000000b00505a43bcf6emr69455849pff.33.1654132330347; Wed, 01 Jun 2022 18:12:10 -0700 (PDT) Received: from 192.168.3.10 ([111.202.144.35]) by smtp.gmail.com with ESMTPSA id fa23-20020a17090af0d700b001e2ff3a1221sm1940288pjb.33.2022.06.01.18.12.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2022 18:12:08 -0700 (PDT) From: chengkaitao X-Google-Original-From: chengkaitao To: mst@redhat.com, jasowang@redhat.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, smcdef@gmail.com, chengkaitao Subject: [PATCH] virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed Date: Thu, 2 Jun 2022 08:55:42 +0800 Message-Id: <20220602005542.16489-1-chengkaitao@didiglobal.com> X-Mailer: git-send-email 2.14.1 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: chengkaitao The reference must be released when device_register(&vm_cmdline_parent) failed. Add the corresponding 'put_device()' in the error handling path. Signed-off-by: chengkaitao --- drivers/virtio/virtio_mmio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index 56128b9c46eb..1dd396d4bebb 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -688,6 +688,7 @@ static int vm_cmdline_set(const char *device, if (!vm_cmdline_parent_registered) { err = device_register(&vm_cmdline_parent); if (err) { + put_device(&vm_cmdline_parent); pr_err("Failed to register parent device!\n"); return err; } -- 2.14.1