Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9098495pxu; Mon, 28 Dec 2020 06:36:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVGmwerbLuRcRaWwGN4whicT3jwv/aEtW27w71vxwTZwKpvgyxeu0hsX2Qlz74CayTzAm+ X-Received: by 2002:aa7:d6d8:: with SMTP id x24mr43244267edr.105.1609166164677; Mon, 28 Dec 2020 06:36:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166164; cv=none; d=google.com; s=arc-20160816; b=soXoAhMfIslCy5MZE8XOXaB0DA5K8D2CO5FeTK+SS2pl5rGFdR2qmRl4ZdhpWNrhNx +x6lwRgp77SqODF+qoXT9KSIh96V3VBw7bNVDx66YnXwSb58VyR5nlOX80pYsaTTCyfn MkBPR/05oDy7jEGwPFG0KAClDZoGZnRwo6xt/XxxejhgJfvmeU1tJY1S2HKQt2qJq4Br v1Rpf3Cko4szQsoCveF6ALy7vUddImiZY9dhgjLX8hfHL+fbXH2LPHikLmo9/xUEGeZ+ /dseJ5lanKgM0uK4ULStqR8dmfXIj0q+/cKEu6cgh/dPYuLCNnWAuUYIXvRoYjnIgYPG ZeXQ== 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=EjkbuTUfWbpxJ+QKIsBYjgcQKOKoCG1G8AGUxreWgOw=; b=VgGEDUePiOezh6MBvCHTXYbZdOWAHn4aQZxJIxnhoP8wN4BgdZNtGHR8Gb3dvWsKgF ULtk8Xwpi88Oadqm120JIPuc3EvGzPxjDi+pnSzo1UO2HGv2yAFhhkEWx4GKE9m9zXy9 sJTuAlThUaAdBhR0pKZD0Q4COct4CffkabfZIugYwOeZtGzfnIfC1yCURE/y+4+OTWwl yTL/7hogzDhhNyAjPncnZyTangrodtc2LnX2LtJ21p5hXGTPc4NmDyYdQIm4gk/3yLJO dJ9E8hHZWqxi8PTsYjRUTjnJwd8RT2BA8mLU0A7d5r022iIVW4TI5YbIzlXBbhPMOUHj en+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oUIHucE6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si17938914eje.650.2020.12.28.06.35.41; Mon, 28 Dec 2020 06:36:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oUIHucE6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2504892AbgL1Odm (ORCPT + 99 others); Mon, 28 Dec 2020 09:33:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:40610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504793AbgL1OdK (ORCPT ); Mon, 28 Dec 2020 09:33:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9828220715; Mon, 28 Dec 2020 14:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165975; bh=fa32XThH0eE/2W4UsWH8fzYbgtHNcVvwX2R7eX4u694=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oUIHucE6GgPYwKmSMRLntEOL4YM6L4Mz7R2bnjcqARuQM9WOMNHtPI2ylCNYRkTY1 GTpz7rUpfQeKABXx1yoITfHaO6/Dr1LT6jR4+Ik/wMYA/m/RUVDvg7i2U6F2QXDirF 6eYrBvbEMQA1I6L0VFV3Ui9ydnksX4MpFP4cDUSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikita Shubin , Alexandre Belloni Subject: [PATCH 5.10 714/717] rtc: ep93xx: Fix NULL pointer dereference in ep93xx_rtc_read_time Date: Mon, 28 Dec 2020 13:51:52 +0100 Message-Id: <20201228125055.212099724@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikita Shubin commit 00c33482bb6110bce8110daa351f9b3baf4df7dc upstream. Mismatch in probe platform_set_drvdata set's and method's that call dev_get_platdata will result in "Unable to handle kernel NULL pointer dereference", let's use according method for getting driver data after platform_set_drvdata. 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = (ptrval) [00000000] *pgd=00000000 Internal error: Oops: 5 [#1] ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 5.9.10-00003-g723e101e0037-dirty #4 Hardware name: Technologic Systems TS-72xx SBC PC is at ep93xx_rtc_read_time+0xc/0x2c LR is at __rtc_read_time+0x4c/0x8c [...] [] (ep93xx_rtc_read_time) from [] (__rtc_read_time+0x4c/0x8c) [] (__rtc_read_time) from [] (rtc_read_time+0x2c/0x4c) [] (rtc_read_time) from [] (__rtc_read_alarm+0x28/0x358) [] (__rtc_read_alarm) from [] (__rtc_register_device+0x124/0x2ec) [] (__rtc_register_device) from [] (ep93xx_rtc_probe+0xa4/0xac) [] (ep93xx_rtc_probe) from [] (platform_drv_probe+0x24/0x5c) [] (platform_drv_probe) from [] (really_probe+0x218/0x374) [] (really_probe) from [] (device_driver_attach+0x44/0x60) [] (device_driver_attach) from [] (__driver_attach+0xb4/0xc0) [] (__driver_attach) from [] (bus_for_each_dev+0x68/0xac) [] (bus_for_each_dev) from [] (driver_attach+0x18/0x24) [] (driver_attach) from [] (bus_add_driver+0x150/0x1b4) [] (bus_add_driver) from [] (driver_register+0xb0/0xf4) [] (driver_register) from [] (__platform_driver_register+0x30/0x48) [] (__platform_driver_register) from [] (ep93xx_rtc_driver_init+0x10/0x1c) [] (ep93xx_rtc_driver_init) from [] (do_one_initcall+0x7c/0x1c0) [] (do_one_initcall) from [] (kernel_init_freeable+0x168/0x1ac) [] (kernel_init_freeable) from [] (kernel_init+0x8/0xf4) [] (kernel_init) from [] (ret_from_fork+0x14/0x34) Exception stack(0xc441dfb0 to 0xc441dff8) dfa0: 00000000 00000000 00000000 00000000 dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 Code: e12fff1e e92d4010 e590303c e1a02001 (e5933000) ---[ end trace c914d6030eaa95c8 ]--- Fixes: b809d192eb98 ("rtc: ep93xx: stop setting platform_data") Signed-off-by: Nikita Shubin Signed-off-by: Alexandre Belloni Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20201201095507.10317-1-nikita.shubin@maquefel.me Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-ep93xx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c @@ -33,7 +33,7 @@ struct ep93xx_rtc { static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, unsigned short *delete) { - struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); + struct ep93xx_rtc *ep93xx_rtc = dev_get_drvdata(dev); unsigned long comp; comp = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_SWCOMP); @@ -51,7 +51,7 @@ static int ep93xx_rtc_get_swcomp(struct static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) { - struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); + struct ep93xx_rtc *ep93xx_rtc = dev_get_drvdata(dev); unsigned long time; time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA); @@ -62,7 +62,7 @@ static int ep93xx_rtc_read_time(struct d static int ep93xx_rtc_set_time(struct device *dev, struct rtc_time *tm) { - struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); + struct ep93xx_rtc *ep93xx_rtc = dev_get_drvdata(dev); unsigned long secs = rtc_tm_to_time64(tm); writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD);