From patchwork Fri Feb 16 12:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 202115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp494068dyb; Fri, 16 Feb 2024 05:03:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXU/ZCKd5uIYcDdNi6VT4axZI11JOIdt7XIxkgzHcfIF3/TpoAbWawUJWqgp+ceP2YorlFPQF4zHFn5P/dYdUS1vhumg== X-Google-Smtp-Source: AGHT+IFdWoC9xmFw9MG1fD08PIRTi+P3vezpfU4rDO6wP/OHoW2k2m0vEmXRK2DoI8eWgeKRGmnp X-Received: by 2002:a17:902:f68a:b0:1db:4287:c309 with SMTP id l10-20020a170902f68a00b001db4287c309mr4639314plg.11.1708088590753; Fri, 16 Feb 2024 05:03:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708088590; cv=pass; d=google.com; s=arc-20160816; b=RkG9Fa8BVmV1yGa+RuchAJ0K23A3uEJqisv6wdtjnsnFbuT4GxQEq3U+pEcPNc7c1P OA5JpaDxxihUVF+RQE2LSoUcyoA8r8vhs+TILnsQ7szxDdcm+H/F8yPvoT06F6Ip5EXy GCahzrFGGwzedzXJNyZufKDQU0nL2ElHh4UZ6x7FZPjYIISvd/ASG1xDlRz2EivGFUgf fmEco7vUiH6gAPY+qzTTkNaD8qdd8c/fkYro4tPHf/p2gho28KPwskdZcQcuOx+93HdU NC0KU0rur02IrcIaYhhrLRAfmtkoYrLwjtRhnov0c71YhZQnsDEbXjdWoflJpGW3GsUJ cLfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=zGXKsXy51gCJICrOkl6rSU4KrFKit0QjMm02SUIQI4M=; fh=dRQP0hx5XHjIU2/wzQWJ/Mhz5BphUU9mbrcUM82OYFk=; b=YPpmeO4C0qNU4kjuHtJ8tdmxgcbPcCMDEBjMalty/LPfgBhmUYw1QpRMO04GIwp+3m PKI5HqHL1gNhkSoZ3VSAMfqCe/yd2thPsNthZwXeIcDb6OPND8atGARLyI7Qx2hYhOVk 7nqiMPe192Twd6JZGI/T4PcRZv+hg04TPbJ9UEwAIx6j5tPLI5WfeRt279lRoTjOoLvV 1eQI6Uunl71SB73ImimXaRfSEV71r55syJDePMwP3Fnu9AXHW8dTVqDJYT2/ovwwbOSZ byRl1hJDM+9O2MwXIhHYzHK8DqPgeQEZaB494Bs76S35O8lGkLz8CiQIX4TayWRPRXW2 /U5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gMybALGW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68603-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68603-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a26-20020a637f1a000000b005dc785e4a28si2929467pgd.30.2024.02.16.05.03.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 05:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68603-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gMybALGW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68603-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68603-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D4052B2346C for ; Fri, 16 Feb 2024 13:00:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A71B2129A69; Fri, 16 Feb 2024 13:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gMybALGW" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 23A5B128825; Fri, 16 Feb 2024 13:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708088406; cv=none; b=nti9srGrutdir8DnS78cH+Fm3aYTAe/RxJx0E2iLDh/n4Q9zt3IMBuvUqalm0EslaqI0HVgTK4pSdv1qoHwZXkR2uGSPFzx4YRW9hEug5XufP/Dj9IAQos7sk5t7s2UZnLqFliUv+Tp7/57rE4hQeela1dunOcBg7K+GCIwFhRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708088406; c=relaxed/simple; bh=Fua+75fYl25KxH7zo3jRCWk4YuWrcZJH5ZiE41IuRQo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=H5otpB7D1QWo65S0DPyofP0h9cnn3Vs45gHHP/ACHG5e3NvjZQ+hUs9zMtyggWIY+o6GjNaOGZlBIfQGLM1yYqx/MnHRcmkrkMtOUifFI++1xBQJV4GtRXbnWtvX8E176CeEUmUou4sMvQG+QcRsqTVgf3bqJ7ZKv9FMx650Af8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gMybALGW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA108C433F1; Fri, 16 Feb 2024 13:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708088405; bh=Fua+75fYl25KxH7zo3jRCWk4YuWrcZJH5ZiE41IuRQo=; h=From:To:Cc:Subject:Date:From; b=gMybALGWtGK83QV3RuisQujmIX6Z4uGLabFhmq/aPfU55noI54gh4xVKrs7LKpqYd aOexQACIOuVuHmktqpnUMhdZ/qO1Gzk9Fxm//zDVee/4CWAl/X1NSy4/HF0FGLFETi dxe3r+SKrQt0jGDtAmf3ItVUr2S8/g5s4Avv1U4MUZnKM6oUeHtqY/PRYH6FfCiLhD PLp++c+NQSzMVXU4aKlfJegtGhXGnrJOBF0SFvNW5HkP3eMzGiBqg7FjF+jfOc0Cer QbgNgThIZ/XwpmiG0P+bq+aMyybYRI9dKWz5m7H7BbQSHsRM9QYPReMjOyeha1n/f6 JXzbMGIybuwjg== From: Arnd Bergmann To: Bartosz Golaszewski , Linus Walleij , "Paul E. McKenney" Cc: Arnd Bergmann , Kent Gibson , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: cdev: avoid uninitialized variable dereference Date: Fri, 16 Feb 2024 13:59:50 +0100 Message-Id: <20240216125959.3766309-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791060701918868785 X-GMAIL-MSGID: 1791060701918868785 From: Arnd Bergmann The 'gc' variable is never set before it gets printed: drivers/gpio/gpiolib-cdev.c:2802:11: error: variable 'gc' is uninitialized when used here [-Werror,-Wuninitialized] 2802 | chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id); | ^~ drivers/gpio/gpiolib.h:277:11: note: expanded from macro 'chip_dbg' 277 | dev_dbg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__) | ^~ Use dev_dbg() directly. Fixes: 8574b5b47610 ("gpio: cdev: use correct pointer accessors with SRCU") Signed-off-by: Arnd Bergmann --- drivers/gpio/gpiolib-cdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 85037fa4925e..d6e8d2b7ac8f 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -2783,7 +2783,6 @@ static const struct file_operations gpio_fileops = { int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt) { - struct gpio_chip *gc; int ret; cdev_init(&gdev->chrdev, &gpio_fileops); @@ -2799,7 +2798,7 @@ int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt) if (!rcu_access_pointer(gdev->chip)) return -ENODEV; - chip_dbg(gc, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id); + dev_dbg(&gdev->dev, "added GPIO chardev (%d:%d)\n", MAJOR(devt), gdev->id); return 0; }