All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Arend van Spriel <arend@broadcom.com>
Cc: linux-wireless@vger.kernel.org
Subject: re: brcmsmac: use container_of instead of cast
Date: Thu, 12 Jul 2012 14:20:07 +0300	[thread overview]
Message-ID: <20120712112007.GA12822@elgon.mountain> (raw)

The patch ed1dd81464f5: "brcmsmac: use container_of instead of cast" 
from Jun 30, 2012, leads to the following Smatch warning:
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c:543 ai_detach()
	 warn: can 'sii' even be NULL?

   533  /* may be called with core in reset */
   534  void ai_detach(struct si_pub *sih)
   535  {
   536          struct si_info *sii;
   537  
   538          struct si_pub *si_local = NULL;
   539          memcpy(&si_local, &sih, sizeof(struct si_pub **));
   540  
   541          sii = container_of(sih, struct si_info, pub);
   542  
   543          if (sii == NULL)
   544                  return;
   545  
   546          kfree(sii);
   547  }


Smatch complains because container_of() of does pointer math and the
check for NULL only works when ->pub is first member of the si_info
struct.

Are you sure you want to free sii and not sih?

Also kfree() checks for NULL.

The memcpy() is pointless.

The white space is not right.  There should be a blank line after the
variable declarations.

regards,
dan carpenter

             reply	other threads:[~2012-07-12 11:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-12 11:20 Dan Carpenter [this message]
2012-07-12 11:47 ` brcmsmac: use container_of instead of cast Hauke Mehrtens

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=20120712112007.GA12822@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=arend@broadcom.com \
    --cc=linux-wireless@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.