From patchwork Fri Jul 22 18:34:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9244147 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 B984E60459 for ; Fri, 22 Jul 2016 18:34:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A336B1FF10 for ; Fri, 22 Jul 2016 18:34:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96DC02236A; Fri, 22 Jul 2016 18:34:32 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 4E2001FF10 for ; Fri, 22 Jul 2016 18:34:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbcGVSeR (ORCPT ); Fri, 22 Jul 2016 14:34:17 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:36608 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750791AbcGVSeQ (ORCPT ); Fri, 22 Jul 2016 14:34:16 -0400 Received: by mail-pa0-f67.google.com with SMTP id ez1so7331565pab.3; Fri, 22 Jul 2016 11:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date:in-reply-to:references; bh=zWoaBEnKqx9hpAzA0ZkAVRw9QZR6sw9/iFLR4Ggdrxs=; b=PWOeaR8xjcuDkTZzjEvJ6m2lB+D9zlMUsV5nCDQIGgICb8U1jxcIKVhvZOpjEOz8ps DpZfvjCaKY6X4H7AbQuijRUZuHYXLLls2TmSgB/IJdLuV5K2MMZIVAFGD+JazGrOKkqO CWpQbqCJE4mJWe4k+x8wl30lIgdtPnb7p6rCYylSYuJzbws4NXp4nV9exXdjq82UGhRm rARhT8wnfnI0TaGO/3KSgL2GToZFLQbF6tFmP1riWEaHOQWlxOHRE7Ixs5uVeyBYArWF sBTpL5l1wju61jPeMgl5rxnt2nuYu8qLeoD9Visdkk6w+1399ljeRsUtueiF4dhaMiaM ia8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references; bh=zWoaBEnKqx9hpAzA0ZkAVRw9QZR6sw9/iFLR4Ggdrxs=; b=BKxEiu/Fz32ixGk6nhmLGHKd4Ys3Sz9ETEyBwfsZRNL8Gfl4yBIDzgPWiHxc+GeGUN 3M3yFsgOltevUTCORHz2oC6Iw0rdH47W7EhFkOv5jRpJu/2lSvRKTD2e/7ymxrBXmJzh duWOn5BXPIMWVdZmdX+l5ygMRswCELnek5slfhbb+pWLEJcI9Em/ocGKA1VOUiazfoSw Ifcv5d0abueSBQEVbOlHOMSzXCh9UMX0nESmN7THcQjVPw+HxNJmLQZD3n2S5Bv4rFXO U1ye0SEwlVIBQAx6kpY8kZoo5IOr3CipDSA05W3F1KuR4MmHu/cTYwjsf6WtP1GCKMS/ c4Hw== X-Gm-Message-State: AEkoousdZkNAum55Id2lsQ4mVjgQuWLxeX/222smjBa8gXRKvO6EWrOUkzaAEFBYexkaCQ== X-Received: by 10.66.140.103 with SMTP id rf7mr4924399pab.75.1469212455662; Fri, 22 Jul 2016 11:34:15 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id p4sm21668878pac.46.2016.07.22.11.34.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2016 11:34:15 -0700 (PDT) Message-ID: <57926727.840e420a.d7fc9.38dd@mx.google.com> X-Google-Original-Message-ID: <20160722183408.9415-1-me> From: tom.ty89@gmail.com X-Google-Original-From: me To: tj@kernel.org, hare@suse.de, sergei.shtylyov@cogentembedded.com, arnd@arndb.de Cc: sfr@canb.auug.org.au, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, Tom Yan Subject: [PATCH resend v3 3/5] libata-scsi: use u8 array to store mode page copy Date: Sat, 23 Jul 2016 02:34:08 +0800 X-Mailer: git-send-email 2.9.0 In-Reply-To: References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, char could be signed char. In that case, bytes larger than 127 would be converted to negative number. For example, 0xff from def_control_mpage[] would become -1. This prevented ata_mselect_control() from working at all, since when it did the read-only bits check, there would always be a mismatch. Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 4a4e6f1..5cfcb4b 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3610,7 +3610,7 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc, { struct ata_taskfile *tf = &qc->tf; struct ata_device *dev = qc->dev; - char mpage[CACHE_MPAGE_LEN]; + u8 mpage[CACHE_MPAGE_LEN]; u8 wce, mask; int i; @@ -3668,7 +3668,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc, const u8 *buf, int len, u16 *fp) { struct ata_device *dev = qc->dev; - char mpage[CONTROL_MPAGE_LEN]; + u8 mpage[CONTROL_MPAGE_LEN]; u8 d_sense, mask; int i;