public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Hariprasad Kelam <hariprasad.kelam@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tim Collier <osdevtc@gmail.com>,
	Chris Opperman <eklikeroomys@gmail.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: wlan-ng: collect return status without variable
Date: Fri, 10 May 2019 21:40:11 +0300	[thread overview]
Message-ID: <20190510184011.GE18105@kadam> (raw)
In-Reply-To: <20190510172308.GA3075@hari-Inspiron-1545>

On Fri, May 10, 2019 at 10:53:08PM +0530, Hariprasad Kelam wrote:
> On Fri, May 10, 2019 at 01:57:54PM +0300, Dan Carpenter wrote:
> > On Fri, May 10, 2019 at 08:09:00AM +0530, Hariprasad Kelam wrote:
> > > diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c
> > > index 8a862f7..5dad5ac 100644
> > > --- a/drivers/staging/wlan-ng/cfg80211.c
> > > +++ b/drivers/staging/wlan-ng/cfg80211.c
> > > @@ -231,17 +231,12 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev,
> > >  {
> > >  	struct wlandevice *wlandev = dev->ml_priv;
> > >  
> > > -	int err = 0;
> > > -	int result = 0;
> > > -
> > > -	result = prism2_domibset_uint32(wlandev,
> > > -		DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID,
> > > -		key_index);
> > > -
> > > -	if (result)
> > > -		err = -EFAULT;
> > > -
> > > -	return err;
> > > +	if (prism2_domibset_uint32(wlandev,
> > > +				   DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID,
> > > +				   key_index))
> > > +		return -EFAULT;
> > > +	else
> > > +		return 0;
> > 
> > We should just preserve the error codes from prism2_domibset_uint32().
> > 
> > 	return prism2_domibset_uint32(dev->ml_priv,
> > 				DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID,
> > 				key_index);
> >
>    prism2_domibset_uint32 function can return  -ENODEV,-EPERM,-EBUSY if
>    fail  case.
> 
>    If we observe the pattern of calling this function,we can find
>    
>    "return -EFAULT on failure and 0 on success".
> 
>    Due to this we  can not collect return status directly.

Yes, I know this code is full of nonsense.

It shouldn't just always return -EFAULT, it should preserve the correct
error code.  This is only called from rdev_set_default_key() if you want
to check the caller.

regards,
dan carpenter


  reply	other threads:[~2019-05-10 18:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10  2:39 [PATCH] staging: wlan-ng: collect return status without variable Hariprasad Kelam
2019-05-10 10:57 ` Dan Carpenter
2019-05-10 17:23   ` Hariprasad Kelam
2019-05-10 18:40     ` Dan Carpenter [this message]
2019-05-11  7:58       ` Hariprasad Kelam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190510184011.GE18105@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=eklikeroomys@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hariprasad.kelam@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=osdevtc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox