Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3555359pxb; Mon, 24 Jan 2022 12:07:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXQG1djHQv1H5PSHiYjPm5zdSL34Ja5eCF8pcIFnnW8k5oC7lnhlXSz4KtWxJbkZqRUNRD X-Received: by 2002:a17:902:b202:b0:149:9a8a:f93b with SMTP id t2-20020a170902b20200b001499a8af93bmr15400593plr.127.1643054839962; Mon, 24 Jan 2022 12:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054839; cv=none; d=google.com; s=arc-20160816; b=08dlkJaY7GSPmhzlJK41TV2Zay1CbZUQB897Ybv2iOnAzvZy5sMpeet4TgBJBP7CHG P8TyBZcApKn48I1/vMOwMgvePJ5xu5Ve2VKrBXR1R5Hq2uK5MW2IXSpdY21Unp2w/lbT Hl5j89xrlFvCZc/f9SNXnagVEBfrNDatwy/fwKm1OEJtNLiPGGsu1wdqUtNuhWBEdNI6 Le7W5KhihCIoFqo6WrqF9CK+rD4E5usNAyKWbu/Wkn6EIdpGCMjSvJNfqXS0bGeX6pPb bzPkfWWuRRlE+huH2yQKAA+KxvhXXa397nOBFVbRCFLFeAkjO/4jLquXs50FtpL/HVWS 5GmQ== 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=pWZlMwKLo9EQ9tZVMIqKzrCHVt1FoMbu8TP7z05fGmOUqkvUwEDNZVXLZT/dJrsFTI Gy9c0z5eIvBXhIVc/jqpP23cTu2yrXbbaL7nvGGx+Y20ULsXXRYbLOsPPCrcKBWqmazX Anc9ODeWf249uAMaKneh3aC8DcE/oilUWwkpvJr/FsD9GmEWxoj/oQr+O6upITdEba04 MJ5IYeiF5R6rOJrA6nH0q22D5ZQUV5QeZs0A2tYb1Ur88OJouXa9DVifqYXjvps6GeTK vgwvY2x91xJSx5Bp87taugkPqSrCZHWm6OvZ+/ITy3iKlmZzUr9B6w8xuKBA1rRJgoAS OqYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CaYt9ENs; 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 k1si8984119pgn.306.2022.01.24.12.07.06; Mon, 24 Jan 2022 12:07:19 -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=CaYt9ENs; 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 S1346351AbiAXTFY (ORCPT + 99 others); Mon, 24 Jan 2022 14:05:24 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:57388 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345360AbiAXTAK (ORCPT ); Mon, 24 Jan 2022 14:00:10 -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 B27FCB8119D; Mon, 24 Jan 2022 19:00:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2837C340E5; Mon, 24 Jan 2022 19:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050807; bh=4jx1Bl4S5uQyeaT0H4TWgXfSBRxVssLycfkRR4kmCkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CaYt9ENsPHL31F3ng/UEsgKGmXW/2Sh2PjUe68INQrCSlDyFZObqonXN0swwjVy2E qaa36zOmWnlmck1TQRKfOMRgqj6Rggs8UUDMOdlSayY4ySyaWYrXKODa22h59EjMtX qXEQe4xaNouaMExAlBe4zgJ6qnIseb1963gx07r8= 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.9 085/157] media: m920x: dont use stack on USB reads Date: Mon, 24 Jan 2022 19:42:55 +0100 Message-Id: <20220124183935.484109346@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@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