linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Vihas Mak <makvihas@gmail.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Straube <straube.linux@gmail.com>,
	Martin Kaiser <martin@kaiser.cx>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately
Date: Mon, 24 Jan 2022 09:49:18 +0300	[thread overview]
Message-ID: <20220124064918.GR1951@kadam> (raw)
In-Reply-To: <20220123181734.10402-1-makvihas@gmail.com>

On Sun, Jan 23, 2022 at 11:47:35PM +0530, Vihas Mak wrote:
> rtw_init_netdev_name() calls dev_alloc_name() which allocates the name
> for the device as per the given name format.
> The name format is specified by the module parameter "ifname".
> It returns a negative err code if the format is invalid. Handle this
> error appropriately.
> Cancel the timers ininitliazed by rtw_init_drv_sw() before calling
> rtw_free_drv_sw() and then proceed to free the adapter.
> 
> Also, if register_netdev() fails then goto free_drv_sw instead of
> goto handle_dualmac.
> 
> Signed-off-by: Vihas Mak <makvihas@gmail.com>
> ---
> v1->v2:
>     free the adapter and netdev instead of warning the user about 
>     allocation failure.

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

Of course, all this code is staging code and terrible.  This function
is needlessly difficult to read/review.

TODO: re-write probe error handling

Step 1: Keep the success path and error path separate.

-	status = _SUCCESS;
+	return padapter;

Step 2: Eliminate do-nothing-gotos.  s/goto exit/return NULL/

Step 3: Delete the vfree(pnpi->priv); from rtw_free_netdev() and call
        vfree(pnpi->priv); from probe and rtw_usb_if1_deinit() instead.
        Avoid a layering violation.

Step 4: Every allocation function needs a matching free function.  Move
        the rtw_cancel_all_timer() into the rtw_free_drv_sw() function.
        Open coding it is a layering violation.

Step 5: Get rid of the rtw_handle_dualmac() function.  It has a bad
        name and a global variable.  What is the point of this function?

But that stuff is for later patches.

regards,
dan carpenter


  reply	other threads:[~2022-01-24  6:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23 18:17 [PATCH v2] staging: r8188eu: handle rtw_init_netdev_name() failure appropriately Vihas Mak
2022-01-24  6:49 ` Dan Carpenter [this message]
2022-01-24  9:16   ` Vihas Mak

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=20220124064918.GR1951@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=makvihas@gmail.com \
    --cc=martin@kaiser.cx \
    --cc=phil@philpotter.co.uk \
    --cc=straube.linux@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;
as well as URLs for NNTP newsgroup(s).