From patchwork Sat Oct 22 07:24:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1121156wrr; Sat, 22 Oct 2022 02:27:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4eqBbjBcISVlXg77vmT7+cga8RpFN3Vwi9WBcRz/wffFHzGjU9CBRd9vA+dx2rBoQuKQrC X-Received: by 2002:a17:90b:4c48:b0:20d:5c55:b8a8 with SMTP id np8-20020a17090b4c4800b0020d5c55b8a8mr27605354pjb.207.1666430859977; Sat, 22 Oct 2022 02:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430859; cv=none; d=google.com; s=arc-20160816; b=t0NaAm6VhsnadiLWDXgxSj1DzJd3oueuDoVwe8MA/7mbE4zfKEnzbneqQ+2lm6CfBh 70lR3IZ1DPj0xsrK/BOQQ9yKtrfvZCy9Avg1ztHCyp4Jj3FyLTDVO9YgkCJu55s0r2Io OIZFCTE7xTyRX98JMRsDVothAFHolz3cU6+XeFPdt3lw7lpWTEUx+9eemO1B9Eo8Ym9k nt2AM73aql8Ptde7zNtL8SJjaOYx4CQ1WEBLxRmdByH6Qt8Rx3RskW1IKCkQVCR/YJ75 1KQSA3lmzIUJIel1b0Mgn6E14htJjBtHJQNAgH7qTfTxP+PdmcUJrhdg5ekQQY3Z4X1E Enxw== 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=ePOaXFAp8fzd97EvoMiRquo79Vlu0tgTgxdf81+a6ND/iMQ7VcwtE048OK9VNXHpUm 91rAZNrCY3XFWCv2w1Vj79kA6WL8+FDA4M6SRBkY2Ky85zdNuu8G24zMitsSkaq2cWS2 0qyBR4ndvEpbi28LZUJYHQpZJXU+qUA+pnwDiGdmMmBAnjCErjciUFdjOOVd6YMs3v6N YyuuubXdgdHhxPmd2Sers0HOqyBj9QjRvoVUaQfLLctyVwdIpOrRVDO0Ph7rdsii01Td IK9hTW8GlAq7exNCEt86zHfkyk2SwkT8EzdBAPpYURYpLhZoLDudx1ssGY6ukwZWE42C p0tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RRCqyv67; 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 a25-20020a631a19000000b0045166930a46si29978817pga.609.2022.10.22.02.27.27; Sat, 22 Oct 2022 02:27:39 -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=RRCqyv67; 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 S231954AbiJVJFn (ORCPT + 99 others); Sat, 22 Oct 2022 05:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235170AbiJVJD5 (ORCPT ); Sat, 22 Oct 2022 05:03:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5CA2DCB04; Sat, 22 Oct 2022 01:19:04 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6C7B5B82E34; Sat, 22 Oct 2022 07:50:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4101C433B5; Sat, 22 Oct 2022 07:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425057; bh=daM7vcIsZKr7FdXlFX6dxhQkjn98nSSipw3bhrJuVxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RRCqyv67aQ03PR72dCVeTty/NZ03j+KtBl/f18TPgIOt66njwzbrI05VuliRFNk2a y/1yLVv+D4vwDPrtOou8RC9hrqHXmndplhzOou+OSslN9r6pkdSFSeGfYKernQ475U L7+py7Z/t5Z0g6AtRfCj1QsAa32hbpIcATmLQLYM= 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 5.19 376/717] iio: inkern: fix return value in devm_of_iio_channel_get_by_name() Date: Sat, 22 Oct 2022 09:24:15 +0200 Message-Id: <20221022072513.816258648@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747379405242119951?= X-GMAIL-MSGID: =?utf-8?q?1747379405242119951?= 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)