From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC7ECC43334 for ; Thu, 23 Jun 2022 17:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234635AbiFWRnj (ORCPT ); Thu, 23 Jun 2022 13:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234946AbiFWRia (ORCPT ); Thu, 23 Jun 2022 13:38:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3155532D7; Thu, 23 Jun 2022 10:09:11 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 13FF761D02; Thu, 23 Jun 2022 17:09:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E277EC3411B; Thu, 23 Jun 2022 17:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004150; bh=9ua7Tv8ngKzIg90avnelbsiLM5arPoUfgpVVXD8P87k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1md44VFPMdeFrtVxwOzkNrbmoYwqctXa2Q6vq2/3bJxKzNDMFHEMgOE/DW0JIY72 k0lFsz3uOIogc5PoKmBMppCAvGm6+k1lTTxdsOa4kytc0tIS1tC8wS4A0TI5uxmm8A mnN7EMKIDLgDCsNOXcvzjsNASKX7OsJ7J6g03/GM= 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 4.14 204/237] virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed Date: Thu, 23 Jun 2022 18:43:58 +0200 Message-Id: <20220623164349.017723673@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.132308638@linuxfoundation.org> References: <20220623164343.132308638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 74dc7170fd35..181386e06cb7 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -635,6 +635,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