Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3601888pxb; Mon, 24 Jan 2022 13:15:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcxPLZqiu8CoUSiGANKpKaVen4jHFWp9uoVxT5doVF3IGWHkmtAZPNKN644/1wOK9LUPPo X-Received: by 2002:a17:90a:1b0d:: with SMTP id q13mr226951pjq.14.1643058836611; Mon, 24 Jan 2022 13:13:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058836; cv=none; d=google.com; s=arc-20160816; b=zZAbMTV1iLp0SOH5O6Gp0UsUScflJYD7wFm7s/AZMZoks+ImxfcDPYC1OXXaIAkHRK yYf/A4y593Tl9bDxGSFlMo3tBmYsH1JU0fcf/XzCW754wuw763NNblJQ9J/OGu1x8g0c lsHH+ObGLDD1zhX3fk+nuoEL5vq+/FEyiLb+IGoW2nV/PxrLMijnZkm6qI2NtNfCBZs8 1tdr1FnA5ypH3aZ0mopZbeiSjYCzijG8g6L9GFzwE2kRXao/0stIjgzzmrJrBUy7rKlj HlzkcEG74YuR/xSzUvYuF+c5IRFCI8yVQwwbeGJ7lgmStunxoX2VgbdSA31gzoSTBM6w Reng== 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=QiRjVZ+mywi1kl8z62G/rknSlFjOKzc2R3vVfulephw=; b=XzPat+kfXI3/cQiJ+Vmvk7j6F+tdRpJ3Rlsg0X11cb4BhtEgkjAybTleOMnlbCjxk3 F+lEUxJg9O4yMZSY0rH46OD+LKcjPFMjpZOvxDuFSTTRWDIYaRCTYmzB6XZfmJjmw4T0 c43CoeWc3LnpIn6prZroUN7Mc7/79taI1tYohLEp6VVK2vy2O6XanWZYYIODdS4LSBQX vYqT0GntLHfvMJsNzyzM87qoq6ZZoxNhmpPO6PFIVomYBHkeoYJ7yNgFZbeTemD1Lohb lg64xB071FPxDjuuLMGwHCvvDkeeefjC7J6RC8zINSIBm6adDXSrnCH6i2X6hnrPzERs Nl3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yOcWqydE; 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 h3si9230016plf.203.2022.01.24.13.13.44; Mon, 24 Jan 2022 13:13: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=yOcWqydE; 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 S1386970AbiAXUgL (ORCPT + 99 others); Mon, 24 Jan 2022 15:36:11 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:37336 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346307AbiAXUNC (ORCPT ); Mon, 24 Jan 2022 15:13:02 -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 8465E6090A; Mon, 24 Jan 2022 20:13:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51E94C340E5; Mon, 24 Jan 2022 20:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055180; bh=uwnNQ8+gL5Px1mLCB6XCmWKrCo2atGyRJwY5yIi3pNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yOcWqydEh41D9gsjhpp7s/kylf/Mmbb9hh4fWSXVwKQK3swa4reJf97B/kB33IMU/ s96sIHCf3aLGIMuUa5gR2qG3eTghciHs0fKAZqgBgDWMwkCzPXuGtQSMiOE11+wDkE ZAUYEjBG/iLTM3pYnmVOkU3EolqnioRJgVMcu2nM= 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.15 067/846] virtio/virtio_mem: handle a possible NULL as a memcpy parameter Date: Mon, 24 Jan 2022 19:33:04 +0100 Message-Id: <20220124184103.280002812@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: 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 @@ -577,7 +577,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;