From patchwork Tue Feb 6 13:24:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugues FRUCHET X-Patchwork-Id: 10203101 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 4AF146020F for ; Tue, 6 Feb 2018 13:24:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3900B28A4F for ; Tue, 6 Feb 2018 13:24:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B7BA28B52; Tue, 6 Feb 2018 13:24:44 +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=-6.9 required=2.0 tests=BAYES_00,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 3894028A4F for ; Tue, 6 Feb 2018 13:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbeBFNYk (ORCPT ); Tue, 6 Feb 2018 08:24:40 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:25291 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752016AbeBFNYh (ORCPT ); Tue, 6 Feb 2018 08:24:37 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w16DIqkA007852; Tue, 6 Feb 2018 14:24:26 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2fya260ydt-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 06 Feb 2018 14:24:26 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EFCEB51; Tue, 6 Feb 2018 13:24:24 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 567EEEF3; Tue, 6 Feb 2018 13:24:24 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 6 Feb 2018 14:24:24 +0100 Received: from localhost (10.201.23.73) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 6 Feb 2018 14:24:23 +0100 From: Hugues Fruchet To: Steve Longerbeam , Sakari Ailus , Jacopo Mondi , Hans Verkuil , Mauro Carvalho Chehab CC: , Hugues Fruchet , Benjamin Gaignard Subject: [PATCH v2] media: ov5640: fix virtual_channel parameter permissions Date: Tue, 6 Feb 2018 14:24:09 +0100 Message-ID: <1517923449-7596-1-git-send-email-hugues.fruchet@st.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.201.23.73] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-06_06:, , signatures=0 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 Fix module_param(virtual_channel) permissions. This problem was detected by checkpatch: $ scripts/checkpatch.pl -f drivers/media/i2c/ov5640.c ERROR: Use 4 digit octal (0777) not decimal permissions #131: FILE: drivers/media/i2c/ov5640.c:131: +module_param(virtual_channel, int, 0); Also add an error trace in case of virtual_channel not in the valid range of values. Signed-off-by: Hugues Fruchet Reviewed-by: Jacopo Mondi --- version 2: - Fix code as per Jacopo Mondi suggestions: - int to uint - no need to set global to 0 - shorten error trace See https://www.mail-archive.com/linux-media@vger.kernel.org/msg125474.html drivers/media/i2c/ov5640.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 696a28b..3e7b43c 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -128,7 +128,7 @@ struct ov5640_pixfmt { * to set the MIPI CSI-2 virtual channel. */ static unsigned int virtual_channel; -module_param(virtual_channel, int, 0); +module_param(virtual_channel, uint, 0444); MODULE_PARM_DESC(virtual_channel, "MIPI CSI-2 virtual channel (0..3), default 0"); @@ -1358,11 +1358,16 @@ static int ov5640_binning_on(struct ov5640_dev *sensor) static int ov5640_set_virtual_channel(struct ov5640_dev *sensor) { + struct i2c_client *client = sensor->i2c_client; u8 temp, channel = virtual_channel; int ret; - if (channel > 3) + if (channel > 3) { + dev_err(&client->dev, + "%s: wrong virtual_channel parameter, expected (0..3), got %d\n", + __func__, channel); return -EINVAL; + } ret = ov5640_read_reg(sensor, OV5640_REG_DEBUG_MODE, &temp); if (ret)