Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2378219pxb; Sun, 17 Apr 2022 20:53:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0vaPlgxNFcleKIwpMpk6oDhb7h1c629MGKWR7TEIL/emBO/ZrEFih45YZQAqa2Q5q7ivo X-Received: by 2002:a63:1b20:0:b0:382:70f9:dc24 with SMTP id b32-20020a631b20000000b0038270f9dc24mr8210066pgb.485.1650254001836; Sun, 17 Apr 2022 20:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650254001; cv=none; d=google.com; s=arc-20160816; b=B98CqfMqa1TdBToRosHqzVes7VmK42s4I+wf4tDfiWhnqGtt5Hu4qXg8JeJgQgPz0S EN2vcYj/xxIHUr6prgdRlt0xaQu9kGaNCHA06QIfdnSSdezE2i57w+qwidKd72jb/kdN cR2INV6Y2En4qNJ++jAg+rsVdt9X0dxmlpAGeAHWv63QgE6JpV4zW0p4rajSeObA7X/7 j22hjUPxF7rmqgXLB42ajI3GuZ56YjE7X7zurk//U3OgMIjemmTPpnZiYjIB8eK15dIF S96G9jN4/clqVXN7X5z88nlA6AW+JD4FxmdyoWwLQI/OpIuxATUtWn5LuEIIM2Ujrfv9 MMMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/pFssxoLZmPuWgKi5vncIMSo1DCdax1EcoWBNQif+HM=; b=hx4Z8hodlbWgfDyA6PfRYU+EyvZfOx7E/Ko5FOr40nqqPQ5+jLZlU9uZ9wWyZi4ogA VyElG3HGVrC1zxnyQDrtZHG2ge/pmCeEhNMti1rvhn23rz5ezLaS/j2lwXBY7K1O9Kbp Znwck0eIhWQeQ47+ZWy6YeFJZ788XcyZkoiwFuDsAQ1YR99cUngdROe9VqnyQTT8jT8H vwNInaPl/HCWPt+F64mvzoEETgX/OF3yWssFMmrYKxyb4RZmW7Hsj1uiMyZFnkaPYRqe zgElBV/+ewanbm4jG/b3yFsM2gz7ha77HfRutvbQswsO6Ss9t7OLEzXZDa0uNfEAkFQK x3LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=D+xkEg1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a170902724300b00156eeb5cd6bsi7241425pll.562.2022.04.17.20.53.05; Sun, 17 Apr 2022 20:53:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=D+xkEg1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231838AbiDPLw3 (ORCPT + 99 others); Sat, 16 Apr 2022 07:52:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbiDPLwV (ORCPT ); Sat, 16 Apr 2022 07:52:21 -0400 Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E3B563C3; Sat, 16 Apr 2022 04:49:49 -0700 (PDT) Received: by mail-vs1-xe2a.google.com with SMTP id i186so8894634vsc.9; Sat, 16 Apr 2022 04:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/pFssxoLZmPuWgKi5vncIMSo1DCdax1EcoWBNQif+HM=; b=D+xkEg1a6hjF1V3UTFFTmAqCKPMeLHkneGOn8hpsmi57kTSwyip+IMCZrj+bER4Duk 7v4NA8FQMiEUz6XzVEOxu+E8Lj9Dauk/WdZI52PlGVbMNo8QArXOZoJQRVcaug2ySAq7 DnBrKrjR5D3dtThLWaHXkpg/aCaur5J7NdvtsHEizAs4AOkTeygAgYIuq/Ww0Ovh+zzs uHuYtYF0W8DrUNDC1Pj3cYALQF0w9AGPkBuFBfBpow1WomPdiJsKmw6BUnqiIgYPMe2W r4JxsTdMAV5dbdj2VnLno8e3cMna5cgyt3XIk3V/QxUdFB8KoUa9W1KkDKzacrMCCogA kHBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/pFssxoLZmPuWgKi5vncIMSo1DCdax1EcoWBNQif+HM=; b=LaLqS9ABqkDC80eKzcyj69ohKFcVhF58E2ZzW9qTBOwUykszinhXk//+QCyFe4B8fD tuvgRtWbSdBUDskdbXMEmPFMztlQXwMfWC91pOurZyZAbVhG5l3kQ4dRK7C7Mx/AKnKf a1UxwGV4gdEhSTReHAoaru4l01TteMdGrAFY1ad+GOX6k8vpU7+0h50M5WrjPwkI+42g 8bsJt3ysnda6L+nQZsr88zA4Fe9OWVeKqofRlpD3yCRmjfrNgmWV8pPGhm4oClv9ReoL knueG6ghplpWruDP02h8YUOs64yV0AsGxXrCkxe5g7ti+tFykjluJtTrtcxswET00WVA vXeQ== X-Gm-Message-State: AOAM533FnDfx7HR5+l7UbmUnfYskWKg4qu+Zq/hL6nGktJ6KoBk3ia3i IpWWb14Ksk8dSmdK1d9pb+rNBa0ViT/plEoSg90= X-Received: by 2002:a67:2d51:0:b0:32a:c2b:78c4 with SMTP id t78-20020a672d51000000b0032a0c2b78c4mr758801vst.36.1650109788662; Sat, 16 Apr 2022 04:49:48 -0700 (PDT) MIME-Version: 1.0 References: <20220416074817.571160-1-k.kahurani@gmail.com> <65c52645-26e8-ff2b-86dc-b5dd697317f9@gmail.com> In-Reply-To: <65c52645-26e8-ff2b-86dc-b5dd697317f9@gmail.com> From: David Kahurani Date: Sat, 16 Apr 2022 14:49:37 +0300 Message-ID: Subject: Re: [PATCH] net: ax88179: add proper error handling of usb read errors To: Pavel Skripkin Cc: netdev@vger.kernel.org, syzbot , davem@davemloft.net, jgg@ziepe.ca, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Phillip Potter , syzkaller-bugs@googlegroups.com, arnd@arndb.de, Dan Carpenter Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 16, 2022 at 2:10 PM Pavel Skripkin wrote: > > Hi David, Hi Pavel. > > one more small comment > > On 4/16/22 10:48, David Kahurani wrote: > > Reads that are lesser than the requested size lead to uninit-value bugs. > > In this particular case a variable which was supposed to be initialized > > after a read is left uninitialized after a partial read. > > > > Qualify such reads as errors and handle them correctly and while at it > > convert the reader functions to return zero on success for easier error > > handling. > > > > Fixes: e2ca90c276e1 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to > > gigabit ethernet adapter driver") > > Signed-off-by: David Kahurani > > Reported-and-tested-by: syzbot+d3dbdf31fbe9d8f5f311@syzkaller.appspotmail.com > > --- > > [code snip] > > > @@ -1295,6 +1439,7 @@ static int ax88179_led_setting(struct usbnet *dev) > > static void ax88179_get_mac_addr(struct usbnet *dev) > > { > > u8 mac[ETH_ALEN]; > > + int ret; > > > > memset(mac, 0, sizeof(mac)); > > > > @@ -1303,8 +1448,12 @@ static void ax88179_get_mac_addr(struct usbnet *dev) > > netif_dbg(dev, ifup, dev->net, > > "MAC address read from device tree"); > > } else { > > - ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, > > - ETH_ALEN, mac); > > + ret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, > > + ETH_ALEN, mac); > > + > > + if (ret) > > + netdev_dbg(dev->net, "Failed to read NODE_ID: %d", ret); > > + > > netif_dbg(dev, ifup, dev->net, > > "MAC address read from ASIX chip"); > > } > > > This message sequence is confusing. > > In case of ax88179_read_cmd() failure mac read from device actually > failed, but message says, that it was successfully finished. I suppose the code should return in case of an error that way the next message does not get executed. Thanks for the review! Will fix it and the other issue in the next version. > > > > > > With regards, > Pavel Skripkin