Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3667569pxb; Mon, 24 Jan 2022 14:54:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxst99cLMykmPlOaUDjV9bYMkjz00qYfDijHj6ZxAbWpfNK5xhZTQha6rUcvteJZfBBW9+Y X-Received: by 2002:a17:902:6b05:b0:14a:b331:d07b with SMTP id o5-20020a1709026b0500b0014ab331d07bmr16391015plk.172.1643064846274; Mon, 24 Jan 2022 14:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064846; cv=none; d=google.com; s=arc-20160816; b=tDj/oaSx7FCgahTmuJ25GW/fX1ZCU8JeXMl1T4cMTz8C9EtPZscGPjlz1rXquCaegc JIhHRwpm8OQaYiuo9KHrUY8lZoqgpAcMMwalTyjSf84gwOkpQVjwYfgJrfNmk2Hn0NmP H9g09um1JpRVdyHP0kd+oQ7TNlOdH6xHx3TzNGFN1lPXFbv92Ec2raGhs6WJjx4gfXHb ZZkKu1wXvR1Xj6RutwGqt3fhsjwljJX3igw8tZom2aSuQ/VVXrOuCbVApQX7BXA9Sc72 sDU5rl9h7RfHMzVhnGQkokHqMqV8T+Ew0vslasXlrr0Z0RwPzBgG8w77DhQaK3R9g8zy eRdw== 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=b44YeVsVKMDvuQAzvSD6XGhDSge/gVXW8/TgDYWwtgk=; b=f3tinf97jDc4tMj7Hhk7lF6ubn4+8ulj1lcmGSf45xXowCXjCtI7H4xVL32mVax3W6 b1vA6Zy2PtW1ijOoNYzcanr+4rBODDIzroTmIYBEAq3lcrp5lcxZeh68bIhUa+DUYS1g BbjnDvFYHJp2ZVdVsfVc43YvRKqdF06ZWFs8EaeNanMIqZXOo4QAt/CXlSn3b9rrZCjY tsuPDMYfJmuYMU/L3gsc4sgKmJjg2iSjgLNJaKY4Sc/Faic/WE5FuQx1IgiTRQDKzXHV tv7sopjeC4SZUlbUNQCW6Agza697w3FO4eTArZpzBK31+uUJq7CsZx2T5TSD0WbGiSYJ x1vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K49rSfob; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si15311609pgh.649.2022.01.24.14.53.52; Mon, 24 Jan 2022 14:54:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K49rSfob; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1357691AbiAXWrO (ORCPT + 99 others); Mon, 24 Jan 2022 17:47:14 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:52408 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457859AbiAXVmY (ORCPT ); Mon, 24 Jan 2022 16:42:24 -0500 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 DAE16B811A9; Mon, 24 Jan 2022 21:42:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15A74C340E4; Mon, 24 Jan 2022 21:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060541; bh=Gl0jy4PB5R5wa6o52whfL1Em2AKbbEFdXHfbPfhrtME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K49rSfobpH8tJuU7To1ke4zDHyldQjk99jmZ0hcpUfXMIw8Y4jA846+2ZvGjBHiRW zKROg6rw1iklVmejWfugQpI9JE496I3SDOSkShj4oJIXBN/wRzLaJtyAE83vOhMXmc GzTIzcZNyi+ua65jvuZgq1KmPNgQ3wmfx2U2+ylw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Xuan Zhuo" , Jiasheng Jiang , "Michael S. Tsirkin" Subject: [PATCH 5.16 0983/1039] virtio_ring: mark ring unused on error Date: Mon, 24 Jan 2022 19:46:12 +0100 Message-Id: <20220124184158.318703837@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Michael S. Tsirkin commit 1861ba626ae9b98136f3e504208cdef6b29cd3ec upstream. A recently added error path does not mark ring unused when exiting on OOM, which will lead to BUG on the next entry in debug builds. TODO: refactor code so we have START_USE and END_USE in the same function. Fixes: fc6d70f40b3d ("virtio_ring: check desc == NULL when using indirect with packed") Cc: "Xuan Zhuo" Cc: Jiasheng Jiang Reviewed-by: Xuan Zhuo Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/virtio/virtio_ring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -1197,8 +1197,10 @@ static inline int virtqueue_add_packed(s if (virtqueue_use_indirect(_vq, total_sg)) { err = virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs, in_sgs, data, gfp); - if (err != -ENOMEM) + if (err != -ENOMEM) { + END_USE(vq); return err; + } /* fall back on direct */ }