Message ID | 20220816050906.2583956-1-senozhatsky@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D04FEC19F2C for <linux-mm@archiver.kernel.org>; Tue, 16 Aug 2022 05:09:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D412B6B0073; Tue, 16 Aug 2022 01:09:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFD8D8D0001; Tue, 16 Aug 2022 01:09:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B90946B0078; Tue, 16 Aug 2022 01:09:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A70996B0073 for <linux-mm@kvack.org>; Tue, 16 Aug 2022 01:09:13 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 726171605F7 for <linux-mm@kvack.org>; Tue, 16 Aug 2022 05:09:13 +0000 (UTC) X-FDA: 79804276986.11.7CAAB26 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf18.hostedemail.com (Postfix) with ESMTP id F11D91C001E for <linux-mm@kvack.org>; Tue, 16 Aug 2022 05:09:12 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id f28so8440154pfk.1 for <linux-mm@kvack.org>; Mon, 15 Aug 2022 22:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=KdmzXP13CNxy15WwYF58LgbgciSZbTqWHtRKPzesVZQ=; b=WD+/gTBCSHLbVlCq/CMvy4XoQK9mqHwypW9eDbK2RGQr/izdBf8unDeJZ98vVDttyk I7XalW4qBXEyZubojjtoZxKr3mP/tLeVMFSg2M4r6whQFB+usjT5Gzmavu8S7/rAJT/m nbyzocIyxua/k701B0Qr2vV7mraykF6bUKzd4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=KdmzXP13CNxy15WwYF58LgbgciSZbTqWHtRKPzesVZQ=; b=AfrCcjBw8bDTCq8j+6aScTvtwevYAC963llkjs4ugCTZNaprliuy3Jiv0/KYdAF0Kj L3RxYepVibIeOD1ID4czOFWQr7lZ4jq05Mm8L8cE/kYdVdVfh6gSM0fB9Uk2nzaSWR11 MCoi3X3r3cEEfUrn75qcRslQ9dBTMoLEcT+Gh9KLocIPkr1k2NG6qSUT6PqpSjRMc8JE SUNS+a6nnO8iGTWGpm0y8LhmE+8QzMJVwTQBqAmKjgJLjfI2Tvp2v8GJB3AY7FufU0Y5 b8zITf8cd63GemMxhz+kb6quClVoqpgE9I7iBJI5Iec+axdB5TI8gIHXxsUJd1RoxrGl RVnw== X-Gm-Message-State: ACgBeo205UR6rWn6xV+CFZE6n3Z2cPzcvizcPyVxWE/D1vxulBPgUhie nRMlK1/1awgGerZ6aNssT1wvrQ== X-Google-Smtp-Source: AA6agR48kTeSKkrtvQ8tb5usR+/EYoYHUSB8vHFruj5BBWEQ8HYs0FVXAl45joibuxZasZghOpN36w== X-Received: by 2002:a05:6a00:2185:b0:520:7276:6570 with SMTP id h5-20020a056a00218500b0052072766570mr19681095pfi.84.1660626551898; Mon, 15 Aug 2022 22:09:11 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:4b3e:670a:79ec:7666]) by smtp.gmail.com with ESMTPSA id x1-20020a17090300c100b00170a8973137sm7911363plc.17.2022.08.15.22.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 22:09:11 -0700 (PDT) From: Sergey Senozhatsky <senozhatsky@chromium.org> To: Andrew Morton <akpm@linux-foundation.org>, Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky <senozhatsky@chromium.org> Subject: [PATCH] mm/zsmalloc: do not attempt to free IS_ERR handle Date: Tue, 16 Aug 2022 14:09:06 +0900 Message-Id: <20220816050906.2583956-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660626553; a=rsa-sha256; cv=none; b=A6xicWaEKBVMUNtDW8MAEYbB6cBBLp0Fry9cxIJFBSZ1DQcwK3IXiBirxZvRNnpX/mS0Jg KJ2FHAhVkvm+x1DTQVJ2ejywIBUVZO+TR4VsZ65U2d0/gk8DNAtWxKs4naFXlfsy53qe6F bX+7pp3enhVHol6eKn4kF1gBGXyTFPY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="WD+/gTBC"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf18.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.175 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660626553; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=KdmzXP13CNxy15WwYF58LgbgciSZbTqWHtRKPzesVZQ=; b=of83IlquZluUDt4jG/yfTFsDOl6hFcIKNlBMYjA2AH5hq4Bf9zjby+Yjg4I+Z8hNq7lLta E/S0ptsaRY/ddE5YYqNizvpVrYrpp47/Ivr2AuD+W2U5p9X0sukaHVR4I8drTWN4EvNHR5 tHvm5DrB2dbREvmByNKpOsEZo7guuis= X-Stat-Signature: qf11hapuz88exqu3hkabwjagzu5e3w8x X-Rspamd-Queue-Id: F11D91C001E Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="WD+/gTBC"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf18.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.175 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1660626552-319802 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
mm/zsmalloc: do not attempt to free IS_ERR handle
|
expand
|
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 99d93a48cbe0..7b3bffc06078 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1487,7 +1487,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle) struct size_class *class; enum fullness_group fullness; - if (unlikely(!handle)) + if (IS_ERR_OR_NULL((void *)handle)) return; /*
zsmalloc() now returns ERR_PTR values as handles, which zram accidentally can pass to zs_free(). Another bad scenario is when zcomp_compress() fails - handle has default -ENOMEM value, and zs_free() will try to free that "pointer value". Add the missing check and make sure that zs_free() bails out when ERR_PTR() is passed to it. Fixes: c7e6f17b52e9 ("zsmalloc: zs_malloc: return ERR_PTR on failure") Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> --- mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)