Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3573941pxb; Mon, 24 Jan 2022 12:33:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWpYwCHjTdBmxkFbnShXQl3+AlozFfqdFdXwtLMx50kiWedNjFJRhPHSKv6/EVgb/PTIKC X-Received: by 2002:a63:115c:: with SMTP id 28mr12869553pgr.382.1643056423253; Mon, 24 Jan 2022 12:33:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056423; cv=none; d=google.com; s=arc-20160816; b=E9HGfC31aU0eabgjkbAOhQ7mztjq1EdP0pmHsHAQ/JF5nOX/QGAOkD0a9bmsuA15qq klri9eDEslosqqWGWdWGhKHqPl8hmz2uMsDGdXS+lAYOci6acBxAmvGOnPew6Sb6OgQL 7CvGuCFi3PEQgRPqOIzUvSUB9vPafFkDMybzsbVsqu1QLWgsSJfSbfa5jNeFeRr5Z6YN biim3SVCvpHsHJzAd9LmDrm6BHbj6BiFiMMo+RC49T9BKeTYwbRncwBkpfkdYf5tq++l 7YtKmvJjmguM5PcpS+cjOdB4mN4dhER7rLRx4aebkkji9iVii2TpH3tc7dEEMZCP0aEA Fb0w== 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=1LHOCass2Uq/9I2HoR/Ef8GaVlq5JchW9kHJz8R63no=; b=o4NbvLovr2w7l3xmWJQ+rZtHKpqPOjch5YIebWa+RaTKc3pi5AaLlmzoGX+S5Bep+/ bDs6i5jEAd1DsypEB4axjMpbu4R6R+T24vf1oGdIxWfHkUhaLU3lf2h+ZkJ1zQCDoQ1l mVH/QD3Bdn0G1b0m/RT4kyIg+SuWW2eLyiBwH8lTcRJtTUGoNfkSBbVIm3/UMIlNWnFt qgePDwLX1k+XblbvAd7PAht2wdjiewT8JoSx0fjGG2fmrxSiqfMir0+dBjDOr3fvZ+Xm 3cZpvrNKiB1BAt3UpQ+bO4crgyPQSaNWfWQ87aGAsUqiHu62jNuVrwjB54XSUw84mhgg O6LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1PqQ7rSc; 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 a3si12884652pgc.510.2022.01.24.12.33.25; Mon, 24 Jan 2022 12:33:43 -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=1PqQ7rSc; 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 S1345321AbiAXTmQ (ORCPT + 99 others); Mon, 24 Jan 2022 14:42:16 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:56286 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353189AbiAXTdV (ORCPT ); Mon, 24 Jan 2022 14:33:21 -0500 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 24134B810AF; Mon, 24 Jan 2022 19:33:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BC05C340E5; Mon, 24 Jan 2022 19:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052797; bh=8H5EoVxDGihervYYRp6fPu7r8TlKkjq40J4IIxrxiNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1PqQ7rScLD86SrJLr6jO+8lcb2OJ/uzUeJvNRYQLnWEartjEl41BJ9r1B8J9Ll8uO evG8yz4uwpaU6PRbiaDZYkFY3QWjmmGokq6W89g0Di0exkstGGE5aeLqcloZXrPcI4 /a6tK2WaRru/eQhoEGikJR9hCHKK9ncaKF8ul43A= 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 5.4 178/320] media: m920x: dont use stack on USB reads Date: Mon, 24 Jan 2022 19:42:42 +0100 Message-Id: <20220124183959.716996501@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 d866a1990a7d2..7282f60226558 100644 --- a/drivers/media/usb/dvb-usb/m920x.c +++ b/drivers/media/usb/dvb-usb/m920x.c @@ -274,6 +274,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. */ @@ -281,9 +288,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