From patchwork Wed Jul 4 15:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10507151 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 2EF8B600F5 for ; Wed, 4 Jul 2018 15:02:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FFBB28D81 for ; Wed, 4 Jul 2018 15:02:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1483A28D84; Wed, 4 Jul 2018 15:02:53 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 9F4E928D81 for ; Wed, 4 Jul 2018 15:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752388AbeGDPCv (ORCPT ); Wed, 4 Jul 2018 11:02:51 -0400 Received: from mail-lj1-f177.google.com ([209.85.208.177]:43308 "EHLO mail-lj1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752145AbeGDPCu (ORCPT ); Wed, 4 Jul 2018 11:02:50 -0400 Received: by mail-lj1-f177.google.com with SMTP id r13-v6so4518456ljg.10 for ; Wed, 04 Jul 2018 08:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=hOT9lq9M0rkLQ2+BI2L7CFETOq93Og4mLJHnIxwoIWM=; b=EbFYxmtGohrXKL7CFH3qBayZIydhXKhuK9eGc5ulWH9M5/YmV/GJbtqCHYteDU5eu8 qvttjDTTUmAFbS5bdRGyyb6xpRM11hq/m4OT4tYZO9WwQOWmLpS/ZDwCvk7oMGRQ9a8w B/2zSQOfbBbxwkJs4ffwtnkiGqTAZEKbu0TDIEcDoPG2quchEtVHW/En369P1YzuASBS AKuGPIQCn1qiTO1Rvp1Glpj46QyNx3vvlJKrOR7mc237BtxzxUj85q4CslcajFO7RNC8 ZyTXoSZWwsA3Of70v3/hS0OKx3ma+dGh3lsvUeSc3Q6R++kKRsvFCyUwwv+23C7DiE5r QYxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=hOT9lq9M0rkLQ2+BI2L7CFETOq93Og4mLJHnIxwoIWM=; b=DMoJg5zad6Q4E/pA1KtydqxHP0uXeCtERA0Gs3igh7IZX0linhAHvRzBTzfTuoCOk0 mIWxZuiezu5aXcz2Trq2s6kUZw4mSuFqoswCrkGdux3AqTC2zBZUy3QiF8IhnCARr+GT jHCzRC/dRcbvbT618TmyQt6jIb25VViWV+l4MA7bXGHEThufzjL/hFYZvlXc8+fzZ399 Gmrx1ijkS8OHsWMSkLZ1wk8KQlVmNyyQ09DEHJDP/4LCGprIxgKSR1HYShUfDddRFUWU nIU2LillaI1qfkWQUX8aHrW5dJizFLzCp3a32QqWsQkvTTClG1cVpzrrfMUecIgHTmRP jZFQ== X-Gm-Message-State: APt69E1qoZsN0lQcdvpWuhoyesgG/UHIPOp9VnIVVj30ofTEyAxY6p2+ CJmnImOBkgzXOrYMn9O1tqM= X-Google-Smtp-Source: AAOMgpe3hqPK/xEujV3SAH+Vnv3+BSY/3wdU3lYfS9PwRCTXaYHygHMzOllQFKLOWamoodYTefSnTg== X-Received: by 2002:a2e:5243:: with SMTP id g64-v6mr1748486ljb.144.1530716568889; Wed, 04 Jul 2018 08:02:48 -0700 (PDT) Received: from xi.terra (c-8bb2e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.178.139]) by smtp.gmail.com with ESMTPSA id u203-v6sm841913lff.40.2018.07.04.08.02.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 08:02:48 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1fajIm-00078e-5H; Wed, 04 Jul 2018 17:02:40 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH 3/4] USB: serial: kobil_sct: fix modem-status error handling Date: Wed, 4 Jul 2018 17:02:18 +0200 Message-Id: <20180704150219.27389-3-johan@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180704150219.27389-1-johan@kernel.org> References: <20180704150219.27389-1-johan@kernel.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to return -EIO in case of a short modem-status read request. While at it, split the debug message to not include the (zeroed) transfer buffer content in case of errors. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Johan Hovold --- drivers/usb/serial/kobil_sct.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index a31ea7e194dd..a6ebed1e0f20 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -393,12 +393,20 @@ static int kobil_tiocmget(struct tty_struct *tty) transfer_buffer_length, KOBIL_TIMEOUT); - dev_dbg(&port->dev, "%s - Send get_status_line_state URB returns: %i. Statusline: %02x\n", - __func__, result, transfer_buffer[0]); + dev_dbg(&port->dev, "Send get_status_line_state URB returns: %i\n", + result); + if (result < 1) { + if (result >= 0) + result = -EIO; + goto out_free; + } + + dev_dbg(&port->dev, "Statusline: %02x\n", transfer_buffer[0]); result = 0; if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) result = TIOCM_DSR; +out_free: kfree(transfer_buffer); return result; }