From: Petko Manolov <petko.manolov@konsulko.com>
To: Pavel Skripkin <paskripkin@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
gregkh@linuxfoundation.org, Petko Manolov <petkan@nucleusys.com>
Subject: Re: [PATCH net v2 1/2] Check the return value of get_geristers() and friends;
Date: Tue, 3 Aug 2021 20:26:22 +0300 [thread overview]
Message-ID: <YQl8Pr42Oj4PafFP@carbon> (raw)
In-Reply-To: <69cedfb2-fc76-0afb-3a48-f24f238d5330@gmail.com>
On 21-08-03 19:45:56, Pavel Skripkin wrote:
> On 8/3/21 7:18 PM, Petko Manolov wrote:
> > From: Petko Manolov <petkan@nucleusys.com>
> >
> > Certain call sites of get_geristers() did not do proper error handling. This
> > could be a problem as get_geristers() typically return the data via pointer to a
> > buffer. If an error occured the code is carelessly manipulating the wrong data.
> >
> > Signed-off-by: Petko Manolov <petkan@nucleusys.com>
> > ---
> > drivers/net/usb/pegasus.c | 104 ++++++++++++++++++++++++++------------
> > 1 file changed, 72 insertions(+), 32 deletions(-)
> >
> > diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
> > index 9a907182569c..06e3ae6209b0 100644
> > --- a/drivers/net/usb/pegasus.c
> > +++ b/drivers/net/usb/pegasus.c
> > @@ -132,9 +132,15 @@ static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
> > static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
> > const void *data)
> > {
> > - return usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REGS,
> > + int ret;
> > +
> > + ret = usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REGS,
> > PEGASUS_REQT_WRITE, 0, indx, data, size,
> > 1000, GFP_NOIO);
> > + if (ret < 0)
> > + netif_dbg(pegasus, drv, pegasus->net, "%s failed with %d\n", __func__, ret);
> > +
> > + return ret;
> > }
> > /*
> > @@ -145,10 +151,15 @@ static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
> > static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
> > {
> > void *buf = &data;
> > + int ret;
> > - return usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REG,
> > + ret = usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REG,
> > PEGASUS_REQT_WRITE, data, indx, buf, 1,
> > 1000, GFP_NOIO);
> > + if (ret < 0)
> > + netif_dbg(pegasus, drv, pegasus->net, "%s failed with %d\n", __func__, ret);
> > +
> > + return ret;
> > }
> > static int update_eth_regs_async(pegasus_t *pegasus)
> > @@ -188,10 +199,9 @@ static int update_eth_regs_async(pegasus_t *pegasus)
> > static int __mii_op(pegasus_t *p, __u8 phy, __u8 indx, __u16 *regd, __u8 cmd)
> > {
> > - int i;
> > - __u8 data[4] = { phy, 0, 0, indx };
> > + int i, ret = -ETIMEDOUT;
> > __le16 regdi;
> > - int ret = -ETIMEDOUT;
> > + __u8 data[4] = { phy, 0, 0, indx };
> > if (cmd & PHY_WRITE) {
> > __le16 *t = (__le16 *) & data[1];
> > @@ -211,8 +221,9 @@ static int __mii_op(pegasus_t *p, __u8 phy, __u8 indx, __u16 *regd, __u8 cmd)
> > goto fail;
> ^^^^^^^^^
>
> I really don't want You to spin this series one more time, but ret
> initialization is missed here again :) Maybe, it's not really important
> here...
I'll respin this as many times as needed. :)
> And Fixes or CC stable is missed too
Done.
cheers,
Petko
next prev parent reply other threads:[~2021-08-03 17:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 16:18 [PATCH net v2 0/2] net: usb: pegasus: better error checking and DRIVER_VERSION removal Petko Manolov
2021-08-03 16:18 ` [PATCH net v2 1/2] Check the return value of get_geristers() and friends; Petko Manolov
2021-08-03 16:45 ` Pavel Skripkin
2021-08-03 17:26 ` Petko Manolov [this message]
2021-08-03 16:18 ` [PATCH net v2 2/2] Remove the changelog and DRIVER_VERSION Petko Manolov
2021-08-03 16:53 ` Greg KH
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=YQl8Pr42Oj4PafFP@carbon \
--to=petko.manolov@konsulko.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=netdev@vger.kernel.org \
--cc=paskripkin@gmail.com \
--cc=petkan@nucleusys.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;
as well as URLs for NNTP newsgroup(s).