Kernel Patch Submission tutorial

Getting your patch submitted in Linux kernel could be one of the most satisfying job for a newbie Linux kernel developer. Until my first patch got in to mainline I was not knowing that this could be a very easy task as it seems to be.

There are many ways to submit a patch to Linux community, but will not discuss all of them as it could be very confusing. I have gone through all and came up with one most sure shot procedure.

Ok, so here is to the point step by step guide to submit your first linux kernel patch, and have your name in Linux kernel 🙂

I am considering you are doing all this in Ubuntu machine, for other flavors please tweak the commands accordingly.

 I. Tools Set up

    1) Install git : version control system for your Linux kernel

sudo apt-get install git

    2) Install git mail : you will be requiring this to send patches to Linux community

sudo apt-get install git-email

    3) Config git : create a file at your home directory vim ~/.gitconfig, and have the below details in it

name = Saurabh Sengar
email =
smtpencryption = tls
smtpserver =
smtpuser =
smtpserverport = 587
smtppass = XXXXXX

The above example is for my gmail id configuration to git. Change my email ids and names with yours, change smtp server if you are using an email other then gmail, but Heay ! who doesn’t have gmail id ? keep it simple :). And yeah don’t forget to write your actual gmail login password in place of XXXXXX, yes that’s right you heard it correct 😉

    4) Enable access for less secure apps in gmail : This is a very important step, otherwise gmail will not let you send your mails via git email client. So, to do this log in to your gmail id, and in same browser enter the below url.

It will show the option to ‘Turn on’ your access of less secure apps, select that !

II. Download Linux kernel

Go to your home directory, or any folder where you want to keep your linux kernel repository, run the below commands

git clone git://

This will take some time, go watch some movie and come back, don’t worry I will be waiting here.

 III. Creating a Patch

You have your changes ready ? in case you are not sure what you need to submit go to section V to know how all you begin to create the patches for contributing to linux kernel.

Say, you want to change the file ” drivers/staging/iio/iio_simple_dummy_buffer.c”

1 ) Do your changes in file and save it

vim drivers/staging/iio/iio_simple_dummy_buffer.c

2) Add the changes to your git

git add drivers/staging/iio/iio_simple_dummy_buffer.c

3) Commit your changes

git commit -s -v

You need to add a subject and description of changes you have made in patch. Do a git log of the file you have changed in order to get the format of subject and description for that particular file

Thing to make sure is that your sign-off tag should be there in this patch, anyway -s argument of above command will take care of it don’t worry.

4) Whom to send : Get the maintainers email ids by running get_maintainer script on your patch or file you changed

./script/ -f  drivers/staging/iio/iio_simple_dummy_buffer.c

./script/ –patch /tmp/0001-test.patch

copy these mail ids

And next section will be about sending your patch to linux community, but before that make sure your changes doesn’t have any coding style issues, this can be checked by script ./script/

./script/ -f drivers/staging/iio/iio_simple_dummy_buffer.c

./script/ –patch /tmp/0001-test.patch


IV. Sending The Patch

This is easy

git send-email –annotate HEAD^1

it will prompt for email ids whom to sent, paste the email ids copied “whom to send” section. It may also ask for ‘in reply to’ you can just avoid it by pressing enter for first patch as this option is for replying on an existing mail chain. Then for final confirmation it will ask, press ‘y’ … hit enter …. and YOU ARE DONE !! 🙂

After some 10 -15 minutes you can see your patch in site, good start :). And if every thing goes fine soon your patch will be merged in mainline. Depending on the complexity of patch and availability of maintainers your patch can be given feed back ranging from 1 minute to 20 days. In case you don’t get any feedback ping them back, but at least give around 20 days to Linux Kernel Maintainers to respond.

V. What to submit

I would suggest to start your patch submission from driver/staging directory, until you are confident enough on how to send patches.

You can run some static analyzer tool in order to fix there errors, but keep in mind that there could be many false positives too by these tools, so be careful !

Run on kernel, and fix the errors/warnings reported by it, these are many.

Run coccicheck:

After that you gan grep for “TODO” and “FIXME” in kernel code, and can implement the missing logic, be careful here.

And if you are confident in some module or framework of linux kernel, go review them and in case you feel you can make them better go ahead and do the changes.

And as the last advice I can give you while interacting with Linux kernel developers in lkml, be patient and be humble 🙂

Get your hands dirty and let me know if you need any help in comments section.


Hope this helps,

Saurabh Singh Sengar

email-to :



5 thoughts on “Kernel Patch Submission tutorial

  1. Amitav says:

    There are numerous articles on submitting patches in Linux kernel, but this one seems to be the most lucid and easy to understand. Thanks for this helpful blog.


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s