Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp729714rwi; Thu, 13 Oct 2022 04:37:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4e8j9udWqsolDeY8oOixrdrigHj2x//tyHZW/5VOizXKpqdv4GEtOsqDmdzR2DPPtAL8SA X-Received: by 2002:a17:907:31ca:b0:780:2170:e08c with SMTP id xf10-20020a17090731ca00b007802170e08cmr26127516ejb.145.1665661055909; Thu, 13 Oct 2022 04:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665661055; cv=none; d=google.com; s=arc-20160816; b=icjTvrdXi17+yvLPOtT7bdB82TTn6KbmxHDdB9jfP6uf9dpmvsHEGLVcVFmPDN3K4o QjDPRJLAorKH5sCAI31RKvJEy7lJa9iGuvWjMXiFpx4cEEbh/ZV9sN+7lZ1GUb7j/Nvh kikfKOJfx56Bjg0yBBrP1jRLZXk0AEpyWHbZvNuezthqldGsQs+AKwZ9lD8rCMB6DMcU na1YDgyn88P/LU5fAwMBDtOZoPFphLSjqU6u9EdNcASMhKiDh8o2v9s0x8JhrYGt5qak TMLJBkrfVBUbizgXluUtik1jb5zNU32Ir/Yr/tuUl4rzqJg6HP2tJhJ4IoUWN24RsRyb d2rA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=I+EwayS2mXiTVYC1YgiXzkHmIUayGLlFvMVLY98UxeQ=; b=nkcmbGUQoxjItHw/C12T2K61L6spzEMNys7VxQ2Apx+Bra/ddzotfal8fXmBKLE3Rw P5CTUPCj9for3hbObdfHr8x1JB/TqGaIgTcozQclqgsucMaLN/hFiRJn19VrokcwqMOB I2GJoZ8p1/g0b5wp8/NalLP4HltbnA7+P87N0uraDe89+2c3faxbozmrNz5uVD2jq0uA zGNu7qpXJm1346FR217zL9WvKXjn0dtTJbgxjFro8NEdNwoTyTrrCod8zq10+DGypoN5 b/jXpCmKYOPyzBEEEsaq5fp+J4Lsh0ZH4v1cQzzR8xvmkJXVwV+FwCD9YR0T1mRnr7uY l7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=W0aYpoC6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd16-20020a170907629000b0077bc1269f8esi18910259ejc.424.2022.10.13.04.37.10; Thu, 13 Oct 2022 04:37:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=W0aYpoC6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbiJML2x (ORCPT + 99 others); Thu, 13 Oct 2022 07:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiJML2r (ORCPT ); Thu, 13 Oct 2022 07:28:47 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13AC6125853 for ; Thu, 13 Oct 2022 04:28:39 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 27F155FD02; Thu, 13 Oct 2022 14:28:36 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1665660516; bh=I+EwayS2mXiTVYC1YgiXzkHmIUayGLlFvMVLY98UxeQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=W0aYpoC6nbXXubmUlI+Q9zdZHp9twEt3VMTvrO6o9Sa6TzimBpUS3j0ZtcRFhaQJQ QPEBgCXZnX8CpIFvtcEFLxcdJxMpb/xmRO0tR2PKukmgjbJG15j9SqzC86A1b1DcCe A6nVMambHSTvzdmnPyRzd2ucbNwVyD/eAQS22mueZ15uw/mfTPHTIKBqgsijt2xfxV wRH06UbZ7WwAY5hF4Uvpd18VEIzVTa+r32aNIsXjk7dB8yTdEjkG4rRwk5O7MIP6Ci 4FgNIddcFShvX4FPmMigDdUFSddiFq3/i0B9UmHP+Ac3cjv4onKeKgcMVHIg0YQEfO X0czXvbfkodIA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Thu, 13 Oct 2022 14:28:34 +0300 (MSK) From: Alexey Romanov To: , , , CC: , , , Alexey Romanov Subject: [PATCH v1] zsmalloc: zs_destroy_pool: add size_class NULL check Date: Thu, 13 Oct 2022 14:28:25 +0300 Message-ID: <20221013112825.61869-1-avromanov@sberdevices.ru> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/10/13 08:08:00 #20452392 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Inside the zs_destroy_pool() function, there can still be NULL size_class pointers: if when the next size_class is allocated, inside zs_create_pool() function, kzalloc will return NULL and handling the error condition, zs_create_pool() will call zs_destroy_pool(). Fixes: f24263a5a076 ("zsmalloc: remove unnecessary size_class NULL check") Signed-off-by: Alexey Romanov --- mm/zsmalloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 525758713a55..d03941cace2c 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2311,6 +2311,9 @@ void zs_destroy_pool(struct zs_pool *pool) int fg; struct size_class *class = pool->size_class[i]; + if (!class) + continue; + if (class->index != i) continue; -- 2.25.1