From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 31E4B224D6 for ; Sun, 7 Jun 2026 20:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780865225; cv=none; b=gdY0Dc5FVdDgZsJAHducpMLR5fQUGfrRfWYKxrg8jXg/jbLRsljyR9mb66JtqS5ZAgjK/OgrZKq29eaZArXZ29mujfPwV9vA3X9sm77MEE0Owoy0wbcIjyPPNOt46eGu4azirw5sgU+i6rKs8kbruTZdXFQttRuu1dXcJAvf44k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780865225; c=relaxed/simple; bh=ad1hq5JNhLtXzY7IPHT3fS14o1GnWbOaJ778Mf40PiI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lvtn3WBu9ScpFNR2YgK/QltLzKO+EAVOQe0FwqT2ZUgtzbLsWeiAdbOmAuBdpj6ArMPiXSKzmcUAYindaCtAiIe6lXUVqYAy1DscKP1ELDVM2Gx94xrtw/yro5cZRQW0OJDix5r94vD/o82zXP86kfEjS+2Vasj/7NSMsJsHv24= 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=RMDQzDnE; arc=none smtp.client-ip=209.85.128.53 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="RMDQzDnE" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490b4e1ade7so39132165e9.0 for ; Sun, 07 Jun 2026 13:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780865223; x=1781470023; 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=E0fGqOLKGiTBs4GzJtJROxaA/ChE132hfn8KfuQAtzY=; b=RMDQzDnEMZPtO7WHex3XB+RyYhJo/U6JTe0NPjDhCcVPJR1x2QVYMCJg42YlITmpQv SemgIA9DEidSFpMOLygDC0fi2rDagksRwddSjC1HPDisPvRl1WS1HZRk4PgHQenOOTpP +PL5WNVyal5Bya6NXih9QsH+a4hO1sHsqjs7hGN19KazA734abQx7Qs39woN8w0uAfSC JEwgo8gRZUdYc9blRwsos4xtUfy/HOVqU4JMgbsAm/ZyXgyC+CCK6sBtEWd35YNsKr7p 4Evy4ejoNlHObTglzI8LGJBXyuolEn1bBNq3aYRbrSosE5iTLkvn8XKsej7Oi+K584Mc 8/vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780865223; x=1781470023; 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=E0fGqOLKGiTBs4GzJtJROxaA/ChE132hfn8KfuQAtzY=; b=ThAr3t623kfZHG6S3JCgB223P7Xyemt3WZ2i+4mdDypzWcMmZ6PTRoNIsl4q00zVqW J49auG6CK03r4OCoh9bobrJj6POVcXF70aK+wUlNcVNbsgoxnOi/Mb9Ha/ekZddtbobQ QrG43yQdZGXu8TYmTj7zDfpzqv09JeDCo/+zqB8YXdh5sbpK2s7q0GFH5mVsMpmgXOnt 461lIZWZIghuOxux+LUK0cGCLNO6I9Opttar4/Nkt6QIvcpXRLwqnyr0XXMCeajqu9+n msRyq79fld5aFIdVznPkhtV/ZK7YtAl8ntfK+93CvmXA6LSDf3nIyUPywxFovxuObdS1 y/GQ== X-Forwarded-Encrypted: i=1; AFNElJ8e52WRZZyHkpx8cOPyfP6p4cTMRuZ6x5j5UxOoepchyhNcit5tUnBnYX/6sFw+FbuQvndJzKz8Cr3IOMg=@vger.kernel.org X-Gm-Message-State: AOJu0YwjGOhMKd13R43j+i9+H9SuTxh5XOyUu48T+4O2OK0msAE04j+L T62roAewx4s3tTN1RILPzTstwb0lkEL/7yNjqJ+ytzvTdtX7Bo0G34/6 X-Gm-Gg: Acq92OHJeuHbiRDI3yB1D7TFm1ar4OSuFOaljjdd7uohEHFQZv8zG6HUR/iTkv0S1MN LKgwpVyvM4gVCPC082oRMUOZ0f4Nu6hYRIYfHTird1H+mLyAS8j/GAhaF7JISUhKvu8p2vT99hv IxKD3c5RNV48BbqgHH7OpA2gisXfPP1/rxiiFbUHCpUEkTeUAOXIFXc7PagIEDj7BhcjzyS28BZ Bki/uARjMrQrAadSstkCiAeSAMpJ18AnPe8UwTf4Tcde0yQ74JVMUyyZtHAnRWdDHpqbSvc0jiA 3hCbmxKIKaGvNRJyfyYVHlbuxqmtYSEDWIPHtFK+qvVnrcDFEqmT3f0Z4tBitOVMJfradKFtpse chrTc36yuOtJusrMquASWIRXF5+jrhRguLE3pIg3cJRFox+4bzbcNRDae27xKsnx/dV+6wH+uVW lJuuTFLzyQ6DwcTg8FvrWZhXRNyieKf1hkHob+xWPXJg4Xn2gB0b8++y2c+F70GQhsyZOf6Ro= X-Received: by 2002:a05:600c:620f:b0:490:5074:651e with SMTP id 5b1f17b1804b1-490c2612cb7mr187071515e9.25.1780865222444; Sun, 07 Jun 2026 13:47:02 -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-490c2c9ebeesm182835285e9.0.2026.06.07.13.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2026 13:47:02 -0700 (PDT) Date: Sun, 7 Jun 2026 21:47:00 +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: <20260607214700.5c5e88b6@pumpkin> In-Reply-To: References: <20260606210420.2311145-1-ovidiu.panait.oss@gmail.com> <20260607122318.40696a11@pumpkin> 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 Sun, 7 Jun 2026 12:55:13 -0700 Guru Das Srinagesh wrote: > On Sun, Jun 07, 2026 at 12:23:18PM +0100, David Laight wrote: > > 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. > > Sorry, could you please clarify the concern further? > > `arg` is already `char *` (line 144), and I verified that my suggestion compiles fine. But "" is 'const char *'. Which is usually a compile error. Unless the kernel is compiled with some permissive compilation options... -- David