Received: by 10.192.165.148 with SMTP id m20csp4173751imm; Mon, 30 Apr 2018 13:10:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo/9S/g4KU5+qzIwlKtQlIzKIGz9a58Do2HGnI1sUJmMvnhVIvjfUNyRqYtGpeDEAWZ4Mle X-Received: by 2002:a17:902:60cd:: with SMTP id k13-v6mr14020692pln.44.1525119059482; Mon, 30 Apr 2018 13:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119059; cv=none; d=google.com; s=arc-20160816; b=z7/pjqRxsgj/16PYSw+qugXVNiRggVpUotG0iHNCw1mAv8NhNBv1A3Kve99ptLYhcK NLUtbpip77aSLVyiUDqfSYxM17DhgK6jq1ELDVbxhQDKaO1WlZX7LYUmGIe3ncVqaeze KBzDzb++61APWqTYu76x8TQLaD03tLOkpIOUX3oLY41pBxQYBl0epCktAO/JNRvELBae CcaM+jfwuLx7oaEUB5LpCEjl00x9rXvAaRE6m5I2q7X6BYdX83iz8eAwa0zBLbvNMtr2 Schaum4ksaZ/EhukXI+EL0UCTtYxj38SQMYRye1lU9lvoVCdUgBg+LFTvSSYz/LZAPmu qXxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=VzKtW0VjuELLdlU8XaZdhSbr70Q4V10jWubJkY7xz+E=; b=XDw8EgnYCs6OfMpbGZdTuYx6F8fyw8Oem/iuFIaXzabyF+R6V3WYS5F8Jzm8ng3kBP NCzCRGUVKbftrERH9WMKheH7HYztZ4JDboev107LnKAt9ozCw7Jkk5MGy0HnrDh6xpwp XoFkqJw7xLNanhPy3yCHf/vd1OGf/n7B2XfztWkUJqpUea47xiJA+SzB8c0svg3VxyQU G/7DIXp7tyFblDGI36YkdrNCv2UIaREepRmnWsa+/viJx1vsGqEhEnCv2QFo37RxyPPL GXjVQR/SwUAdLShHn614okg1vuGWpguIrdoRmwTTrEpLjs3+U54phg+nwK/64XNDwLWR RSrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si7759588plt.55.2018.04.30.13.10.45; Mon, 30 Apr 2018 13:10:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756020AbeD3UJ3 (ORCPT + 99 others); Mon, 30 Apr 2018 16:09:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:33600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755925AbeD3T1R (ORCPT ); Mon, 30 Apr 2018 15:27:17 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3202622DCB; Mon, 30 Apr 2018 19:27:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3202622DCB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" Subject: [PATCH 4.14 27/91] virtio_console: reset on out of memory Date: Mon, 30 Apr 2018 12:24:09 -0700 Message-Id: <20180430184005.596384989@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael S. Tsirkin commit 5c60300d68da32ca77f7f978039dc72bfc78b06b upstream. When out of memory and we can't add ctrl vq buffers, probe fails. Unfortunately the error handling is out of spec: it calls del_vqs without bothering to reset the device first. To fix, call the full cleanup function in this case. Cc: stable@vger.kernel.org Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/char/virtio_console.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2090,6 +2090,7 @@ static int virtcons_probe(struct virtio_ spin_lock_init(&portdev->ports_lock); INIT_LIST_HEAD(&portdev->ports); + INIT_LIST_HEAD(&portdev->list); virtio_device_ready(portdev->vdev); @@ -2107,8 +2108,15 @@ static int virtcons_probe(struct virtio_ if (!nr_added_bufs) { dev_err(&vdev->dev, "Error allocating buffers for control queue\n"); - err = -ENOMEM; - goto free_vqs; + /* + * The host might want to notify mgmt sw about device + * add failure. + */ + __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, + VIRTIO_CONSOLE_DEVICE_READY, 0); + /* Device was functional: we need full cleanup. */ + virtcons_remove(vdev); + return -ENOMEM; } } else { /* @@ -2139,11 +2147,6 @@ static int virtcons_probe(struct virtio_ return 0; -free_vqs: - /* The host might want to notify mgmt sw about device add failure */ - __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, - VIRTIO_CONSOLE_DEVICE_READY, 0); - remove_vqs(portdev); free_chrdev: unregister_chrdev(portdev->chr_major, "virtio-portsdev"); free: