Powered by Linux
Re: smatch "unreachable code" — Semantic Matching Tool

Re: smatch "unreachable code"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 19, 2013 at 09:15:23AM +0100, Johannes Berg wrote:
> > Also even for the --spammy output, I changed the code so it doesn't
> > warn about unreachable break statements and empty statements like
> > "return ;;".
> 
> Heh, ok. FWIW, the latter does trigger coverity and klocwork, I believe
> (we use the latter internally).
> 

Coccinelle can find those and generate patches as well so it's pointless
to try compete.  :P

> Btw, completely unrelated to this - we have some code in
> drivers/net/wireless/mvm/nvm.c like this:
> 
>                 temp = kmemdup(file_sec->data, section_size,
> GFP_KERNEL);
>                 if (!temp) {
>                         ret = -ENOMEM;
>                         break;
>                 }
>                 if (WARN_ON(section_id >= NVM_NUM_OF_SECTIONS)) {
>                         IWL_ERR(mvm, "Invalid NVM section ID\n");
>                         ret = -EINVAL;
>                         break;
>                 }
>                 mvm->nvm_sections[section_id].data = temp;
> 
> (break because it's in a loop over multiple sections).
> 
> It looks like smatch is missing the memory leak here, but I don't know
> how well the memory leak detection code really works anyway.

The leak detection code is only looking at kmalloc() and kzalloc()...

The whole thing probably needs to be re-written.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe smatch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux