From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753989AbbIETzs (ORCPT ); Sat, 5 Sep 2015 15:55:48 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:46798 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752763AbbIETzj (ORCPT ); Sat, 5 Sep 2015 15:55:39 -0400 Date: Sat, 5 Sep 2015 21:47:55 +0200 From: Andrew Lunn To: Michael Welling Cc: Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: phy: Handle postive return codes in phy_connect Message-ID: <20150905194755.GD6040@lunn.ch> References: <1441476089-22108-1-git-send-email-mwelling@ieee.org> <20150905191840.GC6040@lunn.ch> <20150905194400.GA1687@deathstar> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150905194400.GA1687@deathstar> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 05, 2015 at 02:44:01PM -0500, Michael Welling wrote: > On Sat, Sep 05, 2015 at 09:18:40PM +0200, Andrew Lunn wrote: > > On Sat, Sep 05, 2015 at 01:01:29PM -0500, Michael Welling wrote: > > > The function phy_connect_direct can possibly return a positive > > > return code. Using ERR_PTR with a positive value can lead to > > > deferencing of an invalid pointer. > > > > Is this the correct fix? Would it not be better to find where the > > positive return code is from and fix that? > > I guess I can trace it back to find out where the positive return code > is originating. > > Is phy_connect_direct always supposed to return valid -errno? I would look at this from a different angle. A positive ERRNO is probably a bug of some sort. So rather than papering over the cracks, go find what the real issue is. It might not be an ERRNO. E.g. https://lkml.org/lkml/2015/9/3/534 fixed a bug where a positive value is returned which is not an indication of an error. Andrew