Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4144289pxb; Mon, 27 Sep 2021 10:16:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+dICw0KdAjYQMD2PFTH9ybltzJZek7IU+7sZjZ+zClNXuVamptWacnFhT9+fmd7xAkEFY X-Received: by 2002:a62:52d4:0:b0:43d:fe6a:b51d with SMTP id g203-20020a6252d4000000b0043dfe6ab51dmr1085017pfb.49.1632763013189; Mon, 27 Sep 2021 10:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763013; cv=none; d=google.com; s=arc-20160816; b=xOOm3gQHJH5vmOgwJ0u8ihswmsOVnT2XwkuaZBr+aFaF7+dZyLDCLOyvqSomSXDkaR w1KwWwelA9keHjULIu4jly1v7kLEwaaZG26Xtho3COUihSzVI+R9detocrZd144rcC9M TPkMpux7xQE38HJVvKXfP06ocnW3k0XQxM9y5seOVzsKOLlJvka7SGe69x3z/wZlEvBU D6ktttOVEkAkL9ujphwwZFds/HGQTS0pvXwbU4WuUtfvLpU49rNb/4NDqCC1QTz/3VGN GhhjtR6nQy7yP9w9/F5iAmdIIt0Hgy4bbZcgTTiDHYFPzx1AJBcvuDjQAgKi+/G4OE8r ETpw== 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=gj8harWufxZPAhDRGiIKbsSKuVL790iMb9N/UGyDZqZDOeNSvrmlckypTt0FxdeXyE m6yOVaa6wflQ9ayhsVoygE8tMs3rbcx2yPnHWDFEyQzuGRFJ69KeXkwArB+E/gIcwons Q/jH7wq/sE0RmVkdt1lBBdvE4f8qHH7hF0u1Dl0unSf8WAU7A0UqAihYHfhmULC2k3IA Fv3Sf0X+bamhN/LLGK+0+WU9dsDqJ++KVvLig5RX7A8tjWTttZSc6tS8y7YJ8yuSiLVx /oVLoVjyel02Eyn8DqvS7fsWrolZKXk6toFCU6RBKe35RGLbR5r1RiHevjBomv4HRrY4 Zhkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="FptXh/JL"; 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 u24si24956186pfm.250.2021.09.27.10.16.40; Mon, 27 Sep 2021 10:16:53 -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="FptXh/JL"; 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 S236487AbhI0RRe (ORCPT + 99 others); Mon, 27 Sep 2021 13:17:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:53906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237281AbhI0RO3 (ORCPT ); Mon, 27 Sep 2021 13:14:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7D786135A; Mon, 27 Sep 2021 17:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762607; bh=cWf6s3w5KufPS3NvTgxGdIoyfoTRIo+gHNVhlZgTZa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FptXh/JLZBP40TxzEfHUvhWOrlLAy46kHLp6C+vzoVco/dKY77N/YS30BYnE7u34U gPPrME3jUzlYR3/ALCkx3JvtZ+pvuaVCiY5QrLiofnOhFK5g9bKfs2ZBZGvfqyz88x PfBcGxdoXY5dWQ/NA7s6J5g5wGzh+fyUiRl/oLo4= 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.10 086/103] block: check if a profile is actually registered in blk_integrity_unregister Date: Mon, 27 Sep 2021 19:02:58 +0200 Message-Id: <20210927170228.744860402@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170225.702078779@linuxfoundation.org> References: <20210927170225.702078779@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