From: "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>
To: "knaack.h@gmx.de" <knaack.h@gmx.de>
Cc: "Baluta, Daniel" <daniel.baluta@intel.com>,
"lars@metafoo.de" <lars@metafoo.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jic23@kernel.org" <jic23@kernel.org>,
"Purdila, Octavian" <octavian.purdila@intel.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"Westerberg, Mika" <mika.westerberg@intel.com>,
"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
"beomho.seo@samsung.com" <beomho.seo@samsung.com>,
"gwendal@chromium.org" <gwendal@chromium.org>
Subject: Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
Date: Sat, 24 Jan 2015 00:17:12 +0000 [thread overview]
Message-ID: <1422058633.15254.2.camel@spandruv-hsb-test> (raw)
In-Reply-To: <54C2DB5F.2050106@gmx.de>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3734 bytes --]
On Sat, 2015-01-24 at 00:38 +0100, Hartmut Knaack wrote:
> Pandruvada, Srinivas schrieb am 19.01.2015 um 17:56:
> > On Mon, 2015-01-19 at 18:49 +0200, Daniel Baluta wrote:
> >> On Mon, Jan 19, 2015 at 6:44 PM, Pandruvada, Srinivas
> >> <srinivas.pandruvada@intel.com> wrote:
> >>> On Mon, 2015-01-19 at 16:40 +0200, Daniel Baluta wrote:
> >>>> Hello,
> >>>>
> >>>> On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
> >>>> <srinivas.pandruvada@intel.com> wrote:
> >>>>> +Mika
> >>>>>
> >>>>> On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
> >>>>>> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
> >>>>>>> On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> >>>>>>>> Daniel Baluta schrieb am 18.12.2014 um 18:16:
> >>>>>>>>> When using ACPI, if acpi_match_device fails then chipset enum will be
> >>>>>>>>> uninitialized and &ak_def_array[chipset] will point to some bad address.
> >>>>>>>>>
> >>>>>> I am missing something. You are enumerated over i2c device, which was
> >>>>>> created from ACPI PNP resource. There is a valid handle or and the
> >>>>>> device has an ACPI companion at the least. If this failing, I have to
> >>>>>> check the code for acpi i2c.
> >>>>>> Can you check why this check failed? We may have bug in i2c handling.
> >>>>
> >>>> You are right about this. Under normal circumstances, if probe is called
> >>>> then acpi_match_device will not fail. I even tried to remove the
> >>>> device after probe
> >>>> but before acpi_match_device, anyhow acpi_match_device was still successful :)
> >>>>
> >>>> This is more a matter of code correctness.
> >>>>
> >>>> In ak8975_match_acpi_device we have:
> >>>>
> >>>> » const struct acpi_device_id *id;
> >>>>
> >>>> » id = acpi_match_device(dev->driver->acpi_match_table, dev);
> >>>> » if (!id)
> >>>> » » return NULL;
> >>>> » *chipset = (int)id->driver_data;
> >>>>
> >>>> Compiler complains on the fact that chipset might be uninitialized
> >>>> if this returns NULL, and we shouldn't ignore this warning even this case
> >>>> will never happen.
> >>>>
> >>> Will this fix?
> >>> data->chipset = AK8975;
> >>> before
> >>> ak8975_match_acpi_device(&client->dev, &data->chipset);
> >>>
>
> This would fix the compiler warning, but doesn't seem the right solution for
> this issue. Quoting the description of acpi_match_device:
> "Return a pointer to the first matching ID on success or %NULL on failure."
> So, even if it is very unlikely to for it to fail - if it does fail, the
> error should be handled as quick as possible. I would favor Daniels solution
> to check for a valid assignment of name.
>
This should never fail as the device is enumerated by this. So it
doesn't matter as long as you silent compiler warning.
> >>
> >> Yes, this is done in the original patch:
> >>
> >> + *chipset = AK_MAX_TYPE;
> > Since data memory is not zero alloced, other member of data are anyway
> > initialized, so adding this also may be better.
>
> If there did not occur an error condition, it will be assigned a value
> before being checked for valid ranges. And if there is an error, probe
> should be aborted, anyway. So initializing *chipset doesn't seem to add
> any benefit IMHO.
>
> >>
> >> .. and fixes the warning.
> >>
> >> Daniel.
> >
> > N�����r��y���b�X��ǧv�^�)Þº{.n�+����{��*"��^n�r���z�\x1a��h����&��\x1e�G���h�\x03(�é�ݢj"��\x1a�^[m�����z�Þ���f���h���~�mml==
> >
>
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
prev parent reply other threads:[~2015-01-24 0:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-18 17:16 Daniel Baluta
2014-12-19 22:16 ` Hartmut Knaack
2014-12-19 22:25 ` Daniel Baluta
2014-12-20 21:26 ` Srinivas Pandruvada
2014-12-20 21:29 ` Pandruvada, Srinivas
2014-12-20 21:40 ` Daniel Baluta
2015-01-19 14:40 ` Daniel Baluta
2015-01-19 16:44 ` Pandruvada, Srinivas
2015-01-19 16:49 ` Daniel Baluta
2015-01-19 16:56 ` Pandruvada, Srinivas
2015-01-23 23:38 ` Hartmut Knaack
2015-01-24 0:17 ` Pandruvada, Srinivas [this message]
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=1422058633.15254.2.camel@spandruv-hsb-test \
--to=srinivas.pandruvada@intel.com \
--cc=beomho.seo@samsung.com \
--cc=daniel.baluta@intel.com \
--cc=gwendal@chromium.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@intel.com \
--cc=octavian.purdila@intel.com \
--cc=pmeerw@pmeerw.net \
/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
all inboxes | Powered by JetHome®