Bugs in LG kernel source code for Optimus V

I’ve discovered some bugs in the Linux kernel source code released by LG for the Virgin Mobile Optimus V, or VM670, a close CDMA twin to my Sprint Optimus S. It seems clear from the differences between the S and V source releases that LG has attempted to scrub code comments from the V source, but in the process they’ve created at least two syntax errors that break the code and cause it not to build.

They’ve also left out 15 files that are part of the Linux kernel’s netfilter and needed to build the kernel as configured by LG.

Update: LG has fixed the bugs, so keep reading only if you’re interested in the details.

I’ll detail the problems and explain how to (possibly) fix them below. However, the real issue is that the LG archive is broken as-is, so there’s no way it was used to build the actual Optimus V kernel. While I’m no GPL expert, it seems to me that LG is obligated to provide actual, working source code upon request, not an incomplete, broken fork. Let’s hope this was just an oversight, and one that LG will rectify.

What I found

Basically, I downloaded the VM670 source from LG’s open source code distribution site and tried to compile it, just as I have several times for the LS670. It’s worth noting here that, while the Optimus series is a popular model worldwide, with U.S. models including the T, U, M and Vortex, the S and V are particularly close because the V is based on the slightly older S, and both run on Sprint’s 3G network. They’re virtually identical, and it’s obvious from the source code that the VM670 code is derived from the LS670 code.

The first build error came on drivers/net/wireless/bcm4325/src/dhd/sys/dhd_sdio.c:

  CC [M]  drivers/net/wireless/bcm4325/src/dhd/sys/dhd_sdio.o
cc1: warnings being treated as errors
drivers/net/wireless/bcm4325/src/dhd/sys/dhd_sdio.c: In function 'dhdsdio_dpc':
drivers/net/wireless/bcm4325/src/dhd/sys/dhd_sdio.c:3997:1: error: ISO C90 forbids mixed declarations and code

Check out this diff and LG’s comment-scrubbing is clear. The block at line 3933 is where they accidentally deleted a closing brace. Putting the brace back in is easy enough.


  CC [M]  drivers/net/wireless/bcm4325/src/bcmsdio/sys/bcmsdh_sdmmc_linux.o
drivers/net/wireless/bcm4325/src/bcmsdio/sys/bcmsdh_sdmmc_linux.c: In function 'dhd_register_hwakeup':
drivers/net/wireless/bcm4325/src/bcmsdio/sys/bcmsdh_sdmmc_linux.c:725:2: error: expected expression before 'if'

Again, code-comment scrubbing caused an error. In the block at line 772, a function call spanning multiple lines is cut off. Again, easy enough to put back.

Finally, these 15 files relating to the Linux kernel’s netfilter code were all missing (apparently because the source code archive was made on a case-insensitive filesystem) in the VM670 source code, each time causing the compile to fail:


In the end, I was able to build the kernel by restoring these files from the LS670 source.

Unfortunately, even though it compiled, it’s quite possible that my kernel is not the same as the official kernel (if the VM670 netfilter code is different, or if other code is broken in a way that doesn’t raise an error). The only thing that is certain is that LG’s production kernel couldn’t have been compiled from this source code.

Time to contact LG

After I wrap this post up I’ll try to contact LG to see if they’ll fix the source code release, and report back here. (If you actually know anyone at LG who could help, please tell me!)

It’s worth saying here that LG isn’t under any obligation to provide end-user support, or to include their code comments. I don’t expect any of that (although they may find that it’s easier just to distribute the unmodified code, including comments, than to fix the bugs in their comment-scrubber). However, if they do strip code comments, they ought to have a build system that works like this:

source code -> strip comments -> compile

rather than:

source code -> compile -> strip comments

to ensure that they distribute correct source code. That way, LG wouldn’t even have to test the separate, comment-scrubbed branch to see if it works (which they clearly failed to do in this case), because they’re always building from that branch.

Obviously, LG isn’t fully complying with the GPL (version 2.0 of which covers the Linux kernel) by supplying wrong source code, but on the other hand, these errors are minor and appear to be unintentional. I’ve been complimentary of LG in the past, and hopefully this is just an oversight on their part. We’ll see if I get anywhere.

Update: And I did, for once! Kudos to LG for addressing the issue so promptly.

Filed under: Code.  Tagged: , , , , .

1 comment »