Return-Path: MIME-Version: 1.0 In-Reply-To: <20111010073511.GI4094@fusion.localdomain> References: <1317303988-26310-1-git-send-email-sancane@gmail.com> <1317303988-26310-2-git-send-email-sancane@gmail.com> <1317303988-26310-3-git-send-email-sancane@gmail.com> <1317303988-26310-4-git-send-email-sancane@gmail.com> <1317303988-26310-5-git-send-email-sancane@gmail.com> <1317303988-26310-6-git-send-email-sancane@gmail.com> <1317303988-26310-7-git-send-email-sancane@gmail.com> <1317303988-26310-8-git-send-email-sancane@gmail.com> <1317303988-26310-9-git-send-email-sancane@gmail.com> <20111010073511.GI4094@fusion.localdomain> Date: Mon, 10 Oct 2011 10:04:36 +0200 Message-ID: Subject: Re: [PATCH 8/9] Read measurement interval characteristic From: Santiago Carot To: Santiago Carot-Nemesio , linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Johan! Thanks your comments. 2011/10/10 Johan Hedberg : > Hi Santiago, > > On Thu, Sep 29, 2011, Santiago Carot-Nemesio wrote: >> @@ -148,7 +192,31 @@ static void read_temp_type_cb(guint8 status, const guint8 *pdu, guint16 len, >> ?static void read_interval_cb(guint8 status, const guint8 *pdu, guint16 len, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpointer user_data) >> ?{ >> - ? ? /* TODO */ >> + ? ? struct characteristic *ch = user_data; >> + ? ? uint8_t value[ATT_MAX_MTU]; >> + ? ? uint16_t *p, interval; >> + ? ? int vlen; >> + >> + ? ? if (status != 0) { >> + ? ? ? ? ? ? DBG("Measurement Interval value read failed: %s", >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? att_ecode2str(status)); >> + ? ? ? ? ? ? return; >> + ? ? } >> + >> + ? ? if (!dec_read_resp(pdu, len, value, &vlen)) { >> + ? ? ? ? ? ? DBG("Protocol error\n"); >> + ? ? ? ? ? ? return; >> + ? ? } >> + >> + ? ? if (vlen < 2) { >> + ? ? ? ? ? ? DBG("Invalid Interval received"); >> + ? ? ? ? ? ? return; >> + ? ? } >> + >> + ? ? p = (uint16_t *) value; >> + ? ? interval = btohs(*p); > > This looks like a potential unaligned access issue. Probably safer to > use bt_get_unaligned here. I'm going to review this and all previous issues you have mentioned regarding to previous patches, when I get ready I'll send you a new set fixing them. Once more, thank you all for your patient. Regards. Santiago