[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aAD9GsY02U4dGBJ1@gmail.com>
Date: Thu, 17 Apr 2025 14:07:38 +0100
From: Qasim Ijaz <qasdev00@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: andrew+netdev@...n.ch, davem@...emloft.net, edumazet@...gle.com,
pabeni@...hat.com, horms@...nel.org, linux-usb@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
syzbot+3361c2d6f78a3e0892f9@...kaller.appspotmail.com,
stable@...r.kernel.org
Subject: Re: [PATCH 4/5] net: ch9200: add missing error handling in
ch9200_bind()
On Tue, Apr 15, 2025 at 08:47:08PM -0700, Jakub Kicinski wrote:
> On Sat, 12 Apr 2025 19:38:28 +0100 Qasim Ijaz wrote:
> > retval = usbnet_get_endpoints(dev, intf);
> > - if (retval)
> > + if (retval < 0)
> > return retval;
>
> This change is unnecessary ? Commit message speaks of control_write(),
> this is usbnet_get_endpoints().
So this change was done mainly for consistency with the other error checks in the function.
Essentially in my one of my previous patches (<https://lore.kernel.org/all/20250317175117.GI688833@kernel.org/>)
I was using "if (retval)" for error handling, however after Simon's recommendation to use "if (retval < 0)" I
changed this. In this particular function I took Simons advice but then noticed that the
usbnet_get_endpoints() check was still using "if (retval)" so I decided to make it the same as the others.
The behaviour is still the same regardless of it we do "if (retval < 0)" or "if (retval)" for
checking usbnet_get_endpoints() since it returns 0 on success or negative on failure.
So in ch9200_bind:
In the first case of "if (retval)", if the usbnet_get_endpoints() function fails
and returns negative then we execute this branch and it returns negative, if it
succeeds with 0 then the ch9200_bind function continues.
In the second case of "if (retval < 0)", if the usbnet_get_endpoints() function
fails and returns negative then we execute this branch and it returns negative,
if it succeeds with 0 then ch9200_bind function continues.
If you like I can include this in the patch description for clarity or remove it entirely.
Powered by blists - more mailing lists