linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: nbd@nbd.name, linux-wireless@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [bug report] mt76: implement functions to get the response skb for MCU calls
Date: Fri, 8 Oct 2021 17:27:35 +0300	[thread overview]
Message-ID: <20211008142734.GI2083@kadam> (raw)
In-Reply-To: <9298fd82e4b49b965e9f26957510b9e968e8b691.camel@sipsolutions.net>

On Fri, Oct 08, 2021 at 04:03:10PM +0200, Johannes Berg wrote:
> On Fri, 2021-10-08 at 16:00 +0300, Dan Carpenter wrote:
> > 
> >     1146         ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_ACCESS, &req,
> >     1147                                         sizeof(req), true, &skb);
> > 
> > If mt76_mcu_send_and_get_msg() calls the dev->mcu_ops->mcu_send_msg()
> > then "skb" is not initialized.
> > 
> >     1148         if (ret)
> >     1149                 return ret;
> >     1150 
> > --> 1151         res = (struct mt7921_mcu_eeprom_info *)skb->data;
> 
> Looks like possibly 'skb' is always initialized if
> mt76_mcu_send_and_get_msg() returns 0 (success)?
> 

This build is with cross function analysis enabled so Smatch looks for
that.

The problem is that the caller has to know if dev->mcu_ops->mcu_send_msg
is NULL or not because if it's non-NULL "skb" is not set.  Perhaps that
means it should be separated into two functions and we pick which one
to call depending on whether the pointer is set.

drivers/net/wireless/mediatek/mt76/mcu.c
    54  int mt76_mcu_send_and_get_msg(struct mt76_dev *dev, int cmd, const void *data,
    55                                int len, bool wait_resp, struct sk_buff **ret_skb)
                                                                                ^^^^^^^
This is the parameter.

    56  {
    57          struct sk_buff *skb;
    58  
    59          if (dev->mcu_ops->mcu_send_msg)
    60                  return dev->mcu_ops->mcu_send_msg(dev, cmd, data, len, wait_resp);

The function pointer doesn't set *ret_skb at all.

    61  
    62          skb = mt76_mcu_msg_alloc(dev, data, len);
    63          if (!skb)
    64                  return -ENOMEM;
    65  
    66          return mt76_mcu_skb_send_and_get_msg(dev, skb, cmd, wait_resp, ret_skb);

But this does.

    67  }

regards,
dan carpenter

  reply	other threads:[~2021-10-08 14:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 13:00 [bug report] mt76: implement functions to get the response skb for MCU calls Dan Carpenter
2021-10-08 14:03 ` Johannes Berg
2021-10-08 14:27   ` Dan Carpenter [this message]
2021-10-08 14:35     ` Dan Carpenter
2022-10-13 13:04     ` Dan Carpenter
2022-10-13 16:25       ` Lorenzo Bianconi
2022-10-14  7:30         ` Dan Carpenter
2022-10-14  8:11           ` Lorenzo Bianconi

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=20211008142734.GI2083@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    /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).