Received: by 10.192.165.148 with SMTP id m20csp836263imm; Fri, 27 Apr 2018 08:16:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQzulI0NxF6ZRFTLq9GOqkvGRb04Fsz0hCIpfhtnxPeZeJDoSbFzfikkIpHP+wMF5ZVdpW X-Received: by 10.98.194.5 with SMTP id l5mr2584956pfg.6.1524842166301; Fri, 27 Apr 2018 08:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524842166; cv=none; d=google.com; s=arc-20160816; b=KwZ3d91iweo3O3nxQPZyONUPNE3ZhIBmWKKPRQe7BXs5Rk3cWp+8tsB6dDAL/MAViX ewHWkdqPt1rOaXaD154Qau6R4BA+p5/8Sj22wHm5AvFCDaci6R0sJxTTEidCo/QPaFFx sq6f9IfjeWqIlkcqDpzc+DUxYn9iOZJ21WKFYnF4okhDyf8UoqrN13dIyrlXJEeY48du RbS6arNWi4D3+PqrYrMlh5maP4TNPxb9ZzYYgy6ocQ/4GA+L0y822pfC176L0l1RlurG oP1OyKh8hRmZhehPlXW47QQBZxxQ8BVUGQpAwcxg2b8Sa7cZSJotKi8fPE5ueW4Kqzqh plJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=9Pn4TWeOt2Y5lwcQeZbRf2LxCYkLZG7NdVMeQMVVDAI=; b=BUdljnIeIYbvCdHLqu7nC3k/OPplcIbPmrSpGVqajJhi+JbgLHC89gFjbaYbFdd/Xz rcSQQo7Kw4QUKA3yo2U5iSznoNgsON9ah2Q3+IggrrKANtjpo1Ec6JMZct01RwpVbiJ4 9ofiVhGhRDmvGzF9MWL6ESTbH1QVBjfUhwWE0loQd+bq6nlxRQw5cYnYtjiEl3NMvykw WEIufaEUI4GeyM0k0HiB2uJlf8w94Z+S1FOU5IBWflEWT42ZtmflaUhTNLUrsUmGsuzo s+Irf27i6WJ3q0n2/mpx1RZ8dv6aKflm+0dn3cbInDKCsTTZjSn2rDOyB1ZIkwvkrjP4 wTgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si1423465plg.463.2018.04.27.08.15.52; Fri, 27 Apr 2018 08:16:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933697AbeD0POk (ORCPT + 99 others); Fri, 27 Apr 2018 11:14:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:50262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932835AbeD0ODs (ORCPT ); Fri, 27 Apr 2018 10:03:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A309621890; Fri, 27 Apr 2018 14:03:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A309621890 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mauro Carvalho Chehab , Amit Pundir Subject: [PATCH 4.9 14/74] [media] stk-webcam: fix an endian bug in stk_camera_read_reg() Date: Fri, 27 Apr 2018 15:58:04 +0200 Message-Id: <20180427135710.494001755@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135709.899303463@linuxfoundation.org> References: <20180427135709.899303463@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit d08876f524a605d64c7ca32cb8e9f5be3839e82e upstream. We pass an int pointer to stk_camera_read_reg() but only write to the highest byte. It's a bug on big endian systems and generally a nasty thing to do and doesn't match the write function either. Signed-off-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab Cc: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/stkwebcam/stk-sensor.c | 6 +++--- drivers/media/usb/stkwebcam/stk-webcam.c | 11 ++++++----- drivers/media/usb/stkwebcam/stk-webcam.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) --- a/drivers/media/usb/stkwebcam/stk-sensor.c +++ b/drivers/media/usb/stkwebcam/stk-sensor.c @@ -228,7 +228,7 @@ static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val) { int i = 0; - int tmpval = 0; + u8 tmpval = 0; if (stk_camera_write_reg(dev, STK_IIC_TX_INDEX, reg)) return 1; @@ -253,7 +253,7 @@ static int stk_sensor_outb(struct stk_ca static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val) { int i = 0; - int tmpval = 0; + u8 tmpval = 0; if (stk_camera_write_reg(dev, STK_IIC_RX_INDEX, reg)) return 1; @@ -274,7 +274,7 @@ static int stk_sensor_inb(struct stk_cam if (stk_camera_read_reg(dev, STK_IIC_RX_VALUE, &tmpval)) return 1; - *val = (u8) tmpval; + *val = tmpval; return 0; } --- a/drivers/media/usb/stkwebcam/stk-webcam.c +++ b/drivers/media/usb/stkwebcam/stk-webcam.c @@ -144,7 +144,7 @@ int stk_camera_write_reg(struct stk_came return 0; } -int stk_camera_read_reg(struct stk_camera *dev, u16 index, int *value) +int stk_camera_read_reg(struct stk_camera *dev, u16 index, u8 *value) { struct usb_device *udev = dev->udev; unsigned char *buf; @@ -163,7 +163,7 @@ int stk_camera_read_reg(struct stk_camer sizeof(u8), 500); if (ret >= 0) - memcpy(value, buf, sizeof(u8)); + *value = *buf; kfree(buf); return ret; @@ -171,9 +171,10 @@ int stk_camera_read_reg(struct stk_camer static int stk_start_stream(struct stk_camera *dev) { - int value; + u8 value; int i, ret; - int value_116, value_117; + u8 value_116, value_117; + if (!is_present(dev)) return -ENODEV; @@ -213,7 +214,7 @@ static int stk_start_stream(struct stk_c static int stk_stop_stream(struct stk_camera *dev) { - int value; + u8 value; int i; if (is_present(dev)) { stk_camera_read_reg(dev, 0x0100, &value); --- a/drivers/media/usb/stkwebcam/stk-webcam.h +++ b/drivers/media/usb/stkwebcam/stk-webcam.h @@ -129,7 +129,7 @@ struct stk_camera { #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) int stk_camera_write_reg(struct stk_camera *, u16, u8); -int stk_camera_read_reg(struct stk_camera *, u16, int *); +int stk_camera_read_reg(struct stk_camera *, u16, u8 *); int stk_sensor_init(struct stk_camera *); int stk_sensor_configure(struct stk_camera *);