From patchwork Sun Oct 18 17:15:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 11843345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47FD8C433E7 for ; Sun, 18 Oct 2020 17:17:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A62B722254 for ; Sun, 18 Oct 2020 17:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QxPubtMr"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="OWNhjTRS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A62B722254 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=11kQWKhx8/oZ3V48uobbUITM7u2goLY7g5ufqFQ6yIk=; b=QxPubtMrYl0ZDPAfYWBIinBQ9c MbxqQF0B5Rwv7Tz0KqnfTrMKDRq1PIsCMmm3Cr0SFlDUiVHaZ/CrVOBnXa7MgFb2V+cOSzR6ElNyZ PZUUlxf5eg8p5aqgO35+fabt9dhKGuTkADRKKzABnrIuceljp0mxLShhdScvOfJtvHwZr9JQ4mp3G x6X3yJwpzHw3Cw2yY9k4dV4gjZhmU4soFFduPGhyxahbF7JUmooSkFf5GEtrgMz2MQ9cBDNYRjqMf WRf0JoIDuLR1gyN84iNMZyeXnCrl4OGJBBoWe9nLkyN7ute7WMfzyAw8srwrANdQBMDvRRpJUCEAA c7r7X4Aw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUCHl-0005YX-90; Sun, 18 Oct 2020 17:15:57 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUCHf-0005XO-Os for linux-arm-kernel@lists.infradead.org; Sun, 18 Oct 2020 17:15:53 +0000 Received: by mail-wr1-x442.google.com with SMTP id j7so4706347wrt.9 for ; Sun, 18 Oct 2020 10:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e+RWq//obkFsbQkf0frorg8nADONbMbmIRghejO+t54=; b=OWNhjTRSyDd9oXlWWD/2w8WrkivJIuxojfj0590PSh5jabXJAdOmR9+6YP2AxW43tC tWWr2yMYXCmDlFaQTBSzjkvxVlzzkpY4DZsqFNrtwWzassbwFHgfFrwN2xtrWMEqSp1m LNhD09fuVCMfYUz8Z8/mNAXIFLmM4oQzQLFkJ7MUKByzptDAovCoSo+SCawKJX+LXcep Iy9eqEr/S4aUHk8ZuCsri9MJ/lUoFz+HlifTvkw8TD4kPPz7+yj0h/WXDHUZ0O2xqVds Ojuw+uTtUft2ziHX2qewu/JcwlMwUK8TXqgm6ouPlMjPhPGHTsF9dEPPRBlRVS9zMOyU fl8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e+RWq//obkFsbQkf0frorg8nADONbMbmIRghejO+t54=; b=Iek2OAh2TCGUWb9vi5Wvx5WWxFFtoxf1OtwW6qI2/NYGexJFp3H0SNeOVtwU+rsbvL F9g8jK/qbpikc956aSsQdD7gOY8wx9Mg9QgZeTUVdvvXwlEC8KgHkmAj8TcbQMjy+j9Q S1Ayr8ETUlSY5PaU3Vc+jtov5HIjdkUsAx8wHznEJxy11afR58c5MM5dq7JLWQlY8sjM FbB+k1oCpjB2Fwgr2zO616v/w20lWCPRFYqsEDbEyFlG8NGiavJ9AZOGfYyXlkrVB/kK PONE2PeLtp0ZUSVmBRQsY7MAezvBUutIb3DKr3wa1ibMzTWMIK0+fWm5Jka8bEiJiSQq xP4Q== X-Gm-Message-State: AOAM53093PKspOk1GnjnKNvd8XI5JsSthdnEHshnkpVO4Tg2G/wsa9EC NjtDvIjLQJceF1f501FAG6Ijiw== X-Google-Smtp-Source: ABdhPJwrLsEQG5u2+3sJluFInmC+o3UDfLKxPtnMSYaPxJJL+OPjcGL9AzT9Yzt8tJP8+LiwH6kBlg== X-Received: by 2002:a5d:66d2:: with SMTP id k18mr16752792wrw.229.1603041349031; Sun, 18 Oct 2020 10:15:49 -0700 (PDT) Received: from localhost.localdomain (124.171.185.81.rev.sfr.net. [81.185.171.124]) by smtp.gmail.com with ESMTPSA id b25sm12013701wmj.21.2020.10.18.10.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 10:15:48 -0700 (PDT) From: Fabien Parent To: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org, matthias.bgg@gmail.com, jic23@kernel.org Subject: [PATCH v2] iio: adc: mediatek: fix unset field Date: Sun, 18 Oct 2020 19:15:45 +0200 Message-Id: <20201018171545.3190476-1-fparent@baylibre.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201018_131551_945429_2F6D8401 X-CRM114-Status: GOOD ( 14.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabien Parent , alexandru.ardelean@analog.com, chun-hung.wu@mediatek.com, lars@metafoo.de, pmeerw@pmeerw.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org dev_comp field is used in a couple of places but it is never set. This results in kernel oops when dereferencing a NULL pointer. Set the `dev_comp` field correctly in the probe function. Fixes: 6d97024dce23 ("iio: adc: mediatek: mt6577-auxadc, add mt6765 support") Signed-off-by: Fabien Parent --- Changelog: V2: * s/of_device_get_match_data/device_get_match_data * include mod_devicetable.h and property.h instead of of_*.h headers drivers/iio/adc/mt6577_auxadc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index ac415cb089cd..79c1dd68b909 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -9,9 +9,9 @@ #include #include #include -#include -#include +#include #include +#include #include #include #include @@ -276,6 +276,8 @@ static int mt6577_auxadc_probe(struct platform_device *pdev) goto err_disable_clk; } + adc_dev->dev_comp = device_get_match_data(&pdev->dev); + mutex_init(&adc_dev->lock); mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,