Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4158778pxb; Mon, 27 Sep 2021 10:35:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpkwm0PD+ORkzVJqZSZRSQ58c9fjcC/0ep2kyLK246YPC2ru1CkbvixXJfrWJxfnEhOr+6 X-Received: by 2002:a63:df0d:: with SMTP id u13mr708496pgg.417.1632764101919; Mon, 27 Sep 2021 10:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632764101; cv=none; d=google.com; s=arc-20160816; b=eTKIrl9mg7XugJTeK8mW5s3z6SrEHqKsNRYM1GU9/vA+g5ig44X9RpW4nnTueE6RBL X2XXR+16KEm3TnOj1UjrWZ3DgTT56jSwPBS3pEYsEdEpeFm14rv4NhPM1hy6WI4ocqD4 Wd7rR0gwYSPmNFweq2IiGnBJBNlIAQDe57PGwtw7/cZDafO4RH5qZ5IIAVIdARMYNryZ p843SGEA9dD6DqqsnrTFh8zoTUuizb+rSQth9jyRJygvlnriQJSD1/JzepK2iq1976Mn H2VhHnq/8Z7s0tI/XeK/mFYQ8xED86kP/6gbkoaiaRCgCmiIklLx6zSxzpDFIhZ+fp3T YUvg== 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=Uw9/mWAqkdpAr2w8KjHeRzPJqDX0nR9xLwaIw9n1xvU=; b=kI2O07L5sA39shxjInlJM9r5tcpXC6qWG6jXGLPM8P9pTSa4S9Qu1vdAhvQxpQ986E FmQqUJF/vtdZUIvlO7qEULcKirV4twmuvT0NpoB38AS9YE1FKMn40VkEbtmB73f0sU2K POijjwv+fEvF2vRZqxpZzuc9Z00GkHJBg1Vt/6YMohDVE818L3S4/SQHi/Bu446dyKUm 5emaMPgCCC9r5zGI3+PqAqZS2ZCBprPnM4lJVBw5r/RHWH0PyTfZLdUykEA4HomRoWP4 7kijc+5exSrJvZbkjSqZltFQTkNCYmXtGQe3Rtx+kg/XRqbulzy7ihIBbcHO3W6wp/Ru mAFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OasreuGj; 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 q17si22467670pfg.312.2021.09.27.10.34.48; Mon, 27 Sep 2021 10:35:01 -0700 (PDT) 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=OasreuGj; 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 S236433AbhI0Rfc (ORCPT + 99 others); Mon, 27 Sep 2021 13:35:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:47652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237110AbhI0RaJ (ORCPT ); Mon, 27 Sep 2021 13:30:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 31948611C0; Mon, 27 Sep 2021 17:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632763091; bh=cWf6s3w5KufPS3NvTgxGdIoyfoTRIo+gHNVhlZgTZa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OasreuGj+Hg43jDtjqem3u0qJKPFhOe+xl+M/ZvXb0nry+Q+aX41YVIQosW8ViEQj LKwcSwq4KBSorWJZZAig8gMSZA77lHZTPpAbFrrqbm0aspDlmXOt8HkAZV6ZtxGzst //kiOB+x8inKeki1wlBt95TgO5dLenrLKE/u3A+s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lihong Kou , Christoph Hellwig , Sagi Grimberg , Jens Axboe , Sasha Levin Subject: [PATCH 5.14 132/162] block: check if a profile is actually registered in blk_integrity_unregister Date: Mon, 27 Sep 2021 19:02:58 +0200 Message-Id: <20210927170238.000521907@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170233.453060397@linuxfoundation.org> References: <20210927170233.453060397@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: Christoph Hellwig [ Upstream commit 783a40a1b3ac7f3714d2776fa8ac8cce3535e4f6 ] While clearing the profile itself is harmless, we really should not clear the stable writes flag if it wasn't set due to a registered integrity profile. Reported-by: Lihong Kou Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Link: https://lore.kernel.org/r/20210914070657.87677-2-hch@lst.de Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-integrity.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 410da060d1f5..e9f943de377a 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -426,8 +426,12 @@ EXPORT_SYMBOL(blk_integrity_register); */ void blk_integrity_unregister(struct gendisk *disk) { + struct blk_integrity *bi = &disk->queue->integrity; + + if (!bi->profile) + return; blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue); - memset(&disk->queue->integrity, 0, sizeof(struct blk_integrity)); + memset(bi, 0, sizeof(*bi)); } EXPORT_SYMBOL(blk_integrity_unregister); -- 2.33.0