From patchwork Mon Mar 26 18:06:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 10308473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 302A760212 for ; Mon, 26 Mar 2018 18:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22865287FD for ; Mon, 26 Mar 2018 18:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1771F28B58; Mon, 26 Mar 2018 18:08:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0708828A48 for ; Mon, 26 Mar 2018 18:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752610AbeCZSIg (ORCPT ); Mon, 26 Mar 2018 14:08:36 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:37683 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752377AbeCZSIf (ORCPT ); Mon, 26 Mar 2018 14:08:35 -0400 Received: by mail-pf0-f194.google.com with SMTP id t16so3610424pfh.4 for ; Mon, 26 Mar 2018 11:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=95sZ6LOdtGJusQDwnB2zDadxEYGS2erI1u5RtVsRTKc=; b=PeOuASOndVO5o9TcQb5WX676U3BJXXEddyTROCTdSJhowODVE9fIE7xNmHxXSDHOLh 7um3GW8i6Y3vuXG6Qlf0OZGLPwrQR5u2WGxVgTJELiHXjujKeIj/IGRJ8lcijkub1oQ9 dfcv5ktjzVgC5XF71eb32Qk+v9hzfBHE+Ut0SkZRZvWWypEalCUyRqGb6D59xpidJJYH Og939CQjVQBcMhuBs+BeAAmGjDUChGbpsbKyL3IFyli4wJaCJNltXqY+0Z7tDafbfl7V qMSkC471R2MCvR1sleqW2IuPcp20TzpPbRiQo78iS1e7FU1yrU09Gkx7M+TlJsek5qH6 66Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=95sZ6LOdtGJusQDwnB2zDadxEYGS2erI1u5RtVsRTKc=; b=NPBmK9Qxm6iQBsQWegdIV4RdBN2SB6UK8IVCvmEO5m2UciIfNjLMk4/e3uWodXmgio mRm+Qt14E+C9q0PMFVTte/DLZeiG79rLmr2SZC/7X1pMdflb+/xkJdkmoNM/jsJCwU78 oOPRsCeejXI77+Lg7H/X69i+DsA7IvxL6totY9lJ7qwIq79stNFpcmSRUzpgjs4DvU8k MGpCyUyDSYB4iV66Wk3eL9lLWYMVHX2VqPJUhLt4CQft8fWwtGWh0yLxDHPJOXsEdvlX w7/wQqK2jjZP3YmXmtwFmE0RruUa5AeIO17CDdedJ4cM7iSjqVF2bmNOMLlYyQuyoZKO +OIA== X-Gm-Message-State: AElRT7E0P9WPBTonSVzrwN+ZZdy0B2BVtKym6i9jsdewez/veQ/tBOTn GCxL37Rvc3t1QXTja88aJ4qQww== X-Google-Smtp-Source: AG47ELsh+wsJK3+ouHokFG3HfmpLu8t5C5uk4eGO/fqye8CdjWub7CsjS7gQmzELhaa6ACPG05FXIQ== X-Received: by 10.99.112.92 with SMTP id a28mr28587844pgn.17.1522087714472; Mon, 26 Mar 2018 11:08:34 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id q6sm27150368pga.37.2018.03.26.11.08.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 11:08:34 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: mchehab@s-opensource.com, Akihiro Tsukada Subject: [PATCH v3 5/5] dvb-usb-v2/gl861: ensure USB message buffers DMA'able Date: Tue, 27 Mar 2018 03:06:52 +0900 Message-Id: <20180326180652.5385-6-tskd08@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180326180652.5385-1-tskd08@gmail.com> References: <20180326180652.5385-1-tskd08@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Akihiro Tsukada i2c message buf might be on stack. Signed-off-by: Akihiro Tsukada --- drivers/media/usb/dvb-usb-v2/gl861.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/gl861.c b/drivers/media/usb/dvb-usb-v2/gl861.c index a57afb12e84..4c29e0b417e 100644 --- a/drivers/media/usb/dvb-usb-v2/gl861.c +++ b/drivers/media/usb/dvb-usb-v2/gl861.c @@ -22,6 +22,8 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, u16 value = addr << (8 + 1); int wo = (rbuf == NULL || rlen == 0); /* write-only */ u8 req, type; + u8 *buf; + int ret; if (wo) { req = GL861_REQ_I2C_WRITE; @@ -44,11 +46,23 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, KBUILD_MODNAME, wlen); return -EINVAL; } - + buf = NULL; + if (rlen > 0) { + buf = kmalloc(rlen, GFP_KERNEL); + if (!buf) + return -ENOMEM; + } usleep_range(1000, 2000); /* avoid I2C errors */ - return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), req, type, - value, index, rbuf, rlen, 2000); + ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), req, type, + value, index, buf, rlen, 2000); + if (rlen > 0) { + if (ret > 0) + memcpy(rbuf, buf, rlen); + kfree(buf); + } + + return ret; } /* Friio specific I2C read/write */