From patchwork Tue Oct 25 08:50:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13018757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13AEAFA373E for ; Tue, 25 Oct 2022 08:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231449AbiJYIuq (ORCPT ); Tue, 25 Oct 2022 04:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbiJYIup (ORCPT ); Tue, 25 Oct 2022 04:50:45 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540CAE31BA; Tue, 25 Oct 2022 01:50:44 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id b2so20753236lfp.6; Tue, 25 Oct 2022 01:50:44 -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=ThKIv3p/MunjRRcs90V/JUQZIVOWApuxjs8vyFYsMxw=; b=XxncA3KI8siFx2VjT4NwTCMr/0b9E4ZXVdYrXeLCpjtX01m69ESKM5nj/VrV00gv2W 2U814RfoLlrmtE/wxXEVqdtsaHVmFieOZtwopoZoCRKmW72iy4GWXP7/XgbRXvFJ9nWI kW8sCnePTDHQPCBPue8no6Oo5apO0n8Q0/hOseLFEp2DXWKeyK4vMO0sJtLCXOwzpfMT +FQSCtjM5Nx8Ppmr3ufk0a4ZrzFLKURmNrrdmKWfT5s1fLaDPnsRmGjHXlpGPBan8fM/ mpU8kZl33OdY/NFYw6UcHK17GfOXbVWlo42EsMew0KZwZDoPMW4lnImTXAZOqNxwSQIW gTJQ== 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=ThKIv3p/MunjRRcs90V/JUQZIVOWApuxjs8vyFYsMxw=; b=kF1SoGT0Z04IyIbDAW178Q/+FTQ5vXSKwcrAw80xTUXUZ3Aw461ITGsZ9nGRqp4ClM XhcOmcaXxeW9YCSk5h+DGvEe1dMaHbUre3Yr2nbwf8qEZLfivFtrvtqlNVnECQFZDaOl uh+R4vqNjTeAjCrdICKOvphEX8FqdqBCzpfDqd+iiewCfxLbddy99ryaaudLfyBTeXVj zLswlsvUo2VxbnubVk60jlxxyPlCzuhx95WSnB7/FhGJG9xezrfnWDGV/DE/GgJnAjZW XXz7QAoeaoWhAkkMAudFB+iviqJUsGkH9vD7QM56lWVvCmUr5nUk7R08xhJ4kMyi1kQo ZL6w== X-Gm-Message-State: ACrzQf2AAFI54aeKOeGvETqYh6M2+/Vc0JyUlfSYGswiyoq5FVauIHxz 9udWcbZs2gacUNgEufN50XE= X-Google-Smtp-Source: AMsMyM7L/Xk5Ter4HACaAUtohVX+eTWaQayZfRuwjMG6OSlh6cb9q+nkjasnUmb8yegVPFiFgb3Zqg== X-Received: by 2002:ac2:5e35:0:b0:4ab:a198:73ad with SMTP id o21-20020ac25e35000000b004aba19873admr3598836lfg.295.1666687842491; Tue, 25 Oct 2022 01:50:42 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id s7-20020ac25fa7000000b0048aa9d67483sm322701lfe.160.2022.10.25.01.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 01:50:41 -0700 (PDT) Date: Tue, 25 Oct 2022 11:50:24 +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 0/2] fix fwnode_irq_get_byname() returnvalue Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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) { ... ret = fwnode_irq_get_byname(...); if (ret < 0) return ret; ... } or int probe(foo) { ... ret = fwnode_irq_get_byname(...); if (ret <= 0) return ret; ... } 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. Reviewed-by: Andy Shevchenko --- 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