Message ID | 20230103030119.1496358-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 4EEC3C3DA7A for <linux-mm@archiver.kernel.org>; Tue, 3 Jan 2023 03:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62B1A8E0002; Mon, 2 Jan 2023 22:01:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DAC18E0001; Mon, 2 Jan 2023 22:01:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A2998E0002; Mon, 2 Jan 2023 22:01:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 375108E0001 for <linux-mm@kvack.org>; Mon, 2 Jan 2023 22:01:28 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E8E81C0288 for <linux-mm@kvack.org>; Tue, 3 Jan 2023 03:01:27 +0000 (UTC) X-FDA: 80311987014.13.80DFF0B Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf01.hostedemail.com (Postfix) with ESMTP id 4F42A40007 for <linux-mm@kvack.org>; Tue, 3 Jan 2023 03:01:26 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=cw0B54ke; spf=pass (imf01.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.176 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672714886; 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=quBw/ujluJ3rNnNfMKVBDJsfvvRIe1fyf1oyveqm1OY=; b=0Sp0AV8hGFl/B7PDdpClg3MHoTPcclSZ2dEjWbondkH2LUl+alU5g4hoVyloY2RSBlc0o/ rIiIX6Y9BE5NHGrlzclhitUfuLTeH6rNySmGaeVegKKECwlUDVDKifyMgQgJ0kN1NGf5I4 5u4V1cMORCjsC/2y7b2YPqZCAf3QZ0g= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=cw0B54ke; spf=pass (imf01.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.176 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672714886; a=rsa-sha256; cv=none; b=lxzziJhfyI5cy+6eloj0pVhw0wc4Gv87jbHsD6LqUYXr5vVsYVfT290w+KMDV2yV/h4MxS 3TtJeiPxvsu7TOvsM0xQE/vCvHiCGjc7T5OyQg96GPgXq/obMmREa/cshcBl0xFBfse7iE eW4rcIU8Z+9jxaFVHw+VUVwGl6AmqIU= Received: by mail-pl1-f176.google.com with SMTP id c2so3693113plc.5 for <linux-mm@kvack.org>; Mon, 02 Jan 2023 19:01:25 -0800 (PST) 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:subject:date:message-id:reply-to; bh=quBw/ujluJ3rNnNfMKVBDJsfvvRIe1fyf1oyveqm1OY=; b=cw0B54keqMMjfjxXPvdfSKFtAdV/6qIqyYsFyMs4XcQgoJ2uSMZCmgxe0U6eaGD4RD J3v4V6eSIrgzEmSWmGPnzo97IafNF2fuEa0ZqyaiKtLF4hHd7pkHa24bsEdPoI7iVSXb +SsWCPw0kOUCmARlNVq9CwkAXgL41NlRhFt5M= 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:subject:date:message-id :reply-to; bh=quBw/ujluJ3rNnNfMKVBDJsfvvRIe1fyf1oyveqm1OY=; b=eFGF8dJkkJAXywfLvBoZmoY2VSO0vO0A6b4Hj8P02sQNbaMOAqGmIdavT7hjh2yihQ ihuAUgdOCI7lXIs5q0KxGds3Hc6Jz4rij+rMYjLEqNC2+YiqNj0CoLz4yy9GdigCQ2oT c9DOrm/EeVglMxK3NcSZa+jA0DJ3b+wpCpab4cPCka6uvUGAo6xOB7/YoEDncsdEhdIW T7yiMfxyyBoDqtoZHeglXKYvvXqxbS3Kgi7EBjZaY39h6V7lSKoSGTsH4VOddye2aLDv fL9tdVR2Rtx/ALXEkM+E4cqczhNFIGv3Flr4owQlF1c30WWbL1Pxy5vC6rs/F8po6Zbx Wbhw== X-Gm-Message-State: AFqh2kqnX3qmWejYkVdP47Majwohda9ww70JI9wE4lhxXLAeBpM56PvQ uYkGxFpYEUZNbNEhYkbxQzlZYQ== X-Google-Smtp-Source: AMrXdXt935vls5I/dh5pfohSB68qQnrMTZKGec2ZB29xqw7PU84GxyU26mWB1gff7duNesjBIZ4rQg== X-Received: by 2002:a17:902:ecc1:b0:192:760f:c35e with SMTP id a1-20020a170902ecc100b00192760fc35emr40224986plh.53.1672714885008; Mon, 02 Jan 2023 19:01:25 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:270a:35ec:5bc4:b90a]) by smtp.gmail.com with ESMTPSA id r10-20020a170902c60a00b001869b988d93sm20838638plr.187.2023.01.02.19.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 19:01:24 -0800 (PST) From: Sergey Senozhatsky <senozhatsky@chromium.org> To: Minchan Kim <minchan@kernel.org>, Andrew Morton <akpm@linux-foundation.org> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky <senozhatsky@chromium.org> Subject: [PATCH] zram: correctly handle all next_arg() cases Date: Tue, 3 Jan 2023 12:01:19 +0900 Message-Id: <20230103030119.1496358-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4F42A40007 X-Rspam-User: X-Stat-Signature: tboiiyx4xe9n6zj6g8smaahoyir5tbyd X-HE-Tag: 1672714886-916753 X-HE-Meta: U2FsdGVkX1+ZtJVSQ6FD9IznWtD7yruZl6o7n0v9mzpPTLnBrZ3T6u1MioqS8+ut+WfNjqEj7uJVz9CGA4ZcU5lugAd+dzXT4S0nLKhiwJy8hRvtOxtgdzBJ0XjT9AwabymbOU5XekWu5K2zx9NmYp9IOTIYilykq5Iiqzcga/66fAiiF2QEi7mllvbpSC6g+bdl/qp+0yBDOtnRIi0S4jlAIzDltbwluEEPAAqRhbd9DZNiAhHtz6ypLKAmLuk2JD05wnPBKB9CxrB3N5xDQ2Ll2rV5/A3P95Hrc9QGnYDiUjskRnuo8d2crr9ooV/nBiHV7F8KjvsKeqrcWn9LmHBdI1MxeJPog+TqkoMTnMqlHPrkfQIoZadmeS30P6G7Q5pV14srBUzFVmI+RWWjfC9DiWOLssIGMXivqOSQzCEjvxcaC7YzaP4dr2FhCzPqnY8oRUp3WHdUTJ+zQ+2BmEET8USdkV5XO7OFKLSgiBdHkc09JNbAC17ds2Gf3Upav0m6SSoI54npK5XyomGr3YqEeyqGnVFfF8YABVtkojP/B/sAMx6CnTfQpc39vA/eDQ2eQkHGwVGyaa7ZlyOgU1Hcjo12uTEyoT9UpHR+9K+RWqzKiB6C8FKodmhH4EPRasGndNSyQ7H1/LQWf1VbX3HWv3AJeHSi6OI7fo0Bx6Kbons/VdEpRpdJxXRVP5NBFgDTLBZDWt9a5c0ngWuf2nCFR9DJKGGddmIRilViVZQkF9IrNu7648eVt4gmv78z8duugK9ak4jOzuf2cBPEkVoGl45bHtXiLFix5p3z46QWrDw6Hju9qSAiCEAmMOMt8KQin0f1LqYelK4d2W2807dUNns3fEhMxEUIFrgGrlUSVj23qWapZZMg/h/Dnqdw80Pjg8JYCCRqfCUrerm3ciN9HMPm8ioIlTIcTOpUyxgaMh7ErAJScmbPRw7akIH3P6Ix+AtLc5JjPARWnEH yMzYMTu7 tmWMsGSohzQg0Z3g6yQNTuj2mEaXBMLMoeeZAMjrmlTo0YXz3zv01YmoIkmdmpVB9bIDqWvR1Y9hKtAOt0bv5WxAhrNSkGf6FKsLXnmc1jFXsmcuONiDEIOAmMwBCfid+qe1W0RwP2EG0Czk+cuSgstQHstM+kmLipzopmD6CBTiVVt1eOvwAtyXqsQ== 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 |
zram: correctly handle all next_arg() cases
|
expand
|
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index e290d6d97047..70c412eb6c1f 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1140,7 +1140,7 @@ static ssize_t recomp_algorithm_store(struct device *dev, while (*args) { args = next_arg(args, ¶m, &val); - if (!*val) + if (!val || !*val) return -EINVAL; if (!strcmp(param, "algo")) { @@ -1824,7 +1824,7 @@ static ssize_t recompress_store(struct device *dev, while (*args) { args = next_arg(args, ¶m, &val); - if (!*val) + if (!val || !*val) return -EINVAL; if (!strcmp(param, "type")) {
When supplied buffer does not have assignment sign next_arg() sets `val` pointer to NULL, so we cannot dereference it. Add a NULL pointer test to handle `param` case, in addition to `*val` test, which handles cases when param has no value assigned to it: `param=`. Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> --- drivers/block/zram/zram_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)