From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: linux-can@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH 5/7] can: dev: add berr_limit infrastrucutre
Date: Tue, 08 Oct 2013 09:05:12 +0200 [thread overview]
Message-ID: <5253AEA8.1080100@pengutronix.de> (raw)
In-Reply-To: <3564375.WErYyL6CN1@ws-stein>
[-- Attachment #1: Type: text/plain, Size: 1991 bytes --]
On 10/08/2013 08:03 AM, Alexander Stein wrote:
> On Monday 07 October 2013 18:00:45, Marc Kleine-Budde wrote:
>>>>> +void can_berr_limit(struct net_device *dev)
>>>>> +{
>>>>> + struct can_priv *priv = netdev_priv(dev);
>>>>> +
>>>>> + if (priv->berr_limit_delay) {
>>>>> + netdev_dbg(dev, "berr-limit\n");
>>>>> + mod_timer(&priv->berr_limit_timer,
>>>>> + jiffies + priv->berr_limit_delay);
>>>>> + } else {
>>>>> + priv->do_berr_restart(dev);
>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>
>>>> Here you are silently requiring that do_berr_restart is non-NULL. I
>>>> know that the driver has to properly set this when using
>>>> can_berr_limit, but it might seem confusing.
>>>
>>> If the driver wants to make use of this feature, it has to setup this
>>> callback. If I add NULL pointer checks, the kernel wouldn't blow up, but
>>> the driver doesn't work any more.
>>
>> I mean, if the driver doesn't setup the callback and there is a NULL
>> pointer checks in both functions, the driver doesn't work properly,
>> because the bus error interrupts will stay disabled and you might not
>> notice it, because there isn't any big sign of failure (like the NULL
>> pointer deref).
>
> Mh, what would be the effect if a driver doesn't setup the callback
> and still uses can_berr_limit? The NULL dereference raises and OOPS
> and what then? The corresponding application gets killed? Well if the
> system as a whole still works and even better then faulty driver can
> be unloaded again, this might be suitable.
It makes no sense to use can_berr_limit() without implementing the
callback. So it makes no sense from my point of view to add a NULL
pointer check.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2013-10-08 7:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-07 14:40 [PATCH 1/7] can: berr_limit support Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 1/7] can: dev: fix nlmsg size calculation in can_get_size() Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 2/7] can: dev: sort can_get_size() by IFLA_CAN_* Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 3/7] can: dev: sort can_fill_info() " Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 4/7] can: dev: sort can_changelink() " Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 5/7] can: dev: add berr_limit infrastrucutre Marc Kleine-Budde
2013-10-07 15:39 ` Alexander Stein
2013-10-07 15:56 ` Marc Kleine-Budde
2013-10-07 16:00 ` Marc Kleine-Budde
2013-10-08 6:03 ` Alexander Stein
2013-10-08 7:05 ` Marc Kleine-Budde [this message]
2013-10-07 14:40 ` [PATCH 6/7] can: dev: berr_limit netlink support for configuration Marc Kleine-Budde
2013-10-07 14:40 ` [PATCH 7/7] can: flexcan: add berr_limit support Marc Kleine-Budde
2013-10-07 19:38 ` [PATCH 1/7] can: " Wolfgang Grandegger
2013-10-07 19:42 ` Marc Kleine-Budde
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=5253AEA8.1080100@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=alexander.stein@systec-electronic.com \
--cc=kernel@pengutronix.de \
--cc=linux-can@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 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).