From mboxrd@z Thu Jan 1 00:00:00 1970 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 C608AC77B72 for ; Thu, 20 Apr 2023 11:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235436AbjDTLIR (ORCPT ); Thu, 20 Apr 2023 07:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234585AbjDTLGx (ORCPT ); Thu, 20 Apr 2023 07:06:53 -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 3401D8A55; Thu, 20 Apr 2023 04:04:12 -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 85CF5647BF; Thu, 20 Apr 2023 11:03:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D89EC433EF; Thu, 20 Apr 2023 11:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681988621; bh=DwJLzS114DU1I5Oiuh5O0As4ojOXaMxgHeKVSQeWWjE=; h=From:To:Cc:Subject:Date:From; b=VaSwICBFW//LHPJMySKn9R96KScoKrqAIxivIbMN9Wh10eCkf1fa0A5c6CwMnQuKa 49KQAazkUoglGr8HMPXH0B1UJnBqCHiv27bfWuTE3oAZWan0fKJaj98Pvg20LKRLj4 GumG5jkkb583Vkuz5t6IsJM5FSti4Q1ckbevukEBVt6jeKGInA7xV34k89ijuRcyxK +5GQEOImuU9OjnKcVfaxKcaAU1tuB9icaxxCRJzOL4mNBcEMcrgOxEcMr4Vclq6GS9 Ie04VIYbFGVZwWRvZCSfH4EyRGQDUMDTzbalRi24i4eubgj7QvgHOYNrW1nmi2deD6 U7tQY8daLxiYQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Patrik=20Dahlstr=C3=B6m?= , Jonathan Cameron , Sasha Levin , jic23@kernel.org, linux-iio@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 1/2] iio: adc: palmas_gpadc: fix NULL dereference on rmmod Date: Thu, 20 Apr 2023 07:03:35 -0400 Message-Id: <20230420110338.506352-1-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Patrik Dahlström [ Upstream commit 49f76c499d38bf67803438eee88c8300d0f6ce09 ] Calling dev_to_iio_dev() on a platform device pointer is undefined and will make adc NULL. Signed-off-by: Patrik Dahlström Link: https://lore.kernel.org/r/20230313205029.1881745-1-risca@dalakolonin.se Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/palmas_gpadc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 2bd785e9e42ac..4861093b0764e 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -630,7 +630,7 @@ static int palmas_gpadc_probe(struct platform_device *pdev) static int palmas_gpadc_remove(struct platform_device *pdev) { - struct iio_dev *indio_dev = dev_to_iio_dev(&pdev->dev); + struct iio_dev *indio_dev = dev_get_drvdata(&pdev->dev); struct palmas_gpadc *adc = iio_priv(indio_dev); if (adc->wakeup1_enable || adc->wakeup2_enable) -- 2.39.2