From patchwork Wed Oct 19 08:29:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp214343wrs; Wed, 19 Oct 2022 02:12:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zWCL+OmEizcWQT05dfY31ZFLYXI8Al6dY5zUHc4hOtjqjetQ3D7ePw4uJZ4DVNQdwOV+Z X-Received: by 2002:a17:907:6e09:b0:78d:a326:49c6 with SMTP id sd9-20020a1709076e0900b0078da32649c6mr5832553ejc.507.1666170752304; Wed, 19 Oct 2022 02:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170752; cv=none; d=google.com; s=arc-20160816; b=r/kVvXjtkLKMGa+/yOSe7lz4ACqNlx9w52I16m79fFDoPpM/MykeBrg03FtuHhP9RB j9oSkA9wIGuPmhenwx5CEShPx1N41Xq9KAO0+oAoWSv5HMVn9wC6866+JZSWDseMZkNc btuLg6xUUUDx6tF4SInatgiBCdUfm5/Y3k+e9WfZZfMQ+zSGhXDpsy8+YK/eQ/CIu1U+ oJKTfuFJjWl6yvHaO+3sJcQnFESO6FnBQ6pL7dVz6a+v53p6bhhIVrADzUxCryfEbx0/ ZFspDSGu/tgYRePN64ubCMOuoo2mjPIDhFQuLduEoGzcS4xaJI2uMMIyq2hGpTgYnj3Z WdHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MGz/Ny3qnn4Iw68vhpXp4rtzdB/NBnC/zXgaZPyC/wo=; b=E+CKUtMxBB8tZafhwBRviOB2fSZKf0KR7won1NSNrxOcAbKAmfFOQwAWyoq151ACQ1 +UnDTLzoJFVZEw79gCG1o3CgJArz9zPQ/plwng75gCvkYZ8x5fa0ASyhrayV+58fJB2Z zcl1wvDpqelEJlrKDw6+qevDST04A5ugi/rb+gsE5tDGTxA0yAgciZF8/Oku3Xb8Qqc7 h8EZDzTcL1t8mKCiKJD10U2FW3KvZGH28gzyKMlfe6+W+mlef4uzvO1IEXIdegifEEs7 K5Cb4EvejStRyXxdmIPckq1eiGpO6oVo0Qy0Wgd8XJIoGFGN+oyvh8aj21ZEwwpkMnza UOYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XWlX7WMM; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a3-20020a50e703000000b00458d2bdcb30si12945608edn.96.2022.10.19.02.12.07; Wed, 19 Oct 2022 02:12:32 -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=@linuxfoundation.org header.s=korg header.b=XWlX7WMM; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232873AbiJSJJa (ORCPT + 99 others); Wed, 19 Oct 2022 05:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232524AbiJSJGs (ORCPT ); Wed, 19 Oct 2022 05:06:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84E0042E74; Wed, 19 Oct 2022 01:59:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 290FC61840; Wed, 19 Oct 2022 08:58:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A1A0C433D6; Wed, 19 Oct 2022 08:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169927; bh=daM7vcIsZKr7FdXlFX6dxhQkjn98nSSipw3bhrJuVxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XWlX7WMMh27L49mHRolEqZ3/ljOJnWJrjvPYjZt30yN6SraTP9Utgxa17vuiBwhjf WmFqUWXcaXJ6Nv8qiBtxM4VTLQ47VPrM6WNCb3ZphYVzmKSpEyeFJ5FSV0TR+4zZ0e bBg+RcRMbArFfkT85sSU79kWnALAjVADv0MQfqOk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.0 462/862] iio: inkern: fix return value in devm_of_iio_channel_get_by_name() Date: Wed, 19 Oct 2022 10:29:09 +0200 Message-Id: <20221019083310.416092950@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106662703908700?= X-GMAIL-MSGID: =?utf-8?q?1747106662703908700?= From: Nuno Sá [ Upstream commit 9e878dbc0e8322f8b2f5ab0093c1e89926362dbe ] of_iio_channel_get_by_name() can either return NULL or an error pointer so that only doing IS_ERR() is not enough. Fix it by checking the NULL pointer case and return -ENODEV in that case. Note this is done like this so that users of the function (which only check for error pointers) do not need to be changed. This is not ideal since we are losing error codes and as such, in a follow up change, things will be unified so that of_iio_channel_get_by_name() only returns error codes. Fixes: 6e39b145cef7 ("iio: provide of_iio_channel_get_by_name() and devm_ version it") Signed-off-by: Nuno Sá Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220715122903.332535-3-nuno.sa@analog.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/inkern.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 9d87057794fc..87fd2a0d44f2 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -412,6 +412,8 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev, channel = of_iio_channel_get_by_name(np, channel_name); if (IS_ERR(channel)) return channel; + if (!channel) + return ERR_PTR(-ENODEV); ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel); if (ret)