Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3622091pxb; Mon, 24 Jan 2022 13:43:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFPqpa1EZTE/cp5xtqmtI++7iMycr56TPstk77B0+gDTHxoukmZYnj1D3WbSFK5y2tCZJp X-Received: by 2002:a17:902:ab89:b0:14a:1802:7c15 with SMTP id f9-20020a170902ab8900b0014a18027c15mr15514776plr.88.1643060621021; Mon, 24 Jan 2022 13:43:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060621; cv=none; d=google.com; s=arc-20160816; b=0pNt5oTzEe2sNjN+Tk83JYz79xXHYViS6G+qRDC/ytMey0p9R/8FIzgRyGYKOIOPaa 3BvgUhcvR8Tj6dOdvjhr9/W6Y1qLbor3zGhz7Xp2XhGLMaPsdD4M7zJl8z0KE9KhHZpq OU0ul/nWLKuIgDnZNrCkIebHPVumz1wWQdbTG00QvADUIBI6+ZCIPtMNg/wTj3QihdUR gVCTzdetQ3uKNoINc4YYPWrHgz+eKR7Izd+xBkZ/6lZ5KlOQaocGyaZYtsrQjzHKtKxo 2LL6u92GsgwA2giS1HkwZUFSivfmgTr/Qaq3YtFMNX6cmIWcaOwpCFs79Dw8bBLOp09l RZGQ== 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=9kw9CUCgqYfRwx56d+KCq0YDtsqXP+RFzk+zW+dhoM4=; b=k6vGXrgupEX3wrcdVKrWsJO0jjastfj8nllLO7h1JPtci2+foCRt9U1vkjlYD7G0F1 6hmuCJNd1A0IkuTjWtqkZT1lHKlu7KaokP6zcsB0kzTEM7bWuWa0PCx2oalpB4G4OFq0 8PXKyl4M5uQmUcM/0wQYcoEsR9VLZZDjVwoygSJGMFKpO9b24mUoWR21VRmzYgUjh2eC 5AY4f/QpVIk6YOXy2cxpXD+/EjStIp9KMljTpu6B86lCU5AOJ6XQgISuR4HfsKcuALrO Ca3d46S2WejcxPIqNTmkXQPwFrdg0Y2x6CBvIUMYQptVnzPcwE1TuANhNCT3hjMluWma DGqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N+G1ba2F; 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 w15si15615403pfu.279.2022.01.24.13.43.22; Mon, 24 Jan 2022 13:43:41 -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=N+G1ba2F; 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 S1451766AbiAXVXd (ORCPT + 99 others); Mon, 24 Jan 2022 16:23:33 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:51914 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443036AbiAXU4J (ORCPT ); Mon, 24 Jan 2022 15:56:09 -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 893E0B810A8; Mon, 24 Jan 2022 20:56:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B54BEC340E5; Mon, 24 Jan 2022 20:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057767; bh=d8KuQaMMEpwfYk41SbyDZxgaCrp6MyVMmi879u70yiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+G1ba2FVRaqCyOx4Nizi4mIacyXnMCR8I1hd8PlpxaY1K5KwSEiVAWmnesqVHARY n7dv4d1QkzLYytpq2NlUQqtr3YMOyQNGNem/E6PI9QBXCMsks3Eow1ws1S9k7WXnUr voV3JAIuaeojuigjB6vrJ+uFerkvLYxGZP7eVzmE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Hao , "Michael S. Tsirkin" Subject: [PATCH 5.16 0072/1039] virtio/virtio_mem: handle a possible NULL as a memcpy parameter Date: Mon, 24 Jan 2022 19:31:01 +0100 Message-Id: <20220124184127.597119023@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: Peng Hao commit cf4a4493ff70874f8af26d75d4346c591c298e89 upstream. There is a check for vm->sbm.sb_states before, and it should check it here as well. Signed-off-by: Peng Hao Link: https://lore.kernel.org/r/20211222011225.40573-1-flyingpeng@tencent.com Signed-off-by: Michael S. Tsirkin Fixes: 5f1f79bbc9e2 ("virtio-mem: Paravirtualized memory hotplug") Cc: stable@vger.kernel.org # v5.8+ Signed-off-by: Greg Kroah-Hartman --- drivers/virtio/virtio_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -592,7 +592,7 @@ static int virtio_mem_sbm_sb_states_prep return -ENOMEM; mutex_lock(&vm->hotplug_mutex); - if (new_bitmap) + if (vm->sbm.sb_states) memcpy(new_bitmap, vm->sbm.sb_states, old_pages * PAGE_SIZE); old_bitmap = vm->sbm.sb_states;