From patchwork Thu Jul 21 23:35:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9242673 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 2B807602F0 for ; Thu, 21 Jul 2016 23:35:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F5C020453 for ; Thu, 21 Jul 2016 23:35:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13BE6219AC; Thu, 21 Jul 2016 23:35:57 +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 B4A8320453 for ; Thu, 21 Jul 2016 23:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752535AbcGUXfn (ORCPT ); Thu, 21 Jul 2016 19:35:43 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33646 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751512AbcGUXfl (ORCPT ); Thu, 21 Jul 2016 19:35:41 -0400 Received: by mail-pa0-f68.google.com with SMTP id q2so5938708pap.0; Thu, 21 Jul 2016 16:35:41 -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=gmJXb5DGiixg1lZiHVfDPGZTSwFSqISxGPYGLYQM33M=; b=IYvFkiQJrq64dkTHtPd2cx4X9w8rvQF2XxNIeCL9gWrZ4+r9pvclFYavLyU180hcB7 UWtIxDrE1hUdlI4JM/NYU6kCY88gKPiFXaz/lw+Rj5CYKwqoovgIGEXzZJGfYKa379En 1/Sek8TCs7HUTEgs2yzX6yAQJ3oinDISfGtT/Hp3EQFf8ZW9UDvssjt9t+0kp/lgHcjf HvwDIpa/AQToissinfceCpoAWsQb0M4s2h3SwoLXxoZWMTpojMio1jv2+fUseKFjG6V3 nUGQsGFpUwPl5BE1Ngq5hiKFx8mzCrZlTgjsW0UyniAnhF2E/2GsJsIxOmp3Hx+zC8ie OlNA== 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=gmJXb5DGiixg1lZiHVfDPGZTSwFSqISxGPYGLYQM33M=; b=fWllC6P/KzzKe2mp8zsmriz2n2iZNly24UGJnM6A1hcHSp6eCWqpYSJFaQysZv6BmC sCgsebB7+Q4jl20ldhFJGz4DViwoL19pgJe2NlBpLphnEDu9hfFctyLcoH/3f36BZeKx NSRmq/HUxylKuqVwh1S5KBoZOCzBrhGtWjvp7EJu5Y3hbtxqHmOpKxxIniidv3S8vv/H NNxgcwqarL9SEZ9TYDYgrrlpnCeu2v3GdkV8BuRjSGchTJycYqwJyWjSDU1HdevOWqTJ yKhfoOul56cePTO9QC1ofJ57JFy3VB3HgVP0sBhmZiBh4OYwJoLumddWmzWSAuMzNYrd CkPw== X-Gm-Message-State: AEkooutnAsxxvi3q/OHEXB6Yb1RlrwF1O2n7vJvUAv+9JUPfSo1/g4x/y4ySyX6aCz8EJA== X-Received: by 10.66.15.3 with SMTP id t3mr1323328pac.14.1469144140894; Thu, 21 Jul 2016 16:35:40 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id p63sm14783890pfp.65.2016.07.21.16.35.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2016 16:35:40 -0700 (PDT) Message-ID: <57915c4c.4229620a.243a4.4d9f@mx.google.com> X-Google-Original-Message-ID: <20160721233534.894-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 v2 3/5] libata-scsi: use u8 array to store mode page copy Date: Fri, 22 Jul 2016 07:35:34 +0800 X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160721214202.GG23759@htj.duckdns.org> References: <20160721214202.GG23759@htj.duckdns.org> 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..a28e2ea94 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;