Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3570879pxb; Mon, 24 Jan 2022 12:29:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxk8ocREkGm44EZgmViBN/7hFw2WlTWkz72c9wV1HRQp4JDTNWVIpvxqSFLw2uHrsm+LF4Z X-Received: by 2002:a17:90a:c78b:: with SMTP id gn11mr72167pjb.138.1643056173992; Mon, 24 Jan 2022 12:29:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056173; cv=none; d=google.com; s=arc-20160816; b=fq1K8Q+gOiI24ixmlUUnTDvdH35XZymUJTvyoGYMI3IFIqyQIcFM/XAEbVcAUceQXG Sw5U2AQqgOhILanLZ2aThFlNpSS21iS/Lae3J+izDodPGcO7uQXGDuo+cQMGm1xDWI6P RMozRLTdxQEkSf98YbdX+S+R6zj1Va7To/4YZAnzQDLOIyP6l2jiGG0cytgx20rRrcyL 3lh6CYykynzofYxuIi3BopPtF6pLt74aww6gbou3HbODh5DPK6VQMV3NS5aA5Pj+O96h og7YoW5+V+0tkb/9/p8xoijLQd7+LPwUwq101+16JzI/BKmGj88ZqaMl+uaV+x6l+u+p /+GA== 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=LFQ0GFVzyFYFWmaxKcezCHfIDe+Gj+fadSwHBn2CMCU=; b=KKijJhsFYN9c4ByI3naOSQWtKbmbblxU7tMp5pw4ImFnAzfMmDTQMEQF+giaRIEV0m 6UWh8QpKQmREJYleQ19HAni++p8dwwoJIo0fDlyMUPpanvvEquSDrT96sdvcyVIVZTuA yN0cg5KBh/Z96B5wffRv4MjO738EBwyZVdao7rI/smPCN/6u7Fjr7fHLAVHUukLd57Eb 9DjMGJRo08TcyO0+Zedd6VZlvTYdq55wVoqo0ph5vNnuk4/1Fq3brAjEIKROX7hHKrmd sNqY8xhURPQT2mTgc5mbw2SBzmxjwW2bjL71y4IvUPhwbs6DYronfHrWf1TmB2PrGTMF z1sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=159D2yPG; 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 l9si16402979pfc.282.2022.01.24.12.29.21; Mon, 24 Jan 2022 12:29:33 -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=159D2yPG; 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 S1352147AbiAXT3n (ORCPT + 99 others); Mon, 24 Jan 2022 14:29:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349159AbiAXTUX (ORCPT ); Mon, 24 Jan 2022 14:20:23 -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 CA375C02B8D0; Mon, 24 Jan 2022 11:07:39 -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 6FC57B811FC; Mon, 24 Jan 2022 19:07:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D0E8C340E5; Mon, 24 Jan 2022 19:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051258; bh=0ierq2hC0x5LeWSevBtfA0k91FVROzcHK/4VaadK2lE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=159D2yPGt7T19DHIDFY1oSc6eoeM83+9T/ZZ4XrqMCnzxvpELMCUD+9hixXFB8h2Q lmaKI1cJzaZV9w1V6S51TKDFBnPg3y39rw5dxbMuKx2xop3AJARqssa7fUVkw0XTPB L7wPaPr5g9NdvDdirBu4KQ4+HVoVguCkkg6WoK6A= 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.14 103/186] media: m920x: dont use stack on USB reads Date: Mon, 24 Jan 2022 19:42:58 +0100 Message-Id: <20220124183940.427295823@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 32081c2ce0da8..8a43e2415686a 100644 --- a/drivers/media/usb/dvb-usb/m920x.c +++ b/drivers/media/usb/dvb-usb/m920x.c @@ -280,6 +280,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. */ @@ -287,9 +294,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