Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1213114pxb; Thu, 14 Apr 2022 00:32:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdst7ca62vyM7DxIfJFxTeDsZoj/bvQlP9RjRtaApShb1jD30InqtEGqt4BBWBQz6kuiv/ X-Received: by 2002:a17:907:9604:b0:6ec:9b5:c55b with SMTP id gb4-20020a170907960400b006ec09b5c55bmr750286ejc.321.1649921560535; Thu, 14 Apr 2022 00:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649921560; cv=none; d=google.com; s=arc-20160816; b=pEtlYZwGO6p4CADUfalINfXJMWa2XUyWm7htVnKGO9j3gkD1NTn7El/QD8CaPb9GTW +n3/Yt7ZrS7N73mOHhMBO0IAofoI0bMXbyHZgcO6sYPSwJ2PMGf3iqcgvz22vN5RbjAT /MzQx4wokXeUmWaE/MDsGYMaoiLbkOR6Ey99j3dZfOLqOpeugtjCkAtQMs514sUIIq/Y 1DASlK99136tBQj0P1Rwx/RtGI4G3PNYaXHD7amCECQaVcuvdbaYnxvZ7EVWsi6NXDP0 sHGCUrYSWpiSL8UYxMGEtsAxOsgz/rLU5Kr4SvixZXccDjhKysqdNhOffA6VQxwvI1Eq HlmQ== 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=l91PaoNzkraHqeajdUVuvzQMezggMyac9Bnl2PBAwYE=; b=pEsi0OGbvcV98YyezAr4j3kcZnIFP7BjdEqDUUuOT7q6hoQhZbXCvtqzNij6U5R84P IITPgfIBMgI2uimSlPto9xYYqh4Y5av/uAl/L0od9GxWQ1yHv4MiVPGxp/uODAUlgiDz 6+oMwvzJ+7BJgdxoX8xSwQZydfVuJk89FW6u4kKQE3pA38+UCT3uHVO/bgbgpqtPond5 SyPQbR/m1Cjjwl0HuOaadYgGvwQw2i41MGUzO5UY9j0bODS4a5g3vCIL2A1uNVcVdo/p BkySv0oiGXpPj0+nNh31mfSnRD1rKtRsoDd0iYywFpRPACR7xuuT7HAWndbnxXjpLoU8 lqVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="GY+Nx/NL"; 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 q17-20020a1709064cd100b006e449a9eb9csi1508810ejt.829.2022.04.14.00.32.14; Thu, 14 Apr 2022 00:32:40 -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="GY+Nx/NL"; 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 S235434AbiDMMjd (ORCPT + 99 others); Wed, 13 Apr 2022 08:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232694AbiDMMjb (ORCPT ); Wed, 13 Apr 2022 08:39:31 -0400 Received: from mail-vk1-xa36.google.com (mail-vk1-xa36.google.com [IPv6:2607:f8b0:4864:20::a36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C14E434B7; Wed, 13 Apr 2022 05:37:09 -0700 (PDT) Received: by mail-vk1-xa36.google.com with SMTP id o14so769167vkf.13; Wed, 13 Apr 2022 05:37:09 -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=l91PaoNzkraHqeajdUVuvzQMezggMyac9Bnl2PBAwYE=; b=GY+Nx/NLjsUDY2KpKhXCF0f+wm3O1zKwOqSZqRMwSH/56LljWI42nzXFPSbOLyCzgT 38WLFUE7x1wXVcgpN+m50/DObAWM4TnxUxxRmFhI/C9OoGZK4NuzYTGMq2Rm5gfC2W59 5NLo7/rvy6vTcgAgP/s6fT6oILUlEPqJR7TkH7m5VJYlOAMtELQhO2QUn7l50LFhFp3p v6oSBLHRPNRnN3wVuNHT3YkYnjj2RPzO9KpRP3DWjy1xFP4HW+Br7ccBiLlarZcjMUVS U6i/JaRu2U861B3HZ466iOe9s1qpyrndnCtwiKI+X1ic2HRWNvuQH1WT8I3bhjPSOUIu CFHA== 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=l91PaoNzkraHqeajdUVuvzQMezggMyac9Bnl2PBAwYE=; b=K/9w5RqodWriEVvuKJ+pEH4qI4xncynenFD3UvhoB/swI2yswB1sTEYy3YcZDN7oQp dYp6UQhjUPh4RABVdSpizJpPeFnPtWiqMSgu2A6bHmtbsKKj4M3wIkjrAlUgo/u+HFRz 67kkLnEGxV3x30urhkrXa8/fzukfWgN/czoQT0+Z8TklKwJj3E1ud2+4BOqHRuGQKW2V 0r5PSrZoFLN5956z6+DGKX2iIfQoITySOijvaEyOMaA4ovF8Xub5rJgxtULBvXpv8sMF RLmKzmHHQSxZc8kRcY6KWLTOGMyyB22VLlG2ePJ62EpZe/9ZBHi4+JZrIpDZgDcrOh8t kz8A== X-Gm-Message-State: AOAM5320VnjBgaWSL1kURKVF/+yVcKOIpCpDMjVMdMz80TE6cqcN+OgO YJGu5KcMZDv24xi8o/Mt1ep0tyZVrO0X7KZK1lg= X-Received: by 2002:a1f:ac95:0:b0:345:2ade:e54b with SMTP id v143-20020a1fac95000000b003452adee54bmr8524580vke.3.1649853428705; Wed, 13 Apr 2022 05:37:08 -0700 (PDT) MIME-Version: 1.0 References: <20220404151036.265901-1-k.kahurani@gmail.com> <20220404153151.GF3293@kadam> In-Reply-To: <20220404153151.GF3293@kadam> From: David Kahurani Date: Wed, 13 Apr 2022 15:36:57 +0300 Message-ID: Subject: Re: [PATCH] net: ax88179: add proper error handling of usb read errors To: Dan Carpenter 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, Pavel Skripkin 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 Mon, Apr 4, 2022 at 6:32 PM Dan Carpenter wrote: Hi Dan > > int ret; > > int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); > > @@ -201,9 +202,12 @@ static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, > > ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > > value, index, data, size); > > > > - if (unlikely(ret < 0)) > > + if (unlikely(ret < size)) { > > + ret = ret < 0 ? ret : -ENODATA; > > + > > netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", > > index, ret); > > + } > > > > return ret; > > It would be better to make __ax88179_read_cmd() return 0 on success > instead of returning size on success. Non-standard returns lead to bugs. > I don't suppose this would have much effect on the structure of the code and indeed plan to do this but just some minor clarification. Isn't it standard for reader functions to return the number of bytes read? Regards, David. > > > @@ -1060,16 +1151,30 @@ static int ax88179_check_eeprom(struct usbnet *dev) > > > > jtimeout = jiffies + delay; > > do { > > - ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, > > - 1, 1, &buf); > > + ret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, > > + 1, 1, &buf); > > + > > + if (ret < 0) { > > + netdev_dbg(dev->net, > > + "Failed to read SROM_CMD: %d\n", > > + ret); > > + return ret; > > + } > > > > if (time_after(jiffies, jtimeout)) > > return -EINVAL; > > The indenting here is wrong. Run scripts/checkpatch.pl on your patches. > > regards, > dan carpenter >