Accepted as an Outreachy Intern!

I’ve been accepted as an Outreachy intern and will be working on Coccinelle under the guidance of Julia Lawall over the summer!

Julia has a lot of interesting tasks in mind for the internship, but for now I’m working on running and checking scripts from coccinellery and submitting patches based on them.

This is quite interesting because I get to understand common bugs and learn about different functions used in the kernel. For example, I was introduced to devres during the application period of Outreachy and now continue to understand how managed resources work, analyse coccinelle scripts finding devm function bugs and submit patches based on them.

What is devres?

Every driver has some memory resources which are allocated using functions and stored as a linked list of arbitrarily sized memory areas associated with a device. This is called devres.

The special thing about devres or managed resources is that the memory allocated is automatically freed when a driver detaches.

For example, devm_kzalloc() is the managed version of kzalloc(), a very common function in the kernel used to allocate memory. With devm_kzalloc() we do not need kfree() to free memory allocated by devm_kzalloc(), since it is automatically freed when the driver detaches.

There are several managed resource interfaces, a full list of which can be found here.

But many developers still add these freeing functions for devm allocated memory, here is where the awesomeness of Coccinelle steps in. Coccinellery has a couple of scripts to detect these devm bugs and a lot of opportunities to submit patches.

Another interesting devm_ function is devm_ioremap_resource. The usual null error check is actually incorrect for this function, instead it returns an ERR_PTR() encoded error on failure, but developers have not switched the error checks everywhere . Coccinellery contains a semantic patch for this and I’ve submitted several patches like this to rectify this which has already been applied in the kernel.

Julia also recommends this semantic patch to be added to the kernel so I will be understanding how to go about adding the patch to the kernel also!

Exciting internship indeed! 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s