Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1376208

Re: [PATCH] mwifiex: fix possible NULL dereference

From Christian Daudt <csd@broadcom.com>
Newsgroups linux.kernel
Subject Re: [PATCH] mwifiex: fix possible NULL dereference
Date 2016-04-11 20:40 +0200
Message-ID <rmOUG-1Pg-23@gated-at.bofh.it> (permalink)
References <rmLWO-81T-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Apr 11, 2016 at 8:27 AM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
>
> From: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
>
> We have a check for card just after dereferencing it. So if it is NULL
> we have already dereferenced it before its check. Lets dereference it
> after checking card for NULL.
>
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
> ---
>  drivers/net/wireless/marvell/mwifiex/pcie.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index edf8b07..84562d0 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -2884,10 +2884,11 @@ static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
>  {
>         struct pcie_service_card *card = adapter->card;
>         const struct mwifiex_pcie_card_reg *reg;
> -       struct pci_dev *pdev = card->dev;
> +       struct pci_dev *pdev;


you might want to move the variable declaration into the if block
below to avoid it being left undefined

>         int i;
>
>         if (card) {
> +               pdev = card->dev;


to here
  +                struct pci_dev pdev = card->dev;

>
>                 if (card->msix_enable) {
>                         for (i = 0; i < MWIFIEX_NUM_MSIX_VECTORS; i++)
>                                 synchronize_irq(card->msix_entries[i].vector);
>

cheers,
  csd

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mwifiex: fix possible NULL dereference Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-04-11 17:30 +0200
  Re: [PATCH] mwifiex: fix possible NULL dereference Christian Daudt <csd@broadcom.com> - 2016-04-11 20:40 +0200
  Re: [PATCH] mwifiex: fix possible NULL dereference Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-04-12 16:10 +0200
    Re: [PATCH] mwifiex: fix possible NULL dereference "Rustad, Mark D" <mark.d.rustad@intel.com> - 2016-04-12 19:50 +0200
      Re: [PATCH] mwifiex: fix possible NULL dereference Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-04-13 00:20 +0200

csiph-web