From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 DD6FA23C512 for ; Sun, 7 Jun 2026 11:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780831403; cv=none; b=ZA9gvN3BTviNMmX2IFGvn0S7fmwlApDg1+QuhlCoVHQGHjqDPQKHir+hwYBm+fHSDMMzKGGHiN503ZrlrEL4OvGHf9XUfalvmiFnr6tjb4n+MGSswaHPCrz+cgeo6ZM3dc63VFb+HroWH5fYBeLu9WLXAmXsSibvcOmZhpXuwcc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780831403; c=relaxed/simple; bh=IFjZiSwqKHxCIcwpE/RgjCov4hw4GFItjcNHY409v1Y=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tNBLv5NLRs4IlUhjKpZmY0MyIMO1pFR12Un63AuxJexYka8qyyfZHyzlnCR17+Jfog7VkjwpE+nxG2eHooCftAisazB6x1IFko0iSDjT6DyIc/8AvDrFxDE9pOMmzRld+3UMMKOzVJWHPi2j6QCq5NaQ/tQf3gt3E3ExdEdvM4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TgEtj1Hp; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TgEtj1Hp" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-490afc47455so16205445e9.2 for ; Sun, 07 Jun 2026 04:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780831400; x=1781436200; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=xIV+A9YUsZpIvm/xKY9cVRmnS1ILlYLm9GmVIzHOzZM=; b=TgEtj1HphPLWMe9prgMOX2WVJe4L4CZeoxGAHwFprwfA5Sym7FWykojN3LW7cbKe31 UwCEbFxdSXrCFUAP3XH9P5Q9+f8GtA3VyubivapCbFVNkn2zvCtiia3eJqQB5OYnBT7v OkF+Hz4+Efv+NlHw6vYpgaDswuYiPBRycsNwIskql5hWw1EWPv4G5j/asBkRcPBT9I/x lLPd6HITuJalkjzSNiJNvg/UaFTmfdD7c5nb4mp9H4wCaxmDg9nZqP7qhDg5QGeAFP/5 jLWzelX8RfbYeXcDp4IlctDdCMiwIHQH1N2d41UL9cmTY2tWZJKyCqudeRLNGPZcJ89k v8VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780831400; x=1781436200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xIV+A9YUsZpIvm/xKY9cVRmnS1ILlYLm9GmVIzHOzZM=; b=Xaeqsi+kEF6r1/F2IsJpPtXWB8rQxGJbPqkODByYM3szZ6HwT0we9RgC+L5Rrglllf EEo4mQV7rxbumzY7bLJlXjYOO5CDzTylvHRRUyztqiJN1jo1xPVpTLHaUUpyzMdURuTF Jy1BsTN4TS2sxJ8ZWP/bue2H1wTpBt0U3lQwGpZnFMY4Sjsnh8o9/ncl4pvFwLVBadyh cOTx0RGq4SNaRTjDi5+9P6kYuD5aLKdRwx0WEWbjt3NqIZmoHX1+x5Se/DcprwWFXiZD DwCiLKtKaZ9SP4ZOOMC+Oa0YbKByr0Z5VOLTk6c999gSPiSVmChlD5eoQTjzNZKPiyWi LSAA== X-Forwarded-Encrypted: i=1; AFNElJ/BLZG+IEeH/A/a7zFxGEK6+xTaiH0/MUxVySBiyvk0Z+RnJuVHfUnBxX096+JAgD8iPHfhu8M7K5FcPgQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyJ4FuK+RSX47vWbWaGlOTgfpXUeo5MZUCZCAiDADDSiWdScR2j uvVtAF22mMItevBehXsXEkzi4HopW4B0PbHpE4YP2cQMO8fpmXauBkkE X-Gm-Gg: Acq92OGqTx5a0KPaRr6LhIgQYTWQ5OnosR4bmKfv2kgdNbWlyXDoE0rCQjlSkv4o9UI kuwsV1eE+I5zVoxOD2MUWM/hVNavZjNS+A6F+nuzsT3ga2X086Ji+P+i11ieSfdDsis7BCdUj3G QD+JhY3LzBFNQs4JxPrHNAkKSa+igSLHNkmPD49IyyoMCdfsOIpv67RMapFzBfRB1PH6Tvrf6Gr Rbg6DibJc0f1eGHfKvGtSkT5FbrQ2lXjonAje5WXBxiBPURcrtoIKRdPfofjFlvJ+epNZYj90+M l0tGwjB05pVNx62wRHD5bPl8kRemKopp/9UUu49jQKGNzVryWmGP9EUS7JltiVIdxizbsRrHb8w +z9gFMs0/ZRJ4TfhLVF4PXdNLbxmzHmZbPirV4iOXacGEK4jrtQRK9dZP1F4a+jUK0cbC660+8W UfW2WkXW1vMWLnT0qzdJfbpWzZ1YAGLgc4V5ELCpaXvb6D977S/YeUvQp6qu5TijfZKTH2/+Y9+ SwoVSMx/Q== X-Received: by 2002:a05:600c:5246:b0:490:b55c:cec3 with SMTP id 5b1f17b1804b1-490c25d4c13mr183188405e9.12.1780831400348; Sun, 07 Jun 2026 04:23:20 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bda4fd52sm286426225e9.0.2026.06.07.04.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2026 04:23:20 -0700 (PDT) Date: Sun, 7 Jun 2026 12:23:18 +0100 From: David Laight To: Guru Das Srinagesh Cc: Ovidiu Panait , rafael@kernel.org, daniel.lezcano@kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] thermal: testing: Avoid NULL pointer dereference on missing arg Message-ID: <20260607122318.40696a11@pumpkin> In-Reply-To: References: <20260606210420.2311145-1-ovidiu.panait.oss@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 6 Jun 2026 19:52:49 -0700 Guru Das Srinagesh wrote: > On Sun, Jun 07, 2026 at 12:04:18AM +0300, Ovidiu Panait wrote: > [...] > > To fix this, make arg an empty string instead of leaving it NULL when the > > separator is missing. sscanf() then fails correctly with -EINVAL on it. > [...] > > --- > > drivers/thermal/testing/command.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/thermal/testing/command.c b/drivers/thermal/testing/command.c > > index 1159ecea57e7..5513a26feed7 100644 > > --- a/drivers/thermal/testing/command.c > > +++ b/drivers/thermal/testing/command.c > > @@ -150,6 +150,8 @@ static ssize_t tt_command_process(char *s) > > if (arg) { > > *arg = '\0'; > > arg++; > > + } else { > > + arg = s + strlen(s); > > } > > Here, `arg` is made to point to the NUL terminator of s. Couldn't this be simplified to: > > arg = ""; > > to make the intent clearer? Since `tt_command_exec()` takes in arg as `const char *`, > pointing `arg` to a string literal is fine. > Except that 'arg' itself must be 'char *' otherwise the '*arg = 0' higher up will fail. So you'd need to handle it differently. -- David