Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3548494pxb; Mon, 24 Jan 2022 11:58:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo3AhxPQ+WnjTc5ez4x2Xc/ulbX/dgStNL/fXYnV1mHABr37CVviC2jslZCv4sGrtF83Cs X-Received: by 2002:a63:bf0d:: with SMTP id v13mr12849277pgf.500.1643054247148; Mon, 24 Jan 2022 11:57:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054247; cv=none; d=google.com; s=arc-20160816; b=sawfyg2S32KoMBCx91cBUhzsHjE/KEoSDx9ZAXveteriovM3UGMpoAJZFD4mUTOWeg bCPPQzAY0QhlrqgH9o3BJTvScl4uKo7n7Q+9Il4/6OEF3P6O9g4X1n3lDhlasPjQoKSB TesEu8htlJXL/DknhJUfptAjSiU7qTmefOz5lQ+rvZQUpuYLe68eN9HQ1MIlnxHa2wRi SSjWSuZ7y9CDVHWRaZ86FllU1i50Ufx0MK/SZX4r/bMaZWNwUpycEQMYiA+tTCB0YFie Xzyvbk6VDkGZwG2+qzCO/49OMvLclllCrTK+ph1UXKP6vAjPTP2i5KR/EpeBACQaNd2W +OBQ== 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=c88DLAC1Ant1CnL9mvtmUgX0nGgFm4XSV/0c6eOPRgI=; b=ntAR3jIZ7SF6WDQY7CBt7MU6lQXXKKFWsHsAbXUKLGBsGyLV4XSJeCtFS8poNavJd4 DxiueokOSFQDAbwyR6/ahyjnWLcHSQDqEwXjB1cD2Cq37ddZwCn9sBliPGsgu6Kva7kQ dLdN6F4BpGQJ0eX93QesYlZtFJql+UrfsKG8HYNIabbzSNg75tNxDN0YZXt4yJT9aWYz YsvSfKNV6pCpexTRpUdrz46U4KZgPzOwZaBOVUHSVDB0OwpPC9adBJhigHhveaZ2w0Yc U55SmsrJ5t6zuyU7NoM+D+1REslxE45MMitwHBAbE5koGHD/5aywWnFtw29rdyNsXkD2 uc/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VRNJXTh7; 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 k1si8977872pgn.306.2022.01.24.11.57.14; Mon, 24 Jan 2022 11:57:27 -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=VRNJXTh7; 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 S1343922AbiAXSwl (ORCPT + 99 others); Mon, 24 Jan 2022 13:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242005AbiAXSvY (ORCPT ); Mon, 24 Jan 2022 13:51:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF39AC06177E; Mon, 24 Jan 2022 10:51:15 -0800 (PST) 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 96C70B8121B; Mon, 24 Jan 2022 18:51:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9646C340E5; Mon, 24 Jan 2022 18:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050273; bh=4jx1Bl4S5uQyeaT0H4TWgXfSBRxVssLycfkRR4kmCkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRNJXTh773fKJA81a19OFXtUAvLEswz4a3/JCCAL8rEZHLovVQFqqa/tZcyEbAdQx 7BLd/hj7DCroJQWpQ7lDoT/a2Kv2IYggYJR/m/r3KJ9Q3u+Qa71tAtIs80dfxaf4WB 1L7QyJQz4KKGzIexGqE6Ayv6/swNRmzAYS90oH0Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, rkardell@mida.se, Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.4 066/114] media: m920x: dont use stack on USB reads Date: Mon, 24 Jan 2022 19:42:41 +0100 Message-Id: <20220124183929.139516454@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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: Mauro Carvalho Chehab [ Upstream commit a2ab06d7c4d6bfd0b545a768247a70463e977e27 ] Using stack-allocated pointers for USB message data don't work. This driver is almost OK with that, except for the I2C read logic. Fix it by using a temporary read buffer, just like on all other calls to m920x_read(). Link: https://lore.kernel.org/all/ccc99e48-de4f-045e-0fe4-61e3118e3f74@mida.se/ Reported-by: rkardell@mida.se Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/dvb-usb/m920x.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c index eafc5c82467f4..5b806779e2106 100644 --- a/drivers/media/usb/dvb-usb/m920x.c +++ b/drivers/media/usb/dvb-usb/m920x.c @@ -284,6 +284,13 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu /* Should check for ack here, if we knew how. */ } if (msg[i].flags & I2C_M_RD) { + char *read = kmalloc(1, GFP_KERNEL); + if (!read) { + ret = -ENOMEM; + kfree(read); + goto unlock; + } + for (j = 0; j < msg[i].len; j++) { /* Last byte of transaction? * Send STOP, otherwise send ACK. */ @@ -291,9 +298,12 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu if ((ret = m920x_read(d->udev, M9206_I2C, 0x0, 0x20 | stop, - &msg[i].buf[j], 1)) != 0) + read, 1)) != 0) goto unlock; + msg[i].buf[j] = read[0]; } + + kfree(read); } else { for (j = 0; j < msg[i].len; j++) { /* Last byte of transaction? Then send STOP. */ -- 2.34.1