Skip to contentSkip to conversation

ath: Add support for tracing

DISCUSSION Dan Carpenter 2 participants 3 messages Oct 3, 2014 – Oct 6, 2014

lore
Share & tools
lore
#0 lore raw

Hello Sujith Manoharan,

This is a semi-automatic email about new static checker warnings.

The patch e6664dff0608: "ath: Add support for tracing" from Sep 27, 2014, leads to the following Smatch complaint:

drivers/net/wireless/ath/main.c:88 ath_printk()

	 error: we previously assumed 'common->hw' could be null (see line 82)

drivers/net/wireless/ath/main.c

    81	
    82		if (common && common->hw && common->hw->wiphy)
                              ^^^^^^^^^^

Existing code assumes common->hw can be NULL.

    83			printk("%sath: %s: %pV",
    84			       level, wiphy_name(common->hw->wiphy), &vaf);
    85		else
    86			printk("%sath: %pV", level, &vaf);
    87	
    88		trace_ath_log(common->hw->wiphy, &vaf);
                              ^^^^^^^^^^^^^^^^^

New code dereferences it without checking for NULL.

    89	
    90		va_end(args);

regards,
dan carpenter

#1 lore raw
Quoted 7 lines · Dan Carpenter

Hello Sujith Manoharan,

This is a semi-automatic email about new static checker warnings.

The patch e6664dff0608: "ath: Add support for tracing" from Sep 27, 2014, leads to the following Smatch complaint:

Quoted 6 lines

drivers/net/wireless/ath/main.c:88 ath_printk()

	 error: we previously assumed 'common->hw' could be null (see line 82)

drivers/net/wireless/ath/main.c

    81	
    82		if (common && common->hw && common->hw->wiphy)

Oh. And also common is assumed to be possibly NULL as well.

regards,
dan carpenter

Quoted 17 lines
                              ^^^^^^^^^^

Existing code assumes common->hw can be NULL.

    83			printk("%sath: %s: %pV",
    84			       level, wiphy_name(common->hw->wiphy), &vaf);
    85		else
    86			printk("%sath: %pV", level, &vaf);
    87	
    88		trace_ath_log(common->hw->wiphy, &vaf);
                              ^^^^^^^^^^^^^^^^^

New code dereferences it without checking for NULL.

    89	
    90		va_end(args);

regards,
dan carpenter

#2 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

Hello Sujith Manoharan,

This is a semi-automatic email about new static checker warnings.

The patch e6664dff0608: "ath: Add support for tracing" from Sep 27, 2014, leads to the following Smatch complaint:

drivers/net/wireless/ath/main.c:88 ath_printk()

	 error: we previously assumed 'common->hw' could be null (see line 82)

Thanks.

ath_printk() would be called only if ath_hw/ath_common are setup, so the chances of common being NULL is pretty low.

But, since we are interested in trace information with a functional driver, trace_ath_log() can be moved inside the check. I'll send a patch.

Sujith