Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2930629iog; Mon, 20 Jun 2022 07:43:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vTL3hkpUVbah1sBFJXhZPiIWo03DzsS41UYUtQWc0OnXuZ3v59lS1ZlExe93T5crVXPUWE X-Received: by 2002:a17:90a:d98f:b0:1ec:943c:4fbe with SMTP id d15-20020a17090ad98f00b001ec943c4fbemr11170373pjv.161.1655736219496; Mon, 20 Jun 2022 07:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736219; cv=none; d=google.com; s=arc-20160816; b=P/0usz3tFYVGSOKbrAnbnPoxRbGi44laXvSgckqoIJVC7YPuecNghq+fdGZQqUqymY gmq4R1aE5K1jmOelpMQZ2W9C8cDT7j0q3wtpzmAU7YGkHuPnhBc4fNVQiLexUASLpgJP cYiz0IzP/pPYJ358gsKNPcLAQSgYZLCvDgsrPOAbnZ22Zc+4kKGwAH8Ea6UwFCSWkCxk /pU2vlmDluSGGkGB6a9fj1yPDYVkg7kRCDy9HLhXO389ND1vAq/fePpOubEs60Q5lkjV vm0eSuJPqVMc0B4ZdRBBaufoMn1nC1MSb8varqjXBx5jPc/7HNl2aAm3sDGZ+VVFR+I2 q1Vg== 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=wDP/qfFfBJB7MYmXp2nf2Lv3vfdCZR8WHYPsVDlh31U=; b=Kn77dlbXrrswDHu3s3aBwLNVsVpcyPulZErhZxyWbPBThX1YVXxtcYY0mp4Mg1jVPn /HdFHMZBUij7V0ShGx5QvI4GIecKahMw4d4EjlYbUd+2WR3jSbUb/u6BWLZ0jpn5uW+N t7xpY7VzDrSqvQTAYR0ISY+XOeJuqGwDmO8lecyvgw3D0+i82cEtWNELSVAAKaaUbbi+ klILMF8qFa2WGNgvh0quE0NjO17CBwegonRZbE4zSNgSvGcjPMejtsMOlYGlJ0KO0AQ1 RIdnOjI7iie1Lt6eikCZlhL/HpuIL9CCPq2bwgUA7phAvitsgmYUWgIpp/vmcLYVIGNA PF8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oQxyWWYw; 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 t1-20020a170902e84100b00163e05df91asi20078236plg.37.2022.06.20.07.43.25; Mon, 20 Jun 2022 07:43: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=oQxyWWYw; 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 S1344555AbiFTOCH (ORCPT + 99 others); Mon, 20 Jun 2022 10:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352325AbiFTN4S (ORCPT ); Mon, 20 Jun 2022 09:56:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F73F35873; Mon, 20 Jun 2022 06:22:18 -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 ams.source.kernel.org (Postfix) with ESMTPS id C47E5B811C4; Mon, 20 Jun 2022 13:22:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9A16C3411B; Mon, 20 Jun 2022 13:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655731336; bh=AdFVJd7dV+iDxxJ8is6cJt2zyE1ZZxlOE5i/rQvNwmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQxyWWYwbX1T15xMYGkMNPfPbpVrL6lf7ZXbxchcqDROEW6ET0jTzNa4ibHujxj+h 17dbYwo9Y6AbCSEL8sj6G+k9EJGwt1lhfUto+UyQ2zypWowVFql4aHatDUAiPsNFqg U5cdjojc63BbMvLXv3jHv0K9DrNH1paS5+/VP4Yk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, chengkaitao , "Michael S. Tsirkin" , Jason Wang , Sasha Levin Subject: [PATCH 5.4 199/240] virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed Date: Mon, 20 Jun 2022 14:51:40 +0200 Message-Id: <20220620124744.750911421@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,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 From: chengkaitao [ Upstream commit a58a7f97ba11391d2d0d408e0b24f38d86ae748e ] 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 Message-Id: <20220602005542.16489-1-chengkaitao@didiglobal.com> Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Signed-off-by: Sasha Levin --- 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 e09edb5c5e06..74547323aa83 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -669,6 +669,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.35.1