Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759199Ab3CZCHd (ORCPT ); Mon, 25 Mar 2013 22:07:33 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:35192 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755408Ab3CZCHc convert rfc822-to-8bit (ORCPT ); Mon, 25 Mar 2013 22:07:32 -0400 From: "Anna, Suman" To: Wei Yongjun , "linus.walleij@linaro.org" , "loic.pallardy@st.com" , "omar.ramirez@copitl.com" , "lugo.fernando@gmail.com" CC: "yongjun_wei@trendmicro.com.cn" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH -next v2] mailbox: fix invalid use of sizeof in mailbox_msg_send() Thread-Topic: [PATCH -next v2] mailbox: fix invalid use of sizeof in mailbox_msg_send() Thread-Index: AQHOJ5SkUGt9dLoyzkOPylEV/wyWEJi3Ncgg Date: Tue, 26 Mar 2013 02:07:19 +0000 Message-ID: <37C860A02101E749A747FA2D3C1E3C5049F2BE@DLEE11.ent.ti.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [157.170.170.90] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1541 Lines: 49 > From: Wei Yongjun > > sizeof() when applied to a pointer typed expression gives the size of the pointer, > not that of the pointed data. > > Signed-off-by: Wei Yongjun > --- > drivers/mailbox/mailbox.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index > 5fea5c2..78e52c0 100644 > --- a/drivers/mailbox/mailbox.c > +++ b/drivers/mailbox/mailbox.c > @@ -83,7 +83,7 @@ int mailbox_msg_send(struct mailbox *mbox, struct > mailbox_msg *msg) > > mutex_lock(&mq->mlock); > > - if (kfifo_avail(&mq->fifo) < (sizeof(msg) + msg->size)) { > + if (kfifo_avail(&mq->fifo) < (sizeof(*msg) + msg->size)) { > ret = -ENOMEM; > goto out; > } > @@ -93,8 +93,8 @@ int mailbox_msg_send(struct mailbox *mbox, struct > mailbox_msg *msg) > goto out; > } > > - len = kfifo_in(&mq->fifo, (unsigned char *)msg, sizeof(msg)); > - WARN_ON(len != sizeof(msg)); > + len = kfifo_in(&mq->fifo, (unsigned char *)msg, sizeof(*msg)); > + WARN_ON(len != sizeof(*msg)); > > if (msg->size && msg->pdata) { > len = kfifo_in(&mq->fifo, (unsigned char *)msg->pdata, > Looks good, thanks. I have added this patch to my branch on github. Regards Suman -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/