Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8670431rwi; Tue, 25 Oct 2022 09:23:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4nnA6WQ03Ep1TJWMZ3GQpNVKrm5kZe08l4PCqsvb0sW4KomVmhfgHamVsWsH7UJnCTWoH4 X-Received: by 2002:a17:906:6a8d:b0:741:6a3b:536e with SMTP id p13-20020a1709066a8d00b007416a3b536emr34566357ejr.11.1666714980726; Tue, 25 Oct 2022 09:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666714980; cv=none; d=google.com; s=arc-20160816; b=nfGTb81+2p+j+MvbVdlmNdW74KKd5w5+FLrdfGYT5vGBOfkInQahpwKLX+IhzU3wZe 6UltOmy1VIO7rZ3v1KOI3wY+ycRaZ7ZXQV1Ax/CIxGlQhju/IscNcwAImc2Em7ikZShO klbTOZ4aTRdh7T65QlbliKHzTW99J3neO2oNkxMuO8jVV6fRyVWpD3QnTyUfV5AnsFQC VwFa4ewCTsnACbWNjm64fw+QZDhT7DCp0KotslPJTvuKJtJaNSXtStZGsdajDbjbUem4 cfytFjQeaxlgrs8Enczz0aFdRLObYyfjOFoMJVY1AOtkbUIpKPien9aIHrSr9bDDbQw0 2PcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=MWul1tU4IjkmONdULsGbXx3VTw+2F7vYwrYbT4qfDWk=; b=dUEUg+sHxYrdNU6HQYVwxSsLVQsOpS7/MTxDtp2WdGqKelH1dMOQwI/pEdNHJPdsJi un+HkXdIKW/oFvP/PhvGsf7C6ryBJfY/MOlXAWWheLThQnNrHLGRJBZM1hbLXiUiW7dg hEQ/5IcWg9SiGBcJCpUFg8YtfIe7u3x6z6aGYma6xaVC0h9qxwG5sgOar4SxCGsk17Gx CShcPFS0pbEN95YEX8WfNqFQdymVCMKx5YwZtj21zo6ms+SfTjd88e+1O56L/uX3JJZ/ cpElJPGPl9eZL27RCv1cDzi90JhSsVYYaW5GcS48NbF1EuosKxaJtRmEit11jfu0+QVo TGRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z+al1Fwz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020aa7da4f000000b0046155426889si2867561eds.272.2022.10.25.09.22.35; Tue, 25 Oct 2022 09:23:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z+al1Fwz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232908AbiJYPLk (ORCPT + 99 others); Tue, 25 Oct 2022 11:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232529AbiJYPLi (ORCPT ); Tue, 25 Oct 2022 11:11:38 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 213391A9916; Tue, 25 Oct 2022 08:11:36 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id o12so22575494lfq.9; Tue, 25 Oct 2022 08:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=MWul1tU4IjkmONdULsGbXx3VTw+2F7vYwrYbT4qfDWk=; b=Z+al1FwzheJmJi29u7rREJFZgLX1IOoO3LjLp9XVN7j70XdxwCew3JkHhWQi+mzeSN RLshy1L3ieOmjUfJBUUR5XA/AJzyYtCI7gO5HCv7qP87Ruzkm+Rp/aSuAhgNtaMiuXvQ 47xvgR1meAZ7av5MtGB8OlyzoHKZnaCjrBPL1ejjMphg3ef8WammYiTm9uLPcbraJwTI tR9+IHCNyezLUfwsMuj+dAmdJz6fgqbRRtFLQyZhRSKQDGNkwRbXBv3IEZkJRtWhekCp 74CcTwSUCDTHyBM5nO6oT28pwIziOyNfuDrZ+4Pq4h+28vd+DsdSqBeME/xZfu6d+VQZ 7nWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MWul1tU4IjkmONdULsGbXx3VTw+2F7vYwrYbT4qfDWk=; b=lgZaFMmZRKZS0D7Ikbzh7QC+A5PNizJLpZwnVwQuNBTQC68hiJcWFbKDXuIX1bp4yl ejedH991rsKMKEP7N8OpHgmherh7NuK7YY+SFQqJa5mQkIOhDZL3zvld1YL8ne8ba+tR tBuXLtI5byd0ut7hi7kzDzuaP/7+jbQyGfjZMQbX7flDZhabgBzZ8UHVtrVMS9jAr4oL uJASqVW2uKRj8AwKn1BD39ohccnKfRu2jf9XfbiREzfnFZ2KHx515hDqvEeOhcMV1QJP zyYvLgCd2xOfbofMei6yLlW9blO38FXKuNezTA/Xj+Ta0QESOj1DXvldnoWlFXNLrgdS 3vRg== X-Gm-Message-State: ACrzQf2Ho3nFyg6y5iZnUbNpq97YkY8IdFl8ZcZQsMMLn9m9D3NYpcvo 0sS2zY9EiVnuZbaGgxsfyhY= X-Received: by 2002:a05:6512:75:b0:4a4:6c3e:a75d with SMTP id i21-20020a056512007500b004a46c3ea75dmr13354062lfo.408.1666710694300; Tue, 25 Oct 2022 08:11:34 -0700 (PDT) Received: from fedora (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id n11-20020ac2490b000000b004979df1c1fasm453946lfi.61.2022.10.25.08.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 08:11:33 -0700 (PDT) Date: Tue, 25 Oct 2022 18:11:26 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Wolfram Sang , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [PATCH v2 0/2] fix fwnode_irq_get_byname() returnvalue Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="t1R8QCdkJ9VqjNyC" Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --t1R8QCdkJ9VqjNyC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The fix fwnode_irq_get_byname() may have returned zero if mapping the IRQ fails. This contradicts the documentation. Furthermore, returning zero or errno on error is unepected and can easily lead to problems like: int probe(foo) { =2E.. ret =3D fwnode_irq_get_byname(...); if (ret < 0) return ret; =2E.. } or int probe(foo) { =2E.. ret =3D fwnode_irq_get_byname(...); if (ret <=3D 0) return ret; =2E.. } which are both likely to be wrong. First treats zero as successful call and misses the IRQ mapping failure. Second returns zero from probe even though it detects the IRQ mapping failure correvtly. Here we change the fwnode_irq_get_byname() to always return a negative errno upon failure. I have also audited following callers: drivers/i2c/i2c-smbus.c drivers/iio/accel/adxl355_core.c drivers/iio/gyro/fxas21002c_core.c drivers/iio/imu/adis16480.c drivers/iio/imu/bmi160/bmi160_core.c drivers/iio/imu/bmi160/bmi160_core.c and it seems to me these calls will be Ok after the change. The i2c-smbus.c will gain a functional change (bugfix?) as after this patch the probe will return -EINVAL should the IRQ mapping fail. The series will also adjust the return value check for zero to be omitted. Changelog v1 =3D> v2: - minor styling --- Matti Vaittinen (2): drivers: fwnode: fix fwnode_irq_get_byname() i2c: i2c-smbus: fwnode_irq_get_byname() return value fix drivers/base/property.c | 9 +++++++-- drivers/i2c/i2c-smbus.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) base-commit: 247f34f7b80357943234f93f247a1ae6b6c3a740 --=20 2.37.3 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --t1R8QCdkJ9VqjNyC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmNX/J4ACgkQeFA3/03a ocXOkQgAq0+GJzHMzhUv+D5OZ0idZ4ZX0qKwMCcdTxS11fetfx2xqhNGDXhPMdOH M8SJSo7HgvR5QNqGJ7se8c61BzXtigWjo6Jj0FJ/AQHjhFq3mgYMUnR74DfBw4yr XZafFAhLk95WbMgOt/G3yXaFQPMK47yS4qW1yd1hd0sSnFFj7z3nNHZqvNah6YGF pIGf3AThYnHGMJIwkaDnktHCpuo2+nDz2QptEVgxmUrOBSXCc+RnoayTU1wkEkj1 FrDQq1NnNIcB2N7SVqqRyfbpGPGo7ekpQRflJw1JA8x/67JFKh4645HtvYSEGaxx uSteZw4Qe8L0d4gFs6OgvWcE/HuaRw== =LzQ4 -----END PGP SIGNATURE----- --t1R8QCdkJ9VqjNyC--