From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BA7A3C3C16 for ; Fri, 31 Jul 2026 12:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785500583; cv=none; b=sFWZrbTxU7JPbYqRybNhBNpA/LlXCOOE5dZ6PwdX6Ndv1WHEKaXvwKA5AzvvVgCSAE4QIdyxwtgkSOtsQAfT5nN6tZFVvJx9WBlXZYJnm3AnSe7S7DxL+7MlY4JAnY5ravZcX5pgOwl+Wt07gu6H5z8hm8S0TSDXqRHOpOdtqvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785500583; c=relaxed/simple; bh=/7B/jf0/mL1UEJu+qQTV8othAj6/5jmgIsEV5ObC4T4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K65lS0+l2/o8eazYpta9zVoxzIS4M37rSzIeQC6/acYuTltMwLBmbrv/t+s6ZxCszQEmAJhcqjXl8ailIdjnRJP0Tvgc5Zg84IXLfwxLLz8H9Ab7CmS4OC/9AU27MBd89u5Em9OiesdaXRDx6yfZuCiChGRvg6iHVxVb086d2fc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ADEeYi7Y; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ADEeYi7Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E89D1F000E9; Fri, 31 Jul 2026 12:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785500582; bh=KxA3Vgne+NqjJ/Uv6A41VPYaDTca6EeAWdmTFQE1da4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ADEeYi7YOBnBpnTLz8WiRXhnx5d/QTJCa/P/6B/HiXMOe6Z7GfQ18R2L4Av2w/B0/ f6dZ8mvfTy6olEQPbT6Dgq/KlqqScOwpujKJol1Cxy7ClKe0UJG4idKxMzX+/K2Dom tN41yjNWRMRur00cgcZbx7/vYTO1an+iTAj4ZiTU= Date: Fri, 31 Jul 2026 14:22:47 +0200 From: Greg Kroah-Hartman To: Linkai Gong Cc: Jim Cromie , Arnd Bergmann , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] char: scx200_gpio: check cdev_add() return value Message-ID: <2026073136-good-manger-7c91@gregkh> References: <20260730095321.2386744-1-gonglinkai@kylinos.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: <20260730095321.2386744-1-gonglinkai@kylinos.cn> On Thu, Jul 30, 2026 at 05:53:21PM +0800, Linkai Gong wrote: > cdev_add() can fail. The driver currently ignores the return value and > reports probe success even when the cdev was not registered, leaving a > chrdev region allocated with no working file operations. > > Check the return value, emit an error, and unwind the chrdev region and > platform device on failure. > > Fixes: 635adb6cd25c ("[PATCH] scx200_gpio: use 1 cdev for N minors, not N for N") > Signed-off-by: Linkai Gong > --- > drivers/char/scx200_gpio.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c > index 700e6affea6f..d9d66d4c2312 100644 > --- a/drivers/char/scx200_gpio.c > +++ b/drivers/char/scx200_gpio.c > @@ -107,10 +107,16 @@ static int __init scx200_gpio_init(void) > } > > cdev_init(&scx200_gpio_cdev, &scx200_gpio_fileops); > - cdev_add(&scx200_gpio_cdev, devid, MAX_PINS); > + rc = cdev_add(&scx200_gpio_cdev, devid, MAX_PINS); > + if (rc < 0) { Should just be: if (rc) { right? thanks, greg k-h