Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp686303ybv; Thu, 13 Feb 2020 07:45:52 -0800 (PST) X-Google-Smtp-Source: APXvYqz0MmX4Ze/gy2j085ZmwlJ0zRDy3B32R7IAh7LFY5drYyYBO+W5ydNQp/Cd4BTaAREdcUZT X-Received: by 2002:a9d:7e8c:: with SMTP id m12mr14199535otp.346.1581608752623; Thu, 13 Feb 2020 07:45:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608752; cv=none; d=google.com; s=arc-20160816; b=h24Ak8hS+AFgTdFF2upXwJRfBEmayClo2BB7PVqqvrWhZIPpiMEEZGrcDO1VqWj2YF 76TdRAYu50xaKjoaJycCQCwCNqmbTStHci/ZepCK/7fHwYRCv0xYv6RGWTIhcS2F6nLL ULtHggWTry5kVaeelYhTj6E9hfWR9T2oCBj2Q3kZagkDPF4AOPw7HAC4n0Y26TuMHLQq l3JuGuE6EIamTN3cp8V76E6o5xSBtqPEcoo2/JFsQaiOEiP5LOJKbWpcIpvqc2SYo98c V6ZTP9h685s3Velr90bmuNtkbXTtu/bgfe+TsNuS+wJ8f3W1TyX18xoJMsjwrfp7F/M3 oBDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zfyE3EDTCsnd0WV3DUrOKoEF/DR2VaHkkn1p13WKN4A=; b=Mq/JO+f3S7xnKEk4dprvv4EJI822y1gfiqptBKeskoRI9er83GxDlaFYt1X6a5h+OY jdLyO3MSGLqW6tvD4d05s65ul1OoxisDijoCuVJcwomUoH6qqNjPmZOogm9/l8zjgZx7 aiB4OMBDVMmv1G68IFeRgEpVIvVCfEE6T2ETk6clggRBsZx9FPhmAZ7llXCxf+SHlvzp AD7dDk+UBiga6LNmNVKsTLfhGRYSlLs9d4a2bmeqxFCpAh+hl8H1vwTjIfJI1hWT2aMD wmo3o8y1TQYpROVhGaGuwnbSg+oi85ySWFL07POHyIbXkeYGv1HYm4NgnSlcLpwe6PyN dWtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sI5SUgUK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si1339722otq.250.2020.02.13.07.45.40; Thu, 13 Feb 2020 07:45:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sI5SUgUK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729667AbgBMPpf (ORCPT + 99 others); Thu, 13 Feb 2020 10:45:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:50662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729398AbgBMP11 (ORCPT ); Thu, 13 Feb 2020 10:27:27 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6DFBE2168B; Thu, 13 Feb 2020 15:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607647; bh=xtM+YC0fsXmRTgOGiXE3QIqZjxM4PwqTDLgPxouqRsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sI5SUgUK0KIkpc+zFJpDXygJUVJrMQB7TzrbxZ2jViK9WQ1JOzC4MSPeKN8260Bhi fUYLc5t98bcp0qMnc2qz2DRpJbmRT2CXNOu/2Iustj9PYpFs5uohN4X2XqeOdnqwwI s+gIcdla8CorPAUBPPjp+PxwAiiCeOZOC6P1pJZ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , Andy Shevchenko Subject: [PATCH 5.4 40/96] platform/x86: intel_mid_powerbtn: Take a copy of ddata Date: Thu, 13 Feb 2020 07:20:47 -0800 Message-Id: <20200213151854.799686466@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mika Westerberg commit 5e0c94d3aeeecc68c573033f08d9678fecf253bd upstream. The driver gets driver_data from memory that is marked as const (which is probably put to read-only memory) and it then modifies it. This likely causes some sort of fault to happen. Fix this by taking a copy of the structure. Fixes: c94a8ff14de3 ("platform/x86: intel_mid_powerbtn: make mid_pb_ddata const") Signed-off-by: Mika Westerberg Reviewed-by: Andy Shevchenko Signed-off-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- drivers/platform/x86/intel_mid_powerbtn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/platform/x86/intel_mid_powerbtn.c +++ b/drivers/platform/x86/intel_mid_powerbtn.c @@ -146,9 +146,10 @@ static int mid_pb_probe(struct platform_ input_set_capability(input, EV_KEY, KEY_POWER); - ddata = (struct mid_pb_ddata *)id->driver_data; + ddata = devm_kmemdup(&pdev->dev, (void *)id->driver_data, + sizeof(*ddata), GFP_KERNEL); if (!ddata) - return -ENODATA; + return -ENOMEM; ddata->dev = &pdev->dev; ddata->irq = irq;