From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from luna.linkmauve.fr (luna.linkmauve.fr [82.65.109.163]) (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 D61AE2F693A for ; Thu, 11 Dec 2025 13:43:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.65.109.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765460642; cv=none; b=W3IeK2jdF5k4RujagYTji6eeg4ITeevchcqRP7MMy2EDnuB2fVfRLkQ+H0uaXEDmX+QSICbANUTxxMfE5MRMjCLkzwSQ2pqLmrdeZjgZ0A2dHB68ApF1eTdeHEURtSDeBPZZYbzBiwucDBB+CT7OWUMzbXiUNbMY39gBwrOFKpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765460642; c=relaxed/simple; bh=Fv8KPVNTtx1X6ipkTEf9jtD9YWLbt2XdQJVgnEpewro=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L+aCOaQlPVOOP6EYgtZHqCjOxzLpgcYtegJniz/iE04ZyadJK9HJqeLElol7oKM2/N3CL9sn6xepSZSKIku2b3qdv3LxInM5bhlgqSoOFsJHL0uzJoac1GFbHJ4RBy4qA0rASFiY2rFWZAFCB4OM4bsugrEnZk7TVZ92yyPh4JI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linkmauve.fr; spf=pass smtp.mailfrom=linkmauve.fr; arc=none smtp.client-ip=82.65.109.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linkmauve.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linkmauve.fr Received: by luna.linkmauve.fr (Postfix, from userid 1000) id 06C8CF43933; Thu, 11 Dec 2025 14:37:55 +0100 (CET) Date: Thu, 11 Dec 2025 14:37:54 +0100 From: Link Mauve To: Haotian Zhang Cc: srini@kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nvmem: nintendo-otp: Fix potential NULL pointer dereference in nintendo_otp_probe() Message-ID: References: <20251210033803.1720-1-vulab@iscas.ac.cn> 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-Disposition: inline In-Reply-To: <20251210033803.1720-1-vulab@iscas.ac.cn> Jabber-ID: linkmauve@linkmauve.fr Hi, On Wed, Dec 10, 2025 at 11:38:03AM +0800, Haotian Zhang wrote: > of_match_device() may return NULL if no match is found. > Dereferencing the return value of_id in nintendo_otp_probe() > without a check could lead to a NULL pointer dereference. > > Add a check for of_id and return -ENODEV upon failure. > > Fixes: 3683b761fe3a ("nvmem: nintendo-otp: Add new driver for the Wii and Wii U OTP") > Signed-off-by: Haotian Zhang > --- > drivers/nvmem/nintendo-otp.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/nvmem/nintendo-otp.c b/drivers/nvmem/nintendo-otp.c > index 355e7f1fc6d5..89b15a58bf88 100644 > --- a/drivers/nvmem/nintendo-otp.c > +++ b/drivers/nvmem/nintendo-otp.c > @@ -87,6 +87,9 @@ static int nintendo_otp_probe(struct platform_device *pdev) > .root_only = true, > }; > > + if (!of_id) > + return -ENODEV; > + > priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > if (!priv) > return -ENOMEM; > -- > 2.50.1.windows.1 > Thank you for that, this patch is: Reviewed-by: Link Mauve -- Link Mauve