Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1655134lqm; Fri, 3 May 2024 02:20:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtJbunTLiJtQYxqRMV5JvjHXZzzNxUpntqIDlEpbTUQpdHymF9Scs7f/UirpdPG7l/omID935BMArhUkdImtiTboUeq3+sMt9xV0bIgA== X-Google-Smtp-Source: AGHT+IGdNMWKgsIvyILwV3RrKFKZmuQiR6qg43I0tTf5AMF+UKZZTXyFQhkThlkXrWzy8+QJtBQ9 X-Received: by 2002:a05:6214:2aae:b0:6a0:b905:97b1 with SMTP id js14-20020a0562142aae00b006a0b90597b1mr2297967qvb.51.1714728051028; Fri, 03 May 2024 02:20:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714728051; cv=pass; d=google.com; s=arc-20160816; b=OGE4kCjitjRPsDAaT31EgsDA4VVT70SpFjjBqFxOx1ol2F1tCpa7FVPgMB1c18w5Oy zZLCs7ec2HttwgI1VvFF2TcUU/fGD12tqKhPrPyechs3EfDYQ+Ga1atdDhkMDWjkWicv Mn47Q7RbrMHFZ+xirudUjNRCVZovG2QOpF7E1UndKOneyNKuIV7EjxMucTHrHI9fN4fC C0rvqVa6hgtlbQaIUyEzvRX0W0oowf6/3MfHPPSKfIuPa3VfbUhgHBmlDOa3SSZ4sW70 dgmkkesvjcX9IedAigR3RRawA/Uv8qgW81pHNjsWq3hVirlRCRKtTk8ixPUzAS4ahEfP 1JKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RO5gNR3hr1OwBA2XPvPltsruJYPfqcocof4eacOx3kQ=; fh=UKstJvjqAQ3P/Vkvglih02Z8FmmRnlaJbql9clnU9dw=; b=SiuaUcBsbsUx6JpEJHm30CY3i3oKlNBcrDCGrrc5Emy1jPVBMsJKhSmseaVqwcSnm6 LltUqmFrdg+daNapR08xKq5iUaesE+F2L/Gf6jbHCRPA3WI9PJndKVeFrsZpxSZNty/X E6lr/7EZQquHk4WwyJTBOwChRvwDZ1S0rSjQUoNAXra2EuUr8Lpqwu0JKhETytPf7waV lSTqpivbdSj1QVWJTAt2N2kJULto8UrXr4+l/i1iniugi0jUVuGZfio5eI5x6RZO1EPo zM+mAdKkVHXfYNE4QmAVPTB3WOXMXQ1zVTxWT++H50elZyAm7Qv/Cf4EBDgGjUsXHDx1 b84w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fjCBSDLc; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167448-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z21-20020ac87f95000000b0043acfb0c292si2950757qtj.601.2024.05.03.02.20.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 02:20:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167448-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fjCBSDLc; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167448-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BF0E31C21C79 for ; Fri, 3 May 2024 09:20:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E811152E05; Fri, 3 May 2024 09:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fjCBSDLc" Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AC96152519 for ; Fri, 3 May 2024 09:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727936; cv=none; b=l/DSCIYeOB0Qw+VqtVP9nhsasgEE1M0ZfCI3klQTEQqzaXSp3yVJ7P2VWrqPrgkTjUeSL9ZvdN5AJCO6QduzTwomMweYRMYjpul9r8Mxn/XLo8TTJbDuH+7Dj7oFW7zgXEJrG7OnJuEHJSumeXdniV/nMdRin0/jg1yvp0W6lHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727936; c=relaxed/simple; bh=4ArJY7PZnBnDWCMCM15GfOZS5AjpeHaFMcDoWz/RQU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UfQUkfLrD+9g1Ym1y/38MlTVInuJKLKhSs9NwpFjC3Nxbx7p6okLe2r0xsllrSHSJ/SHjUY31wF7R4mXofs0b4a8VVVPqGRirWIijtIWwcIzl/CrYHw8YTeYZ7tvOZ9hkMO8+WG4JFrQJIlH9lZEnaujQm/5AjUuauoj5w5gZq4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=fjCBSDLc; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6f44390e328so1157370b3a.2 for ; Fri, 03 May 2024 02:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714727934; x=1715332734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RO5gNR3hr1OwBA2XPvPltsruJYPfqcocof4eacOx3kQ=; b=fjCBSDLcXrBjgqIArQB5S1METL2+kNVYqZnt3HiorwnY6cJ+xLt4Tb1SxeX0q8vcw/ YC/30eNMNrnaKERQxsvfsZ5DErFgNdPnpMZW/mce0M1ia4LlXeiukzYC0BZoAQvuTQ1J SdOBabZYNf4JMjewO+JhJ4zt9A/Gbo5TFkLQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714727934; x=1715332734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RO5gNR3hr1OwBA2XPvPltsruJYPfqcocof4eacOx3kQ=; b=Ivl3QpPTwMq2LV8NPOgQ/teQ2lm7F4MbvqXk1yTlSag/amaMdn1dv0LDp7Skt0f0Vg vNrMdhLT0N6BA0QTtwsIOmhi4q2HWFlgpDhpw+Lhwj2QynMTNqG/hUOKnK/MtB1UJc7K /RwoawcxEON+n+rR7lI56b6wETe6bFeIBmR/JswUNFOrHt8QZrBRBrnNke3PP9lvsGwq TrX0cVyl4Q8w9Ve/Oi4xZNE338SLXf8tW50+Yf0Mb4CXEniDm/WQGxTodP9l4aW8lVql IiPDWZAUiFDE8OcNA5E4Ya9wxtUf+9icu6+v9Ir9srw8KwUYuAlXq64vHOvaMqr19ugk yntQ== X-Gm-Message-State: AOJu0Yy8//BCWdzcuUJPkzs5s0PXvZVniIG9cuZD3+xHBwy5QtsjpTPY lRf/avhEbADgmQHxMP1s9G/AwYt1oaAiZLCukzauxTEKf3EyOp6qNwBkQ7A2rg== X-Received: by 2002:a05:6a00:2295:b0:6ea:f351:1df9 with SMTP id f21-20020a056a00229500b006eaf3511df9mr2343695pfe.23.1714727934592; Fri, 03 May 2024 02:18:54 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:dc60:24a3:e365:f27c]) by smtp.gmail.com with ESMTPSA id j6-20020aa78d06000000b006ecec1f4b08sm2621938pfe.118.2024.05.03.02.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 02:18:54 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sergey Senozhatsky Subject: [PATCH 08/14] zram: check that backends array has at least one backend Date: Fri, 3 May 2024 18:17:33 +0900 Message-ID: <20240503091823.3616962-9-senozhatsky@chromium.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240503091823.3616962-1-senozhatsky@chromium.org> References: <20240503091823.3616962-1-senozhatsky@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Make sure that backends array has anything apart from the sentinel NULL value. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zcomp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index 9fc5477a6259..fdf06fc6b364 100644 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c @@ -205,6 +205,14 @@ struct zcomp *zcomp_create(const char *alg) struct zcomp *comp; int error; + /* + * The backends array has a sentinel NULL value, so the minimum + * size is 1. In order to be valid the array, apart from the + * sentinel NULL element, should have at least one compression + * backend selected. + */ + BUILD_BUG_ON(ARRAY_SIZE(backends) <= 1); + comp = kzalloc(sizeof(struct zcomp), GFP_KERNEL); if (!comp) return ERR_PTR(-ENOMEM); -- 2.45.0.rc1.225.g2a3ae87e7f-goog