All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: mediatek: fix uninitialized symbol errors in btmtksdio_rx_packet
@ 2019-03-13 20:43 ` sean.wang
  0 siblings, 0 replies; 5+ messages in thread
From: sean.wang @ 2019-03-13 20:43 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: linux-bluetooth, linux-mediatek, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

Fixed all the below warnings. They would probably cause the following
error handling path would use the uninitialized value and then produce
unexpected behavior.

drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here
  unsigned int old_len;
               ^~~~~~~
drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here
  unsigned char *old_data;
                 ^~~~~~~~

Fixes: d74eef2834b5 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/bluetooth/btmtksdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index b4b8320f279e..23cf63888bac 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -372,8 +372,8 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size)
 	const struct h4_recv_pkt *pkts = mtk_recv_pkts;
 	int pkts_count = ARRAY_SIZE(mtk_recv_pkts);
 	struct mtkbtsdio_hdr *sdio_hdr;
-	unsigned char *old_data;
-	unsigned int old_len;
+	unsigned char *old_data = NULL;
+	unsigned int old_len = 0;
 	int err, i, pad_size;
 	struct sk_buff *skb;
 	u16 dlen;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] Bluetooth: mediatek: fix uninitialized symbol errors in btmtksdio_rx_packet
@ 2019-03-13 20:43 ` sean.wang
  0 siblings, 0 replies; 5+ messages in thread
From: sean.wang @ 2019-03-13 20:43 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: linux-bluetooth, linux-mediatek, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

Fixed all the below warnings. They would probably cause the following
error handling path would use the uninitialized value and then produce
unexpected behavior.

drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here
  unsigned int old_len;
               ^~~~~~~
drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here
  unsigned char *old_data;
                 ^~~~~~~~

Fixes: d74eef2834b5 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/bluetooth/btmtksdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index b4b8320f279e..23cf63888bac 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -372,8 +372,8 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size)
 	const struct h4_recv_pkt *pkts = mtk_recv_pkts;
 	int pkts_count = ARRAY_SIZE(mtk_recv_pkts);
 	struct mtkbtsdio_hdr *sdio_hdr;
-	unsigned char *old_data;
-	unsigned int old_len;
+	unsigned char *old_data = NULL;
+	unsigned int old_len = 0;
 	int err, i, pad_size;
 	struct sk_buff *skb;
 	u16 dlen;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: mediatek: fix uninitialized symbol errors in btmtksdio_rx_packet
  2019-03-13 20:43 ` sean.wang
  (?)
@ 2019-03-18 16:55 ` Marcel Holtmann
  2019-03-18 18:02     ` Sean Wang
  -1 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2019-03-18 16:55 UTC (permalink / raw)
  To: Sean Wang; +Cc: Johan Hedberg, linux-bluetooth, linux-mediatek, linux-kernel

Hi Sean,

> Fixed all the below warnings. They would probably cause the following
> error handling path would use the uninitialized value and then produce
> unexpected behavior.
> 
> drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used
> uninitialized in this function [-Wmaybe-uninitialized]
>  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
>  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>          old_data, old_len, true);
>          ~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here
>  unsigned int old_len;
>               ^~~~~~~
> drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used
> uninitialized in this function [-Wmaybe-uninitialized]
>  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
>  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>          old_data, old_len, true);
>          ~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here
>  unsigned char *old_data;
>                 ^~~~~~~~
> 
> Fixes: d74eef2834b5 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Reported-by: Marcel Holtmann <marcel@holtmann.org>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> drivers/bluetooth/btmtksdio.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
> index b4b8320f279e..23cf63888bac 100644
> --- a/drivers/bluetooth/btmtksdio.c
> +++ b/drivers/bluetooth/btmtksdio.c
> @@ -372,8 +372,8 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size)
> 	const struct h4_recv_pkt *pkts = mtk_recv_pkts;
> 	int pkts_count = ARRAY_SIZE(mtk_recv_pkts);
> 	struct mtkbtsdio_hdr *sdio_hdr;
> -	unsigned char *old_data;
> -	unsigned int old_len;
> +	unsigned char *old_data = NULL;
> +	unsigned int old_len = 0;
> 	int err, i, pad_size;
> 	struct sk_buff *skb;
> 	u16 dlen;

or instead just remove this whole old_len + old_data stuff anyway since it is rather pointless. Or at least introduce a proper error path for sdio_readsb since you know when it fails, there is no point in writing the SKB.

Regards

Marcel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: mediatek: fix uninitialized symbol errors in btmtksdio_rx_packet
  2019-03-18 16:55 ` Marcel Holtmann
@ 2019-03-18 18:02     ` Sean Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Sean Wang @ 2019-03-18 18:02 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Johan Hedberg, linux-bluetooth, linux-mediatek, linux-kernel

On Mon, 2019-03-18 at 17:55 +0100, Marcel Holtmann wrote:
> Hi Sean,
> 
> > Fixed all the below warnings. They would probably cause the following
> > error handling path would use the uninitialized value and then produce
> > unexpected behavior.
> > 
> > drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
> >  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >          old_data, old_len, true);
> >          ~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here
> >  unsigned int old_len;
> >               ^~~~~~~
> > drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
> >  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >          old_data, old_len, true);
> >          ~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here
> >  unsigned char *old_data;
> >                 ^~~~~~~~
> > 
> > Fixes: d74eef2834b5 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices")
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Reported-by: Marcel Holtmann <marcel@holtmann.org>
> > Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> > ---
> > drivers/bluetooth/btmtksdio.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
> > index b4b8320f279e..23cf63888bac 100644
> > --- a/drivers/bluetooth/btmtksdio.c
> > +++ b/drivers/bluetooth/btmtksdio.c
> > @@ -372,8 +372,8 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size)
> > 	const struct h4_recv_pkt *pkts = mtk_recv_pkts;
> > 	int pkts_count = ARRAY_SIZE(mtk_recv_pkts);
> > 	struct mtkbtsdio_hdr *sdio_hdr;
> > -	unsigned char *old_data;
> > -	unsigned int old_len;
> > +	unsigned char *old_data = NULL;
> > +	unsigned int old_len = 0;
> > 	int err, i, pad_size;
> > 	struct sk_buff *skb;
> > 	u16 dlen;
> 
> or instead just remove this whole old_len + old_data stuff anyway since it is rather pointless. Or at least introduce a proper error path for sdio_readsb since you know when it fails, there is no point in writing the SKB.
> 
> Regards
> 

I will remove the old_len and old_data in the next version for the issue
because the error path for sdio_readsb seems wrong.

My initial purpose is that I would like to add a error path for these
packets which are successful at sdio_readsb but fail at packet format
parsing. I will update the error path for packet format error in
a separate patch.

> Marcel
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: mediatek: fix uninitialized symbol errors in btmtksdio_rx_packet
@ 2019-03-18 18:02     ` Sean Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Sean Wang @ 2019-03-18 18:02 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Johan Hedberg, linux-bluetooth, linux-mediatek, linux-kernel

On Mon, 2019-03-18 at 17:55 +0100, Marcel Holtmann wrote:
> Hi Sean,
> 
> > Fixed all the below warnings. They would probably cause the following
> > error handling path would use the uninitialized value and then produce
> > unexpected behavior.
> > 
> > drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
> >  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >          old_data, old_len, true);
> >          ~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here
> >  unsigned int old_len;
> >               ^~~~~~~
> > drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
> >  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >          old_data, old_len, true);
> >          ~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here
> >  unsigned char *old_data;
> >                 ^~~~~~~~
> > 
> > Fixes: d74eef2834b5 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices")
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Reported-by: Marcel Holtmann <marcel@holtmann.org>
> > Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> > ---
> > drivers/bluetooth/btmtksdio.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
> > index b4b8320f279e..23cf63888bac 100644
> > --- a/drivers/bluetooth/btmtksdio.c
> > +++ b/drivers/bluetooth/btmtksdio.c
> > @@ -372,8 +372,8 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size)
> > 	const struct h4_recv_pkt *pkts = mtk_recv_pkts;
> > 	int pkts_count = ARRAY_SIZE(mtk_recv_pkts);
> > 	struct mtkbtsdio_hdr *sdio_hdr;
> > -	unsigned char *old_data;
> > -	unsigned int old_len;
> > +	unsigned char *old_data = NULL;
> > +	unsigned int old_len = 0;
> > 	int err, i, pad_size;
> > 	struct sk_buff *skb;
> > 	u16 dlen;
> 
> or instead just remove this whole old_len + old_data stuff anyway since it is rather pointless. Or at least introduce a proper error path for sdio_readsb since you know when it fails, there is no point in writing the SKB.
> 
> Regards
> 

I will remove the old_len and old_data in the next version for the issue
because the error path for sdio_readsb seems wrong.

My initial purpose is that I would like to add a error path for these
packets which are successful at sdio_readsb but fail at packet format
parsing. I will update the error path for packet format error in
a separate patch.

> Marcel
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-18 18:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 20:43 [PATCH] Bluetooth: mediatek: fix uninitialized symbol errors in btmtksdio_rx_packet sean.wang
2019-03-13 20:43 ` sean.wang
2019-03-18 16:55 ` Marcel Holtmann
2019-03-18 18:02   ` Sean Wang
2019-03-18 18:02     ` Sean Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.