From patchwork Wed Mar 28 17:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 10313635 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 07503600F6 for ; Wed, 28 Mar 2018 17:01:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED56A29F46 for ; Wed, 28 Mar 2018 17:01:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC0FA29F8A; Wed, 28 Mar 2018 17:01:46 +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 9812829F46 for ; Wed, 28 Mar 2018 17:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753225AbeC1RBp (ORCPT ); Wed, 28 Mar 2018 13:01:45 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:38073 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753004AbeC1RBm (ORCPT ); Wed, 28 Mar 2018 13:01:42 -0400 Received: by mail-pl0-f68.google.com with SMTP id m22-v6so1962291pls.5 for ; Wed, 28 Mar 2018 10:01:42 -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=Xm+3VM8VRXCyqbGvFgH30ataal/TnU2jrtUIeYqm7/Q=; b=nbk9Fb1cCUG+IeLIgZwQcEvu3L11c6vkiNdinx4aj+6OcNzFrNvj3gJ1AAU+frW/fs Bqw1+ZnG/IwyAYuFvqTbnK6tmv0pErXLtA33o8k/oKUPb8QMDFi5HPNuKaN3fBEyJKJM jqgRW/yMA0G/G2uoN6MoW1Wm5PeRjMwf+nLh/5Sv+srJ0gDHZDPWy5Yad7XLpK/cSIwS EHsCQgE7cCo7bp5tCqkBG1FTvHNGQaBzTuen0NtnEVOnLQieoP4SoeSLL28GFB16MdZt 0uEJ0f+/9gK92meDrSB3iJ5ikXVLckjG8jpFf9eiTtOtm8S2NntTFmvKO+RznE7HDZY/ 2Jhw== 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=Xm+3VM8VRXCyqbGvFgH30ataal/TnU2jrtUIeYqm7/Q=; b=pjKMLOD9WEbxwu0CSR9o3mHGAIPDZc2+TZXYOkrqrCYiVusTLDQ6NS/frYTZ+rR0+d XmxI1qxKBRsIz7NzZPFqaPHhWgBxvB6871Xlh0MWZuUK8fwcg2WFymYDJWLgSselIGEG tgPdERMBwhyWOGRcUKfIjsQJCABTA9OZh677U1HZGB9QQxnDtRz+478d6Gmfe2c4Z+Cu DpsZZY+YtKVLPJj0a6yhX2r4f1AjD63MZfm6kWRepuUv5NKRfq0E1HlJ4YNWqSd3lwsu UW5zxKQX0SUlETnOn+aNQ9tHqYbta9gPrtJhbec5dhJnPj++AIInHVDJbtIAGiglxYH3 5wqQ== X-Gm-Message-State: AElRT7GMbnD6lN3FdqkRFU9arsV5Ntb4ieqjVjrN2aWUfcFQ+mW1XwR0 HkzuONLkkfMN6e9trKNyVkjeqg== X-Google-Smtp-Source: AIpwx489vZ7Em1SlWX725XssURnfiorrxo5qS1hAmTjRInapyl8lcUJaSVn7lWFIlFlZP+uRyN6mWA== X-Received: by 2002:a17:902:7894:: with SMTP id q20-v6mr3478871pll.86.1522256501030; Wed, 28 Mar 2018 10:01:41 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id u4sm8950012pfb.43.2018.03.28.10.01.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 10:01:39 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: mchehab@s-opensource.com, Akihiro Tsukada , crope@iki.fi Subject: [PATCH v4 5/5] dvb-usb-v2/gl861: ensure USB message buffers DMA'able Date: Thu, 29 Mar 2018 02:01:01 +0900 Message-Id: <20180328170101.29385-6-tskd08@gmail.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180328170101.29385-1-tskd08@gmail.com> References: <20180328170101.29385-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 --- Changes since v3: - none 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 6f6dfa65bba..a5c83b561a4 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 */