Thread (9 messages) 9 messages, 4 authors, 2015-01-21

Re: [PATCH] bluetooth: Add hci_h4p driver

From: Pavel Machek <hidden>
Date: 2015-01-20 21:49:26
Also in: linux-arm-kernel, linux-omap, lkml

On Tue 2015-01-20 10:28:50, Johan Hedberg wrote:
Hi Pavel,

On Tue, Dec 23, 2014, Pavel Machek wrote:
quoted
+	while (1) {
+		int cmd, len;
+
+		fw_pos += cmd_len;
+
+		if (fw_pos >= fw_entry->size)
+			break;
+
+		if (fw_pos + 2 > fw_entry->size) {
+			dev_err(info->dev, "Corrupted firmware image\n");
+			err = -EMSGSIZE;
+			break;
+		}
+
+		cmd_len = fw_entry->data[fw_pos++];
+		cmd_len += fw_entry->data[fw_pos++] << 8;
+		if (cmd_len == 0)
+			break;
+
+		if (fw_pos + cmd_len > fw_entry->size) {
+			dev_err(info->dev, "Corrupted firmware image\n");
+			err = -EMSGSIZE;
+			break;
+		}
+
+		/* Skip first two packets */
+		if (++num <= 2)
+			continue;
+
+		/* Note that this is timing-critical. If sending packets takes too
+		 * long, initialization will fail.
+		 */
+		cmd = fw_entry->data[fw_pos+1];
+		cmd += fw_entry->data[fw_pos+2] << 8;
+		len = fw_entry->data[fw_pos+3];
+
+		skb = __hci_cmd_sync(info->hdev, cmd, len, fw_entry->data+fw_pos+4, 500);
+		if (IS_ERR(skb)) {
+			dev_err(info->dev, "...sending cmd %x len %d failed %ld\n",
+				cmd, len, PTR_ERR(skb));
+			err = -EIO;
+			break;
+		}
+	}
Looks like the code is leaking skb when __hci_cmd_sync() succeeds.
Fixed, thanks!
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help