Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3617946pxb; Mon, 24 Jan 2022 13:37:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJSUvFsyGs/QdJ8Z7DsLC9ZzwVg7ayU75YsMOG3ut1rwXmQVEVgMxWQgQsQRDB8QJgOof0 X-Received: by 2002:a05:6a00:23ca:b0:4c7:f7f4:1138 with SMTP id g10-20020a056a0023ca00b004c7f7f41138mr9720261pfc.78.1643060276740; Mon, 24 Jan 2022 13:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060276; cv=none; d=google.com; s=arc-20160816; b=mZr6xZ/EtQp1JxUkR8BUAPnGozF6dc0JzFfa8kMbrG9LsN1vv5Yg+oYLAndr+kZBNF 6lRLxRmhswcXzr2I8122GleXoywFHAuGSbIccEQ8zlXdHBzDHMfMgMCJN8ieXr5oEpyP v+HWSs77UMPYnM44E4srrPnSI2O72sRvyIY5y5BW/nmpPtJI0uArVLlpmoQjcaadIlzv lpRqwHc8U8BFk0dJCHKeJ3TKtdJH3eUOIWeCLTilVNaNA4Qhf+I//EkQngm076g8GcwC PHH4f2Dfc6RmSMiiVfhR9Kek9AfxrJsbNThTXCXHA/1KfrX9dP1yMJipEypbytT7WDYr rF7g== 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=UTJPP2VjITABlB35/WzuW0nzpk/EhWJBOI3toj2OKX++yH/kR5QK/fFdSb+C4C+skB 52GF4ANModC9PIbX1x0ZFkXWkQQFVQSpgeTYrrypYiD8RRzHOh01sDcV32qcEVqw8YlZ EDBAQFaB2E7UX2dctZi8EZ3UXVqwlVet3+Se+K09zKC453JV8r+0rhf5La7a8rNi5cOs Ys8t6LE5v/TynzcnDmcUAUggNsIg3sI871qGd9yxOOXRM/73lu7SWnYUmRWDJ34IMx8D n4Mcr1eM2c5Y0KPF6U/74l8DXADqonIZgN9sHNGomWMjSmz51Wo0VDVyw6/m3DLNOkB/ RhWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yN+G4nPE; 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 l7si14727340pgs.579.2022.01.24.13.37.44; Mon, 24 Jan 2022 13:37:56 -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=yN+G4nPE; 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 S1378252AbiAXVQj (ORCPT + 99 others); Mon, 24 Jan 2022 16:16:39 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:43910 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392005AbiAXUuO (ORCPT ); Mon, 24 Jan 2022 15:50:14 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C6DBC60C41; Mon, 24 Jan 2022 20:50:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AE71C340E5; Mon, 24 Jan 2022 20:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057413; bh=Gl0jy4PB5R5wa6o52whfL1Em2AKbbEFdXHfbPfhrtME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yN+G4nPELe+jkSEmjxDGwGscQ4xVy4eyEZD8AStvoOFCPjYPCOhEM2bS+UsMJUsrP +ygghXa2BuN1LDzqul0emArPxtSl4tQoRg4VrVi+rfYkyRnjGPyJPJkm1+j9CRF7QG WEv6SDryoog6usWxqZjRCF+SSl6FxVXuPOaKJ/bA= 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.15 805/846] virtio_ring: mark ring unused on error Date: Mon, 24 Jan 2022 19:45:22 +0100 Message-Id: <20220124184128.705167203@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 */ }